From 830da2702a015068a5a635cf6c1cbe2a076be157 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Fri, 2 Nov 2007 15:51:35 +0000 Subject: [PATCH] =?UTF-8?q?Test=20=E2=80=9Cgnt-cluster=20command=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also check whether file contents are correct for both βgnt-cluster commandβ and βgnt-cluster copyfileβ. Reviewed-by: iustinp --- qa/ganeti-qa.py | 3 +++ qa/qa-sample.yaml | 1 + qa/qa_cluster.py | 48 +++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py index 306eccb42..d87761378 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 139952741..fb1cab581 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 2f21eefdc..2995885dc 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(): -- GitLab