--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
"config2.yml",
])
assert args["<config>"] == ["config1.yml", "config2.yml"]
- # make sure defaults are working
- assert args["--os-type"] == "ubuntu"
"""
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):
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)
# 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
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)
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'
# 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"