backend: Check for shared storage also
[ganeti-local] / qa / qa_cluster.py
index ac576d5..e1ccf7a 100644 (file)
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2007, 2010, 2011 Google Inc.
+# Copyright (C) 2007, 2010, 2011, 2012 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,6 +29,7 @@ import os.path
 from ganeti import constants
 from ganeti import compat
 from ganeti import utils
+from ganeti import pathutils
 
 import qa_config
 import qa_utils
@@ -58,11 +59,25 @@ def _CheckFileOnAllNodes(filename, content):
     AssertEqual(qa_utils.GetCommandOutput(node["primary"], cmd), content)
 
 
+# data for testing failures due to bad keys/values for disk parameters
+_FAIL_PARAMS = ["nonexistent:resync-rate=1",
+                "drbd:nonexistent=1",
+                "drbd:resync-rate=invalid",
+                ]
+
+
+def TestClusterInitDisk():
+  """gnt-cluster init -D"""
+  name = qa_config.get("name")
+  for param in _FAIL_PARAMS:
+    AssertCommand(["gnt-cluster", "init", "-D", param, name], fail=True)
+
+
 def TestClusterInit(rapi_user, rapi_secret):
   """gnt-cluster init"""
   master = qa_config.GetMasterNode()
 
-  rapi_dir = os.path.dirname(constants.RAPI_USERS_FILE)
+  rapi_dir = os.path.dirname(pathutils.RAPI_USERS_FILE)
 
   # First create the RAPI credentials
   fh = tempfile.NamedTemporaryFile()
@@ -73,17 +88,26 @@ def TestClusterInit(rapi_user, rapi_secret):
     tmpru = qa_utils.UploadFile(master["primary"], fh.name)
     try:
       AssertCommand(["mkdir", "-p", rapi_dir])
-      AssertCommand(["mv", tmpru, constants.RAPI_USERS_FILE])
+      AssertCommand(["mv", tmpru, pathutils.RAPI_USERS_FILE])
     finally:
       AssertCommand(["rm", "-f", tmpru])
   finally:
     fh.close()
 
   # Initialize cluster
-  cmd = ["gnt-cluster", "init"]
+  cmd = [
+    "gnt-cluster", "init",
+    "--primary-ip-version=%d" % qa_config.get("primary_ip_version", 4),
+    "--enabled-hypervisors=%s" % ",".join(qa_config.GetEnabledHypervisors()),
+    ]
 
-  cmd.append("--primary-ip-version=%d" %
-             qa_config.get("primary_ip_version", 4))
+  for spec_type in ("mem-size", "disk-size", "disk-count", "cpu-count",
+                    "nic-count"):
+    for spec_val in ("min", "max", "std"):
+      spec = qa_config.get("ispec_%s_%s" %
+                           (spec_type.replace('-', '_'), spec_val), None)
+      if spec:
+        cmd.append("--specs-%s=%s=%d" % (spec_type, spec_val, spec))
 
   if master.get("secondary", None):
     cmd.append("--secondary-ip=%s" % master["secondary"])
@@ -93,15 +117,11 @@ def TestClusterInit(rapi_user, rapi_secret):
     cmd.append("--bridge=%s" % bridge)
     cmd.append("--master-netdev=%s" % bridge)
 
-  htype = qa_config.get("enabled-hypervisors", None)
-  if htype:
-    cmd.append("--enabled-hypervisors=%s" % htype)
-
   cmd.append(qa_config.get("name"))
-
   AssertCommand(cmd)
 
   cmd = ["gnt-cluster", "modify"]
+
   # hypervisor parameter modifications
   hvp = qa_config.get("hypervisor-parameters", {})
   for k, v in hvp.items():
@@ -183,7 +203,7 @@ def TestClusterEpo():
 
   # Assert that OOB is unavailable for all nodes
   result_output = GetCommandOutput(master["primary"],
-                                   "gnt-node list --verbose --no-header -o"
+                                   "gnt-node list --verbose --no-headers -o"
                                    " powered")
   AssertEqual(compat.all(powered == "(unavail)"
                          for powered in result_output.splitlines()), True)
@@ -201,8 +221,9 @@ def TestClusterEpo():
 
   # All instances should have been stopped now
   result_output = GetCommandOutput(master["primary"],
-                                   "gnt-instance list --no-header -o status")
-  AssertEqual(compat.all(status == "ADMIN_down"
+                                   "gnt-instance list --no-headers -o status")
+  # ERROR_down because the instance is stopped but not recorded as such
+  AssertEqual(compat.all(status == "ERROR_down"
                          for status in result_output.splitlines()), True)
 
   # Now start everything again
@@ -210,7 +231,7 @@ def TestClusterEpo():
 
   # All instances should have been started now
   result_output = GetCommandOutput(master["primary"],
-                                   "gnt-instance list --no-header -o status")
+                                   "gnt-instance list --no-headers -o status")
   AssertEqual(compat.all(status == "running"
                          for status in result_output.splitlines()), True)
 
@@ -254,6 +275,17 @@ def TestClusterReservedLvs():
     AssertCommand(cmd, fail=fail)
 
 
+def TestClusterModifyEmpty():
+  """gnt-cluster modify"""
+  AssertCommand(["gnt-cluster", "modify"], fail=True)
+
+
+def TestClusterModifyDisk():
+  """gnt-cluster modify -D"""
+  for param in _FAIL_PARAMS:
+    AssertCommand(["gnt-cluster", "modify", "-D", param], fail=True)
+
+
 def TestClusterModifyBe():
   """gnt-cluster modify -B"""
   for fail, cmd in [
@@ -330,7 +362,7 @@ def TestClusterRenewCrypto():
   AssertCommand(cmd, fail=True)
 
   rapi_cert_backup = qa_utils.BackupFile(master["primary"],
-                                         constants.RAPI_CERT_FILE)
+                                         pathutils.RAPI_CERT_FILE)
   try:
     # Custom RAPI certificate
     fh = tempfile.NamedTemporaryFile()
@@ -402,6 +434,8 @@ def TestClusterBurnin():
       # Run burnin
       cmd = [script,
              "--os=%s" % qa_config.get("os"),
+             "--minmem-size=%s" % qa_config.get(constants.BE_MINMEM),
+             "--maxmem-size=%s" % qa_config.get(constants.BE_MAXMEM),
              "--disk-size=%s" % ",".join(qa_config.get("disk")),
              "--disk-growth=%s" % ",".join(qa_config.get("disk-growth")),
              "--disk-template=%s" % disk_template]
@@ -442,7 +476,7 @@ def TestClusterMasterFailover():
 
 def TestClusterMasterFailoverWithDrainedQueue():
   """gnt-cluster master-failover with drained queue"""
-  drain_check = ["test", "-f", constants.JOB_QUEUE_DRAIN_FILE]
+  drain_check = ["test", "-f", pathutils.JOB_QUEUE_DRAIN_FILE]
 
   master = qa_config.GetMasterNode()
   failovermaster = qa_config.AcquireNode(exclude=master)
@@ -452,7 +486,7 @@ def TestClusterMasterFailoverWithDrainedQueue():
     AssertCommand(drain_check, node=node, fail=True)
 
   # Drain queue on failover master
-  AssertCommand(["touch", constants.JOB_QUEUE_DRAIN_FILE], node=failovermaster)
+  AssertCommand(["touch", pathutils.JOB_QUEUE_DRAIN_FILE], node=failovermaster)
 
   cmd = ["gnt-cluster", "master-failover"]
   try: