]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Make teuthology-lock respect --os-type 418/head
authorAndrew Schoen <aschoen@redhat.com>
Fri, 23 Jan 2015 22:21:19 +0000 (16:21 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Mon, 26 Jan 2015 15:13:47 +0000 (09:13 -0600)
This fixes the regression in issue #10621

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

index 67212d52fc0685ad2a15aa68c37defc6eddef704..06b75c1a39f32bdf3cd8b4e2ce82a12de9bc76bb 100644 (file)
@@ -1155,13 +1155,11 @@ 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 or --os-type
-    # FIXME: checking for ctx.os_type here should not be needed as
-    # ctx.os_type is assigned to ctx.config["os_type"] if provided
-    # in teuthology.run. We're gonna leave it here for now until we
-    # have the time to fully investigate and test it's removal.
+    if ctx.os_type:
+        return ctx.os_type
+
     try:
-        os_type = ctx.config.get('os_type', ctx.os_type)
+        os_type = ctx.config.get('os_type', None)
     except AttributeError:
         pass
     # next, look for an override in the downburst config for os_type
index 4524f6f298d252c58dab562e2471318494d9e255..862ea07b2046093d8d1e91b31859313afa08fd2f 100644 (file)
@@ -18,6 +18,8 @@ class TestGetDistro(object):
         assert distro == 'ubuntu'
 
     def test_argument(self):
+        # we don't want fake_ctx to have a config
+        self.fake_ctx = Mock()
         self.fake_ctx.os_type = 'centos'
         distro = get_distro(self.fake_ctx)
         assert distro == 'centos'
@@ -27,6 +29,12 @@ class TestGetDistro(object):
         distro = get_distro(self.fake_ctx)
         assert distro == 'fedora'
 
+    def test_argument_takes_precedence(self):
+        self.fake_ctx.config = {'os_type': 'fedora'}
+        self.fake_ctx.os_type = "centos"
+        distro = get_distro(self.fake_ctx)
+        assert distro == 'centos'
+
     def test_teuth_config_downburst(self):
         self.fake_ctx.config = {'downburst' : {'distro': 'sles'}}
         distro = get_distro(self.fake_ctx)
@@ -34,5 +42,6 @@ class TestGetDistro(object):
 
     def test_no_config_or_os_type(self):
         self.fake_ctx = Mock()
+        self.fake_ctx.os_type = None
         distro = get_distro(self.fake_ctx)
         assert distro == 'ubuntu'
index f597040098f6c1de4d52943ea6dd6f50558a82b0..75845ad7a6a3cb35a7410ca12121896905a6b352 100644 (file)
@@ -13,6 +13,8 @@ class TestGetDistroVersion(object):
         self.fake_ctx_noarg = Mock()
         self.fake_ctx_noarg.config = {}
         self.fake_ctx_noarg.os_version = None
+        self.fake_ctx.os_type = None
+        self.fake_ctx_noarg.os_type = None
 
     def test_default_distro_version(self):
         #Default distro is ubuntu, default version of ubuntu is 12.04