QA: Extend cluster QA wrt enabled storage types
authorHelga Velroyen <helgav@google.com>
Thu, 14 Mar 2013 14:09:35 +0000 (15:09 +0100)
committerHelga Velroyen <helgav@google.com>
Thu, 21 Mar 2013 15:41:21 +0000 (16:41 +0100)
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: Helga Velroyen <helgav@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

qa/ganeti-qa.py
qa/qa-sample.json
qa/qa_cluster.py
qa/qa_config.py

index 567732c..f653fb5 100755 (executable)
@@ -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),
index d5e5c86..660989c 100644 (file)
@@ -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": [],
index 77d3226..8d4ff49 100644 (file)
@@ -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 [
index cb509f8..25b91ca 100644 (file)
@@ -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
@@ -349,28 +350,50 @@ 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}.