Unlike almost all other modification commands, hotplugging a device and
failing does not result in an error code showing that the operation was
unsuccessful. Because of this, the QA ignored hotplugging failures. To
fix this, this patch makes the QA examine the output of the command for
signs of failure.

Signed-off-by: Hrvoje Ribicic <[email protected]>
---
 qa/qa_instance.py | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/qa/qa_instance.py b/qa/qa_instance.py
index fbb63cb..b924d20 100644
--- a/qa/qa_instance.py
+++ b/qa/qa_instance.py
@@ -500,6 +500,25 @@ def TestInstanceInfo(instance):
   AssertCommand(["gnt-instance", "info", instance.name])
 
 
+def _TestKVMHotplug(instance):
+  """Tests hotplug modification commands, noting that they
+
+  """
+  args_to_try = [
+    ["--net", "-1:add", "--hotplug"],
+    ["--net", "-1:modify,mac=aa:bb:cc:dd:ee:ff", "--hotplug", "--force"],
+    ["--net", "-1:remove", "--hotplug"],
+    ["--disk", "-1:add,size=1G", "--hotplug"],
+    ["--disk", "-1:remove", "--hotplug"],
+  ]
+  for alist in args_to_try:
+    _, stdout, stderr = \
+      AssertCommand(["gnt-instance", "modify"] + alist + [instance.name])
+    if "failed" in stdout or "failed" in stderr:
+      raise qa_error.Error("Hotplugging command failed; please check output"
+                           " for further information")
+
+
 @InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
 def TestInstanceModify(instance):
   """gnt-instance modify"""
@@ -545,13 +564,7 @@ def TestInstanceModify(instance):
       ])
   elif default_hv == constants.HT_KVM and \
     qa_config.TestEnabled("instance-device-hotplug"):
-    args.extend([
-      ["--net", "-1:add", "--hotplug"],
-      ["--net", "-1:modify,mac=aa:bb:cc:dd:ee:ff", "--hotplug", "--force"],
-      ["--net", "-1:remove", "--hotplug"],
-      ["--disk", "-1:add,size=1G", "--hotplug"],
-      ["--disk", "-1:remove", "--hotplug"],
-      ])
+    _TestKVMHotplug(instance)
 
   for alist in args:
     AssertCommand(["gnt-instance", "modify"] + alist + [instance.name])
-- 
2.2.0.rc0.207.ga3a616c

Reply via email to