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
operations.
Signed-off-by: default avatarDimitris Bliablias <bl.dimitris@gmail.com>
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent ab24db50
......@@ -794,6 +794,9 @@ def IsExclusiveStorageInstanceTestEnabled():
def RunInstanceTests():
"""Create and exercise instances."""
requested_conversions = qa_config.get("convert-disk-templates", [])
supported_conversions = \
set(requested_conversions).difference(constants.DTS_NOT_CONVERTIBLE_TO)
for (test_name, templ, create_fun, num_nodes) in \
qa_instance.available_instance_tests:
if (qa_config.TestEnabled(test_name) and
......@@ -817,11 +820,21 @@ def RunInstanceTests():
RunTestIf("group-rwops", qa_group.TestAssignNodesIncludingSplit,
constants.INITIAL_NODE_GROUP_NAME,
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)
RunTest(qa_instance.TestInstanceConvertDiskToPlain,
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,
supported_conversions)
RunTest(qa_instance.TestInstanceStartup, instance)
# At this point we clear the set because the requested conversions
# has been tested
supported_conversions.clear()
else:
test_desc = "Converting instance of template %s" % templ
ReportTestSkip(test_desc, "conversion feature")
RunTestIf("instance-modify-disks",
qa_instance.TestInstanceModifyDisks, instance)
RunCommonInstanceTests(instance, inodes)
......
......@@ -44,6 +44,13 @@
"diskless"
],
"# Only test the following disk template conversions": null,
"convert-disk-templates": [
"plain",
"drbd",
"diskless"
],
"# 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):
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
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])
cmd.append(name)
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")
return
name = instance.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)
return
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):
continue
AssertCommand(_BuildConvertCommand(templ, snode))
# Before we return, convert to the original template
AssertCommand(_BuildConvertCommand(template, snode))
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
......
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