From 0511ce913f35efacf5f7015c73414ae6369e2c4d Mon Sep 17 00:00:00 2001
From: Michele Tartara <mtartara@google.com>
Date: Mon, 13 May 2013 19:10:11 +0100
Subject: [PATCH] Non-Xen support for monitoring QA

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 <mtartara@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 qa/qa_monitoring.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/qa/qa_monitoring.py b/qa/qa_monitoring.py
index d6a270911..0271a0e44 100644
--- a/qa/qa_monitoring.py
+++ b/qa/qa_monitoring.py
@@ -24,8 +24,10 @@
 """
 
 from ganeti import _autoconf
+from ganeti import constants
 
 import qa_config
+import qa_utils
 
 from qa_utils import AssertCommand
 from qa_instance_utils import CreateInstanceByDiskTemplate, \
@@ -38,8 +40,13 @@ def TestInstStatusCollector():
   """Test the Xen instance status collector.
 
   """
+  enabled_hypervisors = qa_config.GetEnabledHypervisors()
+  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 +54,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()
-- 
GitLab