Commit 02cff8aa authored by Bernardo Dal Seno's avatar Bernardo Dal Seno

QA: Decision about disk templates to use is more modular

qa_config.IsTemplateSupported() is already used to decide which disk
templates are supported by QA. Enabled templates now are part of that

Unit tests are updated.
Signed-off-by: default avatarBernardo Dal Seno <>
Reviewed-by: default avatarGuido Trotter <>
parent 7209d304
......@@ -577,21 +577,16 @@ def TestIPolicyPlainInstance():
def RunInstanceTests():
"""Create and exercise instances."""
instance_tests = []
enabled_disk_templates = qa_config.GetEnabledDiskTemplates()
# FIXME: Refactor this to make the code more elegant wrt to disk templates.
if constants.DT_PLAIN in enabled_disk_templates:
instance_tests.append(("instance-add-plain-disk", constants.DT_PLAIN,
qa_instance.TestInstanceAddWithPlainDisk, 1))
if constants.DT_DRBD8 in enabled_disk_templates:
instance_tests.append(("instance-add-drbd-disk", constants.DT_DRBD8,
qa_instance.TestInstanceAddWithDrbdDisk, 2))
if constants.DT_DISKLESS in enabled_disk_templates:
instance_tests.append(("instance-add-diskless", constants.DT_DISKLESS,
qa_instance.TestInstanceAddDiskless, 1))
if constants.DT_FILE in enabled_disk_templates:
instance_tests.append(("instance-add-file", constants.DT_FILE,
qa_instance.TestInstanceAddFile, 1))
instance_tests = [
("instance-add-plain-disk", constants.DT_PLAIN,
qa_instance.TestInstanceAddWithPlainDisk, 1),
("instance-add-drbd-disk", constants.DT_DRBD8,
qa_instance.TestInstanceAddWithDrbdDisk, 2),
("instance-add-diskless", constants.DT_DISKLESS,
qa_instance.TestInstanceAddDiskless, 1),
("instance-add-file", constants.DT_FILE,
qa_instance.TestInstanceAddFile, 1)
for (test_name, templ, create_fun, num_nodes) in instance_tests:
if (qa_config.TestEnabled(test_name) and
......@@ -412,8 +412,9 @@ class _QaConfig(object):
"""Is the given disk template supported by the current configuration?
return (not self.GetExclusiveStorage() or
templ in constants.DTS_EXCL_STORAGE)
enabled = templ in self.GetEnabledDiskTemplates()
return enabled and (not self.GetExclusiveStorage() or
templ in constants.DTS_EXCL_STORAGE)
def GetVclusterSettings(self):
"""Returns settings for virtual cluster.
......@@ -608,7 +609,7 @@ def GetExclusiveStorage():
def IsTemplateSupported(templ):
"""Wrapper for L{_QaConfig.GetExclusiveStorage}.
"""Wrapper for L{_QaConfig.IsTemplateSupported}.
return GetConfig().IsTemplateSupported(templ)
......@@ -4,6 +4,12 @@
"disk": ["1G", "512M"],
"disk-growth": ["2G", "768M"],
"enabled-disk-templates": [
"nodes": [
"# Master node": null,
......@@ -308,8 +308,13 @@ class TestQaConfig(unittest.TestCase):
self.assertEqual(self.config.GetExclusiveStorage(), bool(value))
def testIsTemplateSupported(self):
enabled_dts = self.config.GetEnabledDiskTemplates()
for e_s in [False, True]:
for template in constants.DISK_TEMPLATES:
if value and template not in constants.DTS_EXCL_STORAGE:
if (template not in enabled_dts or
e_s and template not in constants.DTS_EXCL_STORAGE):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment