From: Andrew Schoen Date: Fri, 23 Jan 2015 22:21:19 +0000 (-0600) Subject: Make teuthology-lock respect --os-type X-Git-Tag: 1.1.0~1031^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F418%2Fhead;p=teuthology.git Make teuthology-lock respect --os-type This fixes the regression in issue #10621 Signed-off-by: Andrew Schoen --- diff --git a/teuthology/misc.py b/teuthology/misc.py index 67212d52f..06b75c1a3 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -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 diff --git a/teuthology/test/test_get_distro.py b/teuthology/test/test_get_distro.py index 4524f6f29..862ea07b2 100644 --- a/teuthology/test/test_get_distro.py +++ b/teuthology/test/test_get_distro.py @@ -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' diff --git a/teuthology/test/test_get_distro_version.py b/teuthology/test/test_get_distro_version.py index f59704009..75845ad7a 100644 --- a/teuthology/test/test_get_distro_version.py +++ b/teuthology/test/test_get_distro_version.py @@ -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