Commit 462f0faa authored by Helga Velroyen's avatar Helga Velroyen
Browse files

QA: dis/enabling of used disk templates



This extends the QA for 'gnt-cluster modify'. It ensures
that disabling of a disk template is only possible if the
cluster does not have any instances using the template.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarMichele Tartara <mtarara@google.com>
parent e04ec58e
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
"vg-name": "xenvg", "vg-name": "xenvg",
"# Cluster-level value of the exclusive-storage flag": null, "# Cluster-level value of the exclusive-storage flag": null,
"exclusive-storage": null, "exclusive-storage": null,
"# Only enable disk templates that the QA machines can actually use.": null,
"enabled-disk-templates": [ "enabled-disk-templates": [
"plain", "plain",
"drbd", "drbd",
......
...@@ -35,6 +35,7 @@ from ganeti import pathutils ...@@ -35,6 +35,7 @@ from ganeti import pathutils
import qa_config import qa_config
import qa_utils import qa_utils
import qa_error import qa_error
import qa_instance
from qa_utils import AssertEqual, AssertCommand, GetCommandOutput from qa_utils import AssertEqual, AssertCommand, GetCommandOutput
...@@ -392,29 +393,101 @@ def TestClusterModifyDisk(): ...@@ -392,29 +393,101 @@ def TestClusterModifyDisk():
def TestClusterModifyDiskTemplates(): def TestClusterModifyDiskTemplates():
"""gnt-cluster modify --enabled-disk-templates=...""" """gnt-cluster modify --enabled-disk-templates=..."""
enabled_disk_templates = qa_config.GetEnabledDiskTemplates()
default_disk_template = qa_config.GetDefaultDiskTemplate() default_disk_template = qa_config.GetDefaultDiskTemplate()
_TestClusterModifyDiskTemplatesArguments(default_disk_template,
enabled_disk_templates)
_RestoreEnabledDiskTemplates()
nodes = qa_config.AcquireManyNodes(2)
instance_template = enabled_disk_templates[0]
instance = qa_instance.CreateInstanceByDiskTemplate(nodes, instance_template)
_TestClusterModifyUnusedDiskTemplate(instance_template)
_TestClusterModifyUsedDiskTemplate(instance_template,
enabled_disk_templates)
qa_instance.TestInstanceRemove(instance)
_RestoreEnabledDiskTemplates()
def _RestoreEnabledDiskTemplates():
"""Sets the list of enabled disk templates back to the list of enabled disk
templates from the QA configuration. This can be used to make sure that
the tests that modify the list of disk templates do not interfere with
other tests.
"""
AssertCommand( AssertCommand(
["gnt-cluster", "modify", ["gnt-cluster", "modify",
"--enabled-disk-templates=%s" % default_disk_template], "--enabled-disk-template=%s" %
",".join(qa_config.GetEnabledDiskTemplates())],
fail=False) fail=False)
AssertCommand(["gnt-cluster", "info"])
def _TestClusterModifyDiskTemplatesArguments(default_disk_template,
enabled_disk_templates):
"""Tests argument handling of 'gnt-cluster modify' with respect to
the parameter '--enabled-disk-templates'. This test is independent
of instances.
"""
AssertCommand( AssertCommand(
["gnt-cluster", "modify", ["gnt-cluster", "modify",
"--enabled-disk-template=%s" % "--enabled-disk-template=%s" %
",".join(qa_config.GetEnabledDiskTemplates())], ",".join(enabled_disk_templates)],
fail=False) fail=False)
AssertCommand(["gnt-cluster", "info"])
# bogus templates # bogus templates
AssertCommand(["gnt-cluster", "modify", AssertCommand(["gnt-cluster", "modify",
"--enabled-disk-templates=pinkbunny"], "--enabled-disk-templates=pinkbunny"],
fail=True) fail=True)
# duplicate entries do no harm # duplicate entries do no harm
AssertCommand( AssertCommand(
["gnt-cluster", "modify", ["gnt-cluster", "modify",
"--enabled-disk-templates=%s,%s" % "--enabled-disk-templates=%s,%s" %
(default_disk_template, default_disk_template)], (default_disk_template, default_disk_template)],
fail=False) fail=False)
AssertCommand(["gnt-cluster", "info"])
def _TestClusterModifyUsedDiskTemplate(instance_template,
enabled_disk_templates):
"""Tests that disk templates that are currently in use by instances cannot
be disabled on the cluster.
"""
# If the list of enabled disk templates contains only one template
# we need to add some other templates, because the list of enabled disk
# templates can only be set to a non-empty list.
new_disk_templates = list(set(enabled_disk_templates)
- set([instance_template]))
if not new_disk_templates:
new_disk_templates = list(set(constants.DISK_TEMPLATES)
- set([instance_template]))
AssertCommand(
["gnt-cluster", "modify",
"--enabled-disk-templates=%s" %
",".join(new_disk_templates)],
fail=True)
def _TestClusterModifyUnusedDiskTemplate(instance_template):
"""Tests that unused disk templates can be disabled safely."""
all_disk_templates = constants.DISK_TEMPLATES
AssertCommand(
["gnt-cluster", "modify",
"--enabled-disk-templates=%s" %
",".join(all_disk_templates)],
fail=False)
new_disk_templates = [instance_template]
AssertCommand(
["gnt-cluster", "modify",
"--enabled-disk-templates=%s" %
",".join(new_disk_templates)],
fail=False)
def TestClusterModifyBe(): def TestClusterModifyBe():
......
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