]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Log the teuthology command being ran at the debug level 410/head
authorAndrew Schoen <aschoen@redhat.com>
Mon, 19 Jan 2015 17:09:46 +0000 (11:09 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Mon, 19 Jan 2015 18:51:12 +0000 (12:51 -0600)
Signed-off-by: Andrew Schoen <aschoen@redhat.com>
teuthology/run.py
teuthology/test/test_run.py

index 5de21caebd5a287c3f17e295663814bb647dd2e9..153bd61ba6ef46386183b1d4d0fb72f324988ef2 100644 (file)
@@ -243,6 +243,28 @@ def report_outcome(config, archive, summary, fake_ctx):
         sys.exit(1)
 
 
+def get_teuthology_command(args):
+    """
+    Rebuilds the teuthology command used to run this job
+    and returns it as a string.
+    """
+    cmd = ["teuthology"]
+    for key, value in args.iteritems():
+        if value:
+            # an option, not an argument
+            if not key.startswith("<"):
+                cmd.append(key)
+            else:
+                # this is the <config> argument
+                for arg in value:
+                    cmd.append(str(arg))
+                continue
+            # so we don't print something like --verbose True
+            if isinstance(value, str):
+                cmd.append(value)
+    return " ".join(cmd)
+
+
 def main(args):
     verbose = args["--verbose"]
     archive = args["--archive"]
@@ -259,6 +281,9 @@ def main(args):
 
     set_up_logging(verbose, archive)
 
+    # print the command being ran
+    log.debug("Teuthology command: {0}".format(get_teuthology_command(args)))
+
     if owner is None:
         args["--owner"] = owner = get_user()
 
index c56ac521552189590f123bfd112145e8f591b8b2..3f4ba40406ee3779677b7ef74ee6972c426cf1c6 100644 (file)
@@ -197,3 +197,30 @@ class TestRun(object):
         # ensures os_type and os_version are property overwritten
         assert fake_ctx["config"]["os_type"] == "os_type"
         assert fake_ctx["config"]["os_version"] == "os_version"
+
+    def test_get_teuthology_command(self):
+        doc = scripts_run.__doc__
+        args = docopt.docopt(doc, [
+            "--archive", "some/archive/dir",
+            "--description", "the_description",
+            "--lock",
+            "--block",
+            "--name", "the_name",
+            "--suite-path", "some/suite/dir",
+            "path/to/config.yml", "path/to/config2.yaml",
+        ])
+        result = run.get_teuthology_command(args)
+        result = result.split()
+        expected = [
+            "teuthology",
+            "path/to/config.yml", "path/to/config2.yaml",
+            "--suite-path", "some/suite/dir",
+            "--lock",
+            "--description", "the_description",
+            "--name", "the_name",
+            "--block",
+            "--archive", "some/archive/dir",
+        ]
+        assert len(result) == len(expected)
+        for arg in expected:
+            assert arg in result