Commit 5949c31c authored by Helga Velroyen's avatar Helga Velroyen

QA: Adjust QA for file storage

This improves the QA code wrt to file storage in the
following ways:
- It fixes a FIXME to make the file storage directory
  customizable in the QA config. Fallback is the default
  value.
- It makes QA derive the enabled storage types from
  the enabled disk templates and runs the 'gnt-node
  storage tests' only on the enabled ones.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent d721894a
......@@ -35,6 +35,9 @@
"diskless"
],
"# Default file storage dir (used also for shared storage)": null,
"default-file-storage-dir": "/srv/ganeti/file-storage",
"# Additional arguments for initializing cluster": null,
"cluster-init-args": [],
......
......@@ -178,7 +178,9 @@ def TestClusterInit(rapi_user, rapi_secret):
"--primary-ip-version=%d" % qa_config.get("primary_ip_version", 4),
"--enabled-hypervisors=%s" % ",".join(qa_config.GetEnabledHypervisors()),
"--enabled-disk-templates=%s" %
",".join(qa_config.GetEnabledDiskTemplates())
",".join(qa_config.GetEnabledDiskTemplates()),
"--file-storage-dir=%s" %
qa_config.get("file-storage-dir", pathutils.DEFAULT_FILE_STORAGE_DIR),
]
for spec_type in ("mem-size", "disk-size", "disk-count", "cpu-count",
......
......@@ -372,6 +372,22 @@ class _QaConfig(object):
_ENABLED_DISK_TEMPLATES_KEY,
constants.DEFAULT_ENABLED_DISK_TEMPLATES)
def GetEnabledStorageTypes(self):
"""Returns the list of enabled storage types.
@rtype: list
@returns: the list of storage types enabled for QA
"""
enabled_disk_templates = self.GetEnabledDiskTemplates()
enabled_storage_types = list(set([constants.DISK_TEMPLATES_STORAGE_TYPE[dt]
for dt in enabled_disk_templates]))
# Storage type 'lvm-pv' cannot be activated via a disk template,
# therefore we add it if 'lvm-vg' is present.
if constants.ST_LVM_VG in enabled_storage_types:
enabled_storage_types.append(constants.ST_LVM_PV)
return enabled_storage_types
def GetDefaultDiskTemplate(self):
"""Returns the default disk template to be used.
......@@ -593,6 +609,13 @@ def GetEnabledDiskTemplates(*args):
return GetConfig().GetEnabledDiskTemplates(*args)
def GetEnabledStorageTypes(*args):
"""Wrapper for L{_QaConfig.GetEnabledStorageTypes}.
"""
return GetConfig().GetEnabledStorageTypes(*args)
def GetDefaultDiskTemplate(*args):
"""Wrapper for L{_QaConfig.GetDefaultDiskTemplate}.
......
......@@ -136,10 +136,10 @@ def _DestroyInstanceDisks(instance):
for node in info["nodes"]:
AssertCommand(["lvremove", "-f"] + vols, node=node)
elif info["storage-type"] == constants.ST_FILE:
# FIXME: file storage dir not configurable in qa
# Note that this works for both file and sharedfile, and this is intended.
filestorage = pathutils.DEFAULT_FILE_STORAGE_DIR
idir = os.path.join(filestorage, instance.name)
storage_dir = qa_config.get("file-storage-dir",
pathutils.DEFAULT_FILE_STORAGE_DIR)
idir = os.path.join(storage_dir, instance.name)
for node in info["nodes"]:
AssertCommand(["rm", "-rf", idir], node=node)
elif info["storage-type"] == constants.ST_DISKLESS:
......@@ -558,9 +558,8 @@ def TestInstanceModifyPrimaryAndBack(instance, currentnode, othernode):
current = currentnode.primary
other = othernode.primary
# FIXME: the qa doesn't have a customizable file storage dir parameter. As
# such for now we use the default.
filestorage = pathutils.DEFAULT_FILE_STORAGE_DIR
filestorage = qa_config.get("file-storage-dir",
pathutils.DEFAULT_FILE_STORAGE_DIR)
disk = os.path.join(filestorage, name)
AssertCommand(["gnt-instance", "modify", "--new-primary=%s" % other, name],
......@@ -997,7 +996,8 @@ def TestRemoveInstanceOfflineNode(instance, snode, set_offline, set_online):
AssertCommand(drbd_shutdown_cmd, node=snode)
AssertCommand(["lvremove", "-f"] + info["volumes"], node=snode)
elif info["storage-type"] == constants.ST_FILE:
filestorage = pathutils.DEFAULT_FILE_STORAGE_DIR
filestorage = qa_config.get("file-storage-dir",
pathutils.DEFAULT_FILE_STORAGE_DIR)
disk = os.path.join(filestorage, instance.name)
AssertCommand(["rm", "-rf", disk], node=snode)
......
......@@ -113,23 +113,16 @@ def TestNodeVolumes():
def TestNodeStorage():
"""gnt-node storage"""
master = qa_config.GetMasterNode()
enabled_disk_templates = qa_config.GetEnabledDiskTemplates()
# FIXME: test all storage_types in constants.VALID_STORAGE_TYPES
# as soon as they are implemented.
for storage_type in [constants.ST_FILE, constants.ST_LVM_VG,
constants.ST_LVM_PV]:
enabled_storage_types = qa_config.GetEnabledStorageTypes()
testable_storage_types = list(set(enabled_storage_types).intersection(
set([constants.ST_FILE, constants.ST_LVM_VG, constants.ST_LVM_PV])))
cmd = ["gnt-node", "list-storage", "--storage-type", storage_type]
for storage_type in testable_storage_types:
# Skip file storage if not enabled, otherwise QA will fail; we
# just test for basic failure, but otherwise skip the rest of the
# tests
if storage_type == constants.ST_FILE and not \
((constants.DT_FILE in enabled_disk_templates) or
(constants.DT_SHARED_FILE in enabled_disk_templates)):
AssertCommand(cmd, fail=True)
continue
cmd = ["gnt-node", "list-storage", "--storage-type", storage_type]
# Test simple list
AssertCommand(cmd)
......
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