Commit 5d94ddf6 authored by Apollon Oikonomopoulos's avatar Apollon Oikonomopoulos Committed by Thomas Thrainer
Browse files

QMP: test supported_commands



Add test for supported_commands.
Signed-off-by: default avatarApollon Oikonomopoulos <apoikos@gmail.com>
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent 8926b648
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment