The QA tests the Xen instance status collector, but that is expected to fail
when run on machines that do not use Xen.

Signed-off-by: Michele Tartara <[email protected]>
---
 qa/qa_monitoring.py | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/qa/qa_monitoring.py b/qa/qa_monitoring.py
index d6a2709..97c0c02 100644
--- a/qa/qa_monitoring.py
+++ b/qa/qa_monitoring.py
@@ -24,8 +24,12 @@
 """
 
 from ganeti import _autoconf
+from ganeti import constants
+from ganeti import pathutils
+from ganeti import utils
 
 import qa_config
+import qa_utils
 
 from qa_utils import AssertCommand
 from qa_instance_utils import CreateInstanceByDiskTemplate, \
@@ -33,13 +37,31 @@ from qa_instance_utils import CreateInstanceByDiskTemplate, 
\
 
 MON_COLLECTOR = _autoconf.PKGLIBDIR + "/mon-collector"
 
+def _ReadSsconfHypervisorList():
+  """Reads ssconf_hypervisor_list from the master node.
+
+  """
+  master = qa_config.GetMasterNode()
+
+  ssconf_path = utils.PathJoin(pathutils.DATA_DIR,
+                               "ssconf_%s" % constants.SS_HYPERVISOR_LIST)
+
+  cmd = ["cat", qa_utils.MakeNodePath(master, ssconf_path)]
+
+  return qa_utils.GetCommandOutput(master.primary,
+                                   utils.ShellQuoteArgs(cmd)).splitlines()
 
 def TestInstStatusCollector():
   """Test the Xen instance status collector.
 
   """
+  enabled_hypervisors = _ReadSsconfHypervisorList()
+  is_xen = (constants.HT_XEN_PVM in enabled_hypervisors or
+            constants.HT_XEN_HVM in enabled_hypervisors)
+  fail = not is_xen
+
   # Execute on master on an empty cluster
-  AssertCommand([MON_COLLECTOR, "inst-status-xen"])
+  AssertCommand([MON_COLLECTOR, "inst-status-xen"], fail=fail)
 
   #Execute on cluster with instances
   node1 = qa_config.AcquireNode()
@@ -47,8 +69,8 @@ def TestInstStatusCollector():
   template = qa_config.GetDefaultDiskTemplate()
 
   instance = CreateInstanceByDiskTemplate([node1, node2], template)
-  AssertCommand([MON_COLLECTOR, "inst-status-xen"], node=node1)
-  AssertCommand([MON_COLLECTOR, "inst-status-xen"], node=node2)
+  AssertCommand([MON_COLLECTOR, "inst-status-xen"], node=node1, fail=fail)
+  AssertCommand([MON_COLLECTOR, "inst-status-xen"], node=node2, fail=fail)
   RemoveInstance(instance)
 
   node1.Release()
-- 
1.8.2.1

Reply via email to