diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py index 306eccb42776cb323f75484c2ab44fdd994c26e4..d87761378639cbf7de717c9e9f6354bc55528eac 100755 --- a/qa/ganeti-qa.py +++ b/qa/ganeti-qa.py @@ -101,6 +101,9 @@ def RunClusterTests(): if qa_config.TestEnabled('cluster-copyfile'): RunTest(qa_cluster.TestClusterCopyfile) + if qa_config.TestEnabled('cluster-command'): + RunTest(qa_cluster.TestClusterCommand) + if qa_config.TestEnabled('cluster-burnin'): RunTest(qa_cluster.TestClusterBurnin) diff --git a/qa/qa-sample.yaml b/qa/qa-sample.yaml index 139952741696446cb313d6b19c256f63c613cf00..fb1cab5818533d8c646bf3104d66d3efa488f5bf 100644 --- a/qa/qa-sample.yaml +++ b/qa/qa-sample.yaml @@ -33,6 +33,7 @@ tests: cluster-getmaster: True cluster-version: True cluster-burnin: True + cluster-command: True cluster-copyfile: True cluster-master-failover: True cluster-destroy: True diff --git a/qa/qa_cluster.py b/qa/qa_cluster.py index 2f21eefdce67f42320760d077d576379da1046fe..2995885dce47e8538be5c777e6a40b3ea7bc6234 100644 --- a/qa/qa_cluster.py +++ b/qa/qa_cluster.py @@ -31,6 +31,26 @@ import qa_error from qa_utils import AssertEqual, StartSSH +def _RemoveFileFromAllNodes(filename): + """Removes a file from all nodes. + + """ + for node in qa_config.get('nodes'): + cmd = ['rm', '-f', filename] + AssertEqual(StartSSH(node['primary'], + utils.ShellQuoteArgs(cmd)).wait(), 0) + + +def _CheckFileOnAllNodes(filename, content): + """Verifies the content of the given file on all nodes. + + """ + cmd = utils.ShellQuoteArgs(["cat", filename]) + for node in qa_config.get('nodes'): + AssertEqual(qa_utils.GetCommandOutput(node['primary'], cmd), + content) + + def TestClusterInit(): """gnt-cluster init""" master = qa_config.GetMasterNode() @@ -144,9 +164,11 @@ def TestClusterCopyfile(): """gnt-cluster copyfile""" master = qa_config.GetMasterNode() + uniqueid = utils.GetUUID() + # Create temporary file f = tempfile.NamedTemporaryFile() - f.write("I'm a testfile.\n") + f.write(uniqueid) f.flush() f.seek(0) @@ -157,12 +179,26 @@ def TestClusterCopyfile(): cmd = ['gnt-cluster', 'copyfile', testname] AssertEqual(StartSSH(master['primary'], utils.ShellQuoteArgs(cmd)).wait(), 0) + _CheckFileOnAllNodes(testname, uniqueid) finally: - # Remove file from all nodes - for node in qa_config.get('nodes'): - cmd = ['rm', '-f', testname] - AssertEqual(StartSSH(node['primary'], - utils.ShellQuoteArgs(cmd)).wait(), 0) + _RemoveFileFromAllNodes(testname) + + +def TestClusterCommand(): + """gnt-cluster command""" + master = qa_config.GetMasterNode() + + uniqueid = utils.GetUUID() + rfile = "/tmp/gnt%s" % utils.GetUUID() + rcmd = utils.ShellQuoteArgs(['echo', '-n', uniqueid]) + cmd = utils.ShellQuoteArgs(['gnt-cluster', 'command', + "%s >%s" % (rcmd, rfile)]) + + try: + AssertEqual(StartSSH(master['primary'], cmd).wait(), 0) + _CheckFileOnAllNodes(rfile, uniqueid) + finally: + _RemoveFileFromAllNodes(rfile) def TestClusterDestroy():