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

QA: skip lvm-based tests if lvm disabled



QA tests should make sure not to be run if the necessary
environment for them is not present. This patch fixes that
for a couple of tests that fail to check that before being
executed.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent b24b52d9
......@@ -437,7 +437,8 @@ def RunExportImportTests(instance, inodes):
# FIXME: inter-cluster-instance-move crashes on file based instances :/
# See Issue 414.
if (qa_config.TestEnabled([qa_rapi.Enabled, "inter-cluster-instance-move"])
and instance.disk_template != constants.DT_FILE):
and (instance.disk_template not in
[constants.DT_FILE, constants.DT_SHARED_FILE])):
newinst = qa_config.AcquireInstance()
try:
tnode = qa_config.AcquireNode(exclude=inodes)
......@@ -804,7 +805,8 @@ def RunQa():
if qa_rapi.Enabled():
RunTest(qa_rapi.TestNode, pnode)
if qa_config.TestEnabled("instance-add-plain-disk"):
if (qa_config.TestEnabled("instance-add-plain-disk")
and qa_config.IsTemplateSupported(constants.DT_PLAIN)):
for use_client in [True, False]:
rapi_instance = RunTest(qa_rapi.TestRapiInstanceAdd, pnode,
use_client)
......
......@@ -407,6 +407,9 @@ def TestDelay(node):
def TestClusterReservedLvs():
"""gnt-cluster reserved lvs"""
# if no lvm-based templates are supported, skip the test
if not qa_config.IsStorageTypeSupported(constants.ST_LVM_VG):
return
vgname = qa_config.get("vg-name", constants.DEFAULT_VG)
lvname = _QA_LV_PREFIX + "test"
lvfullname = "/".join([vgname, lvname])
......
......@@ -435,6 +435,20 @@ class _QaConfig(object):
return enabled and (not self.GetExclusiveStorage() or
templ in constants.DTS_EXCL_STORAGE)
def IsStorageTypeSupported(self, storage_type):
"""Is the given storage type supported by the current configuration?
This is determined by looking if at least one of the disk templates
which is associated with the storage type is enabled in the configuration.
"""
enabled_disk_templates = self.GetEnabledDiskTemplates()
if storage_type == constants.ST_LVM_PV:
disk_templates = utils.GetDiskTemplatesOfStorageType(constants.ST_LVM_VG)
else:
disk_templates = utils.GetDiskTemplatesOfStorageType(storage_type)
return bool(set(enabled_disk_templates).intersection(set(disk_templates)))
def AreSpindlesSupported(self):
"""Are spindles supported by the current configuration?
......@@ -673,6 +687,13 @@ def IsTemplateSupported(templ):
return GetConfig().IsTemplateSupported(templ)
def IsStorageTypeSupported(storage_type):
"""Wrapper for L{_QaConfig.IsTemplateSupported}.
"""
return GetConfig().IsStorageTypeSupported(storage_type)
def AreSpindlesSupported():
"""Wrapper for L{_QaConfig.AreSpindlesSupported}.
......
......@@ -225,6 +225,10 @@ def _TestGroupModifyIPolicy(groupname):
def TestGroupModify():
"""gnt-group modify"""
# This tests assumes LVM to be enabled, thus it should skip if
# this is not the case
if not qa_config.IsStorageTypeSupported(constants.ST_LVM_VG):
return
(group1, ) = qa_utils.GetNonexistentGroups(1)
AssertCommand(["gnt-group", "add", group1])
......
......@@ -246,6 +246,11 @@ def TestRapiQuery():
"""Testing resource queries via remote API.
"""
# FIXME: the tests are failing if no LVM is enabled, investigate
# if it is a bug in the QA or in the code
if not qa_config.IsStorageTypeSupported(constants.ST_LVM_VG):
return
master_name = qa_utils.ResolveNodeName(qa_config.GetMasterNode())
rnd = random.Random(7818)
......@@ -323,15 +328,17 @@ def TestRapiQuery():
("/2/query/%s?fields=%s" % (what, namefield),
compat.partial(_Check, [namefield]), "PUT", {}),
# Fields in body
("/2/query/%s" % what, compat.partial(_Check, [namefield] * 4), "PUT", {
"fields": [namefield] * 4,
}),
("/2/query/%s" % what, compat.partial(_Check, all_fields), "PUT", {
"fields": all_fields,
}),
("/2/query/%s" % what, compat.partial(_Check, [namefield] * 4), "PUT", {
"fields": [namefield] * 4,
}),
])
"fields": [namefield] * 4
})])
def _CheckFilter():
_DoTests([
......@@ -562,6 +569,8 @@ def TestRapiNodeGroups():
def TestRapiInstanceAdd(node, use_client):
"""Test adding a new instance via RAPI"""
if not qa_config.IsTemplateSupported(constants.DT_PLAIN):
return
instance = qa_config.AcquireInstance()
instance.SetDiskTemplate(constants.DT_PLAIN)
try:
......@@ -614,6 +623,11 @@ def TestRapiInstanceAdd(node, use_client):
@InstanceCheck(None, INST_DOWN, FIRST_ARG)
def TestRapiInstanceRemove(instance, use_client):
"""Test removing instance via RAPI"""
# FIXME: this does not work if LVM is not enabled. Find out if this is a bug
# in RAPI or in the test
if not qa_config.IsStorageTypeSupported(constants.ST_LVM_VG):
return
if use_client:
job_id = _rapi_client.DeleteInstance(instance.name)
else:
......
......@@ -569,7 +569,8 @@ class MoveSourceExecutor(object):
logging.info("Retrieving instance information from source cluster")
instinfo = self._GetInstanceInfo(src_client, mrt.PollJob,
mrt.move.src_instance_name)
if instinfo["disk_template"] == constants.DT_FILE:
if (instinfo["disk_template"] in
[constants.DT_FILE, constants.DT_SHARED_FILE]):
raise Error("Inter-cluster move of file-based instances is not"
" supported.")
......
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