]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Respect --os-version and --os-type in teuthology.run.
authorAndrew Schoen <aschoen@redhat.com>
Tue, 16 Dec 2014 15:38:21 +0000 (09:38 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Wed, 17 Dec 2014 20:36:40 +0000 (14:36 -0600)
Remove default value of 'ubuntu' for --os-type for teuthology.run and
make sure that teuthology.misc.get_distro accounts for ctx.os_type now
defaulting to None instead of 'ubuntu'.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
scripts/run.py
scripts/test/test_run.py
teuthology/misc.py
teuthology/run.py
teuthology/test/test_get_distro.py
teuthology/test/test_run.py

index 9cddeb0b351d6098c7c9ef01a1e7557b96e2aaba..ea60ff5457659ee732768f5eb0b20ef9c1c17329 100644 (file)
@@ -17,7 +17,7 @@ optional arguments:
   --owner OWNER                  job owner
   --lock                         lock machines for the duration of the run
   --machine-type MACHINE_TYPE    Type of machine to lock/run tests on.
-  --os-type OS_TYPE              Distro/OS of machine to run test on [default: ubuntu].
+  --os-type OS_TYPE              Distro/OS of machine to run test on.
   --os-version OS_VERSION        Distro/OS version of machine to run test on.
   --block                        block until locking machines succeeds (use with --lock)
   --name NAME                    name for this teuthology run
index f13345172b010fb82e5294cb253d3aaf5c0c1b12..74fa1b9263479009cd741e6e38c0468de98ebc87 100644 (file)
@@ -43,5 +43,3 @@ class TestRun(Script):
             "config2.yml",
         ])
         assert args["<config>"] == ["config1.yml", "config2.yml"]
-        # make sure defaults are working
-        assert args["--os-type"] == "ubuntu"
index aab0d89ed6ce6dc3616df335bc278aa805381eb9..44088842471bee7f4b5936fe8197bfe6e025773e 100644 (file)
@@ -1153,16 +1153,21 @@ def get_distro(ctx):
     """
     Get the name of the distro that we are using (usually the os_type).
     """
+    os_type = None
+    # first, try to get the os_type from the config of --os-type
     try:
         os_type = ctx.config.get('os_type', ctx.os_type)
     except AttributeError:
-        os_type = 'ubuntu'
+        pass
+    # next, look for an override in the downburst config for os_type
     try:
-        return ctx.config['downburst'].get('distro', os_type)
-    except KeyError:
-        return os_type
-    except AttributeError:
-        return ctx.os_type
+        os_type = ctx.config['downburst'].get('distro', os_type)
+    except (KeyError, AttributeError):
+        pass
+    if os_type is None:
+        # default to ubuntu if we can't find the os_type anywhere else
+        return "ubuntu"
+    return os_type
 
 
 def get_distro_version(ctx):
index 084df094bdaf0b6a20de6fe5767e26b1551df6e4..a0f75339cef4ab166dc0e9afb3aa1ef7b12ba582 100644 (file)
@@ -254,6 +254,8 @@ def main(args):
     block = args["--block"]
     lock = args["--lock"]
     suite_path = args["--suite-path"]
+    os_type = args["--os-type"]
+    os_version = args["--os-version"]
 
     set_up_logging(verbose, archive)
 
@@ -291,6 +293,14 @@ def main(args):
     # fetches the tasks and returns a new suite_path if needed
     config["suite_path"] = fetch_tasks_if_needed(config)
 
+    # overwrite the config value of os_type if --os-type is provided
+    if os_type:
+        config["os_type"] = os_type
+
+    # overwrite the config value of os_version if --os-version is provided
+    if os_version:
+        config["os_version"] = os_version
+
     # create a FakeNamespace instance that mimics the old argparse way of doing
     # things we do this so we can pass it to run_tasks without porting those
     # tasks to the new way of doing things right now
index 3ade547e05864dd84ae13d4c2a75b20f5c753798..c61de99465902980ab5bc372c036d9cd32632aac 100644 (file)
@@ -2,12 +2,14 @@ from .. import misc as teuthology
 
 class Mock: pass
 
+
 class TestGetDistro(object):
 
     def setup(self):
         self.fake_ctx = Mock()
         self.fake_ctx.config = {}
-        self.fake_ctx.os_type = 'ubuntu'
+        # os_type in ctx will always default to None
+        self.fake_ctx.os_type = None
 
     def test_default_distro(self):
         distro = teuthology.get_distro(self.fake_ctx)
@@ -27,3 +29,8 @@ class TestGetDistro(object):
         self.fake_ctx.config = {'downburst' : {'distro': 'sles'}}
         distro = teuthology.get_distro(self.fake_ctx)
         assert distro == 'sles'
+
+    def test_no_config_or_os_type(self):
+        self.fake_ctx = Mock()
+        distro = teuthology.get_distro(self.fake_ctx)
+        assert distro == 'ubuntu'
index 82caad6d24ee67e21f0773a4953971eddf3df590..c56ac521552189590f123bfd112145e8f591b8b2 100644 (file)
@@ -194,3 +194,6 @@ class TestRun(object):
         # ensures that values missing in args are added with the correct value
         assert fake_ctx["owner"] == "the_owner"
         assert fake_ctx["machine_type"] == "machine_type"
+        # 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"