The rename instance test performs an lvm-specific check for tags on the instance volume. This should be in the future abstracted *inside* the template class, and not explicitly called from qa.
This would allow other disks to perform the checks that make sense for them. In the meantime though, we just make the same check only when the backend storage for the instance is lvm-based. Signed-off-by: Guido Trotter <[email protected]> --- qa/qa_instance.py | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/qa/qa_instance.py b/qa/qa_instance.py index d3b2f25..e6d8d44 100644 --- a/qa/qa_instance.py +++ b/qa/qa_instance.py @@ -105,6 +105,8 @@ def _GetInstanceInfo(instance): - "drbd-minors": DRBD minors used by the instance, a dictionary where keys are nodes, and values are lists of integers (or an empty dictionary for non-DRBD instances) + - "disk-template": instance disk template + - "storage-type": storage type associated with the instance disk template """ node_elem = r"([^,()]+)(?:\s+\([^)]+\))?" @@ -129,6 +131,13 @@ def _GetInstanceInfo(instance): else: nodes.append(nodestr) + disk_template = info["Disk template"] + if not disk_template: + raise qa_error.Error("Can't get instance disk template") + storage_type = constants.DISK_TEMPLATES_STORAGE_TYPE[disk_template] + if not storage_type: + raise qa_error.Error("Can't get storage type for %s" % disk_template) + re_drbdnode = re.compile(r"^([^\s,]+),\s+minor=([0-9]+)$") vols = [] drbd_min = {} @@ -154,6 +163,8 @@ def _GetInstanceInfo(instance): "nodes": nodes, "volumes": vols, "drbd-minors": drbd_min, + "disk-template": disk_template, + "storage-type": storage_type, } @@ -403,11 +414,22 @@ def TestInstanceRenameAndBack(rename_source, rename_target): finally: qa_utils.RemoveFromEtcHosts(["meeeeh-not-exists", rename_target]) - # Check instance volume tags correctly updated - # FIXME: this is LVM specific! info = _GetInstanceInfo(rename_source) - tags_cmd = ("lvs -o tags --noheadings %s | grep " % - (" ".join(info["volumes"]), )) + + # Check instance volume tags correctly updated. Note that this check is lvm + # specific, so we skip it for non-lvm-based instances. + # FIXME: This will need updating when instances will be able to have + # different disks living on storage pools with etherogeneous storage types. + # FIXME: This check should be put inside the disk/storage class themselves, + # rather than explicitly called here. + if info["storage-type"] == constants.ST_LVM_VG: + # In the lvm world we can check for tags on the logical volume + tags_cmd = ("lvs -o tags --noheadings %s | grep " % + (" ".join(info["volumes"]), )) + else: + # Other storage types don't have tags, so we use an always failing command, + # to make sure it never gets executed + tags_cmd = "false" # and now rename instance to rename_target... AssertCommand(["gnt-instance", "rename", rename_source, rename_target]) @@ -417,7 +439,8 @@ def TestInstanceRenameAndBack(rename_source, rename_target): # NOTE: tags might not be the exactly as the instance name, due to # charset restrictions; hence the test might be flaky - if rename_source != rename_target: + if (rename_source != rename_target and + info["storage-type"] == constants.ST_LVM_VG): for node in info["nodes"]: AssertCommand(tags_cmd + rename_source, node=node, fail=True) AssertCommand(tags_cmd + rename_target, node=node, fail=False) @@ -427,7 +450,8 @@ def TestInstanceRenameAndBack(rename_source, rename_target): _CheckSsconfInstanceList(rename_source) qa_utils.RunInstanceCheck(rename_target, False) - if rename_source != rename_target: + if (rename_source != rename_target and + info["storage-type"] == constants.ST_LVM_VG): for node in info["nodes"]: AssertCommand(tags_cmd + rename_source, node=node, fail=False) AssertCommand(tags_cmd + rename_target, node=node, fail=True) -- 1.7.10.4
