Revision 830da270 qa/qa_cluster.py

b/qa/qa_cluster.py
31 31
from qa_utils import AssertEqual, StartSSH
32 32

  
33 33

  
34
def _RemoveFileFromAllNodes(filename):
35
  """Removes a file from all nodes.
36

  
37
  """
38
  for node in qa_config.get('nodes'):
39
    cmd = ['rm', '-f', filename]
40
    AssertEqual(StartSSH(node['primary'],
41
                         utils.ShellQuoteArgs(cmd)).wait(), 0)
42

  
43

  
44
def _CheckFileOnAllNodes(filename, content):
45
  """Verifies the content of the given file on all nodes.
46

  
47
  """
48
  cmd = utils.ShellQuoteArgs(["cat", filename])
49
  for node in qa_config.get('nodes'):
50
    AssertEqual(qa_utils.GetCommandOutput(node['primary'], cmd),
51
                content)
52

  
53

  
34 54
def TestClusterInit():
35 55
  """gnt-cluster init"""
36 56
  master = qa_config.GetMasterNode()
......
144 164
  """gnt-cluster copyfile"""
145 165
  master = qa_config.GetMasterNode()
146 166

  
167
  uniqueid = utils.GetUUID()
168

  
147 169
  # Create temporary file
148 170
  f = tempfile.NamedTemporaryFile()
149
  f.write("I'm a testfile.\n")
171
  f.write(uniqueid)
150 172
  f.flush()
151 173
  f.seek(0)
152 174

  
......
157 179
    cmd = ['gnt-cluster', 'copyfile', testname]
158 180
    AssertEqual(StartSSH(master['primary'],
159 181
                         utils.ShellQuoteArgs(cmd)).wait(), 0)
182
    _CheckFileOnAllNodes(testname, uniqueid)
160 183
  finally:
161
    # Remove file from all nodes
162
    for node in qa_config.get('nodes'):
163
      cmd = ['rm', '-f', testname]
164
      AssertEqual(StartSSH(node['primary'],
165
                           utils.ShellQuoteArgs(cmd)).wait(), 0)
184
    _RemoveFileFromAllNodes(testname)
185

  
186

  
187
def TestClusterCommand():
188
  """gnt-cluster command"""
189
  master = qa_config.GetMasterNode()
190

  
191
  uniqueid = utils.GetUUID()
192
  rfile = "/tmp/gnt%s" % utils.GetUUID()
193
  rcmd = utils.ShellQuoteArgs(['echo', '-n', uniqueid])
194
  cmd = utils.ShellQuoteArgs(['gnt-cluster', 'command',
195
                              "%s >%s" % (rcmd, rfile)])
196

  
197
  try:
198
    AssertEqual(StartSSH(master['primary'], cmd).wait(), 0)
199
    _CheckFileOnAllNodes(rfile, uniqueid)
200
  finally:
201
    _RemoveFileFromAllNodes(rfile)
166 202

  
167 203

  
168 204
def TestClusterDestroy():

Also available in: Unified diff