Commit dacd8ba4 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

QA: Extend cluster QA wrt enabled storage types



This extends the QA scripts to test the changes in 'gnt-cluster init',
'gnt-cluster info', and 'gnt-cluster modify' with respect to enabled
storage types.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent c074a9e8
......@@ -177,6 +177,7 @@ def RunClusterTests():
("cluster-modify", qa_cluster.TestClusterModifyISpecs),
("cluster-modify", qa_cluster.TestClusterModifyBe),
("cluster-modify", qa_cluster.TestClusterModifyDisk),
("cluster-modify", qa_cluster.TestClusterModifyStorageTypes),
("cluster-rename", qa_cluster.TestClusterRename),
("cluster-info", qa_cluster.TestClusterVersion),
("cluster-info", qa_cluster.TestClusterInfo),
......
......@@ -27,6 +27,7 @@
"vg-name": "xenvg",
"# Cluster-level value of the exclusive-storage flag": null,
"exclusive-storage": null,
"enabled-storage-types": "lvm-vg",
"# Additional arguments for initializing cluster": null,
"cluster-init-args": [],
......
......@@ -190,6 +190,8 @@ def TestClusterInit(rapi_user, rapi_secret):
"gnt-cluster", "init",
"--primary-ip-version=%d" % qa_config.get("primary_ip_version", 4),
"--enabled-hypervisors=%s" % ",".join(qa_config.GetEnabledHypervisors()),
"--enabled-storage-types=%s" %
",".join(qa_config.GetEnabledStorageTypes())
]
for spec_type in ("mem-size", "disk-size", "disk-count", "cpu-count",
......@@ -402,6 +404,33 @@ def TestClusterModifyDisk():
AssertCommand(["gnt-cluster", "modify", "-D", param], fail=True)
def TestClusterModifyStorageTypes():
"""gnt-cluster modify --enabled-storage-types=..."""
default_storage_type = qa_config.GetDefaultStorageType()
AssertCommand(
["gnt-cluster", "modify",
"--enabled-storage-types=%s" % default_storage_type],
fail=False)
AssertCommand(["gnt-cluster", "info"])
AssertCommand(
["gnt-cluster", "modify",
"--enabled-storage-types=%s" %
",".join(qa_config.GetEnabledStorageTypes())],
fail=False)
AssertCommand(["gnt-cluster", "info"])
# bogus types
AssertCommand(["gnt-cluster", "modify",
"--enabled-storage-types=pinkbunny"],
fail=True)
# duplicate entries do no harm
AssertCommand(
["gnt-cluster", "modify",
"--enabled-storage-types=%s,%s" %
(default_storage_type, default_storage_type)],
fail=False)
AssertCommand(["gnt-cluster", "info"])
def TestClusterModifyBe():
"""gnt-cluster modify -B"""
for fail, cmd in [
......
......@@ -38,6 +38,7 @@ _INSTANCE_CHECK_KEY = "instance-check"
_ENABLED_HV_KEY = "enabled-hypervisors"
_VCLUSTER_MASTER_KEY = "vcluster-master"
_VCLUSTER_BASEDIR_KEY = "vcluster-basedir"
_ENABLED_STORAGE_TYPES_KEY = "enabled-storage-types"
#: QA configuration (L{_QaConfig})
_config = None
......@@ -348,29 +349,51 @@ class _QaConfig(object):
@rtype: list
"""
return self._GetStringListParameter(
_ENABLED_HV_KEY,
[constants.DEFAULT_ENABLED_HYPERVISOR])
def GetDefaultHypervisor(self):
"""Returns the default hypervisor to be used.
"""
return self.GetEnabledHypervisors()[0]
def GetEnabledStorageTypes(self):
"""Returns the list of enabled storage types.
@rtype: list
"""
return self._GetStringListParameter(
_ENABLED_STORAGE_TYPES_KEY,
list(constants.DEFAULT_ENABLED_STORAGE_TYPES))
def GetDefaultStorageType(self):
"""Returns the default storage type to be used.
"""
return self.GetEnabledStorageTypes()[0]
def _GetStringListParameter(self, key, default_values):
"""Retrieves a parameter's value that is supposed to be a list of strings.
@rtype: list
"""
try:
value = self._data[_ENABLED_HV_KEY]
value = self._data[key]
except KeyError:
return [constants.DEFAULT_ENABLED_HYPERVISOR]
return default_values
else:
if value is None:
return []
elif isinstance(value, basestring):
# The configuration key ("enabled-hypervisors") implies there can be
# multiple values. Multiple hypervisors are comma-separated on the
# command line option to "gnt-cluster init", so we need to handle them
# equally here.
return value.split(",")
else:
return value
def GetDefaultHypervisor(self):
"""Returns the default hypervisor to be used.
"""
return self.GetEnabledHypervisors()[0]
def SetExclusiveStorage(self, value):
"""Set the expected value of the C{exclusive_storage} flag for the cluster.
......@@ -528,6 +551,20 @@ def GetDefaultHypervisor(*args):
return GetConfig().GetDefaultHypervisor(*args)
def GetEnabledStorageTypes(*args):
"""Wrapper for L{_QaConfig.GetEnabledStorageTypes}.
"""
return GetConfig().GetEnabledStorageTypes(*args)
def GetDefaultStorageType(*args):
"""Wrapper for L{_QaConfig.GetDefaultStorageType}.
"""
return GetConfig().GetDefaultStorageType(*args)
def GetMasterNode():
"""Wrapper for L{_QaConfig.GetMasterNode}.
......
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