Signed-off-by: Apollon Oikonomopoulos <[email protected]>
---
 test/py/ganeti.hypervisor.hv_kvm_unittest.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/test/py/ganeti.hypervisor.hv_kvm_unittest.py 
b/test/py/ganeti.hypervisor.hv_kvm_unittest.py
index 2fc3c33..bc153ba 100755
--- a/test/py/ganeti.hypervisor.hv_kvm_unittest.py
+++ b/test/py/ganeti.hypervisor.hv_kvm_unittest.py
@@ -39,6 +39,7 @@ from ganeti import pathutils
 
 from ganeti.hypervisor import hv_kvm
 import ganeti.hypervisor.hv_kvm.netdev as netdev
+import ganeti.hypervisor.hv_kvm.monitor as monitor
 
 import testutils
 
@@ -63,6 +64,15 @@ class QmpStub(threading.Thread):
   _EMPTY_RESPONSE = {
     "return": [],
     }
+  _SUPPORTED_COMMANDS = {
+    "return": [
+      {"name": "command"},
+      {"name": "query-kvm"},
+      {"name": "eject"},
+      {"name": "query-status"},
+      {"name": "query-name"},
+    ]
+  }
 
   def __init__(self, socket_filename, server_responses):
     """Creates a QMP stub
@@ -94,6 +104,10 @@ class QmpStub(threading.Thread):
     conn.recv(4096)
     conn.send(self.encode_string(self._EMPTY_RESPONSE))
 
+    # Expect query-commands and return the list of supported commands
+    conn.recv(4096)
+    conn.send(self.encode_string(self._SUPPORTED_COMMANDS))
+
     while True:
       # We ignore the expected message, as the purpose of this object is not
       # to verify the correctness of the communication but to act as a
@@ -199,6 +213,10 @@ class TestQmp(testutils.GanetiTestCase):
                        msg="Got multi-line message")
       self.assertEqual(response, msg)
 
+    self.assertRaises(monitor.QmpCommandNotSupported,
+                      qmp_connection.Execute,
+                      "unsupported-command")
+
 
 class TestConsole(unittest.TestCase):
   def _Test(self, instance, node, group, hvparams):
-- 
1.9.1

Reply via email to