Commit 68ed58a7 authored by Dimitris Bliablias's avatar Dimitris Bliablias Committed by Petr Pudlak

QA: add support for the disk template conversion

This patch provides support for testing the disk template conversion
feature between all the available disk templates.

The number of the disk templates that will be tested will be specified
by the user, and so we introduce a new option in the 'qa-sample.json'
file named 'convert-disk-templates'. The conversion test will run once
and will cover all the user-provided templates that are enabled in the
cluster. Since the conversion goes through a pipe, it suffices to test
every template once for import and once for export. This means that a
list of N templates to test, translates to N distinct conversion
Signed-off-by: default avatarDimitris Bliablias <>
Signed-off-by: default avatarPetr Pudlak <>
Reviewed-by: default avatarPetr Pudlak <>
parent ab24db50
......@@ -794,6 +794,9 @@ def IsExclusiveStorageInstanceTestEnabled():
def RunInstanceTests():
"""Create and exercise instances."""
requested_conversions = qa_config.get("convert-disk-templates", [])
supported_conversions = \
for (test_name, templ, create_fun, num_nodes) in \
if (qa_config.TestEnabled(test_name) and
......@@ -817,11 +820,21 @@ def RunInstanceTests():
RunTestIf("group-rwops", qa_group.TestAssignNodesIncludingSplit,
inodes[0].primary, inodes[1].primary)
# This test will run once but it will cover all the supported
# user-provided disk template conversions
if qa_config.TestEnabled("instance-convert-disk"):
RunTest(qa_instance.TestInstanceShutdown, instance)
instance, inodes)
RunTest(qa_instance.TestInstanceStartup, instance)
if (len(supported_conversions) > 1 and
instance.disk_template in supported_conversions):
RunTest(qa_instance.TestInstanceShutdown, instance)
RunTest(qa_instance.TestInstanceConvertDiskTemplate, instance,
RunTest(qa_instance.TestInstanceStartup, instance)
# At this point we clear the set because the requested conversions
# has been tested
test_desc = "Converting instance of template %s" % templ
ReportTestSkip(test_desc, "conversion feature")
qa_instance.TestInstanceModifyDisks, instance)
RunCommonInstanceTests(instance, inodes)
......@@ -44,6 +44,13 @@
"# Only test the following disk template conversions": null,
"convert-disk-templates": [
"# Default file storage directories": null,
"default-file-storage-dir": "/srv/ganeti/file-storage",
"default-shared-file-storage-dir": "/srv/ganeti/shared-file-storage",
......@@ -698,20 +698,47 @@ def TestInstanceStoppedModify(instance):
def TestInstanceConvertDiskToPlain(instance, inodes):
def TestInstanceConvertDiskTemplate(instance, requested_conversions):
"""gnt-instance modify -t"""
def _BuildConvertCommand(disk_template, node):
cmd = ["gnt-instance", "modify", "-t", disk_template]
if disk_template == constants.DT_DRBD8:
cmd.extend(["-n", node])
return cmd
if len(requested_conversions) < 2:
print qa_utils.FormatInfo("You must specify more than one convertible"
" disk templates in order to test the conversion"
" feature")
name =
template = instance.disk_template
if template != constants.DT_DRBD8:
if template in constants.DTS_NOT_CONVERTIBLE_FROM:
print qa_utils.FormatInfo("Unsupported template %s, skipping conversion"
" test" % template)
assert len(inodes) == 2
AssertCommand(["gnt-instance", "modify", "-t", constants.DT_PLAIN, name])
AssertCommand(["gnt-instance", "modify", "-t", constants.DT_DRBD8,
"-n", inodes[1].primary, name])
inodes = qa_config.AcquireManyNodes(2)
master = qa_config.GetMasterNode()
snode = inodes[0].primary
if master.primary == snode:
snode = inodes[1].primary
enabled_disk_templates = qa_config.GetEnabledDiskTemplates()
for templ in requested_conversions:
if (templ == template or
templ not in enabled_disk_templates or
templ in constants.DTS_NOT_CONVERTIBLE_TO):
AssertCommand(_BuildConvertCommand(templ, snode))
# Before we return, convert to the original template
AssertCommand(_BuildConvertCommand(template, snode))
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment