Skip to content
Snippets Groups Projects
Commit 830da270 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Test “gnt-cluster command”.

Also check whether file contents are correct for both “gnt-cluster command” and
“gnt-cluster copyfile”.

Reviewed-by: iustinp
parent 3f78eef2
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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
......
......@@ -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():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment