Statistics
| Branch: | Tag: | Revision:

root / qa / ganeti-qa.py @ 66787da5

History | View | Annotate | Download (13 kB)

1 f89d59b9 Iustin Pop
#!/usr/bin/python -u
2 a8083063 Iustin Pop
#
3 a8083063 Iustin Pop
4 e1df06f2 Iustin Pop
# Copyright (C) 2007, 2008, 2009, 2010 Google Inc.
5 a8083063 Iustin Pop
#
6 a8083063 Iustin Pop
# This program is free software; you can redistribute it and/or modify
7 a8083063 Iustin Pop
# it under the terms of the GNU General Public License as published by
8 a8083063 Iustin Pop
# the Free Software Foundation; either version 2 of the License, or
9 a8083063 Iustin Pop
# (at your option) any later version.
10 a8083063 Iustin Pop
#
11 a8083063 Iustin Pop
# This program is distributed in the hope that it will be useful, but
12 a8083063 Iustin Pop
# WITHOUT ANY WARRANTY; without even the implied warranty of
13 a8083063 Iustin Pop
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 a8083063 Iustin Pop
# General Public License for more details.
15 a8083063 Iustin Pop
#
16 a8083063 Iustin Pop
# You should have received a copy of the GNU General Public License
17 a8083063 Iustin Pop
# along with this program; if not, write to the Free Software
18 a8083063 Iustin Pop
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 a8083063 Iustin Pop
# 02110-1301, USA.
20 a8083063 Iustin Pop
21 a8083063 Iustin Pop
22 cec9845c Michael Hanselmann
"""Script for doing QA on Ganeti.
23 94508060 Michael Hanselmann

24 94508060 Michael Hanselmann
"""
25 a8083063 Iustin Pop
26 a8083063 Iustin Pop
import sys
27 c68d1f43 Michael Hanselmann
import datetime
28 c68d1f43 Michael Hanselmann
import optparse
29 a8083063 Iustin Pop
30 cec9845c Michael Hanselmann
import qa_cluster
31 cec9845c Michael Hanselmann
import qa_config
32 cec9845c Michael Hanselmann
import qa_daemon
33 cec9845c Michael Hanselmann
import qa_env
34 30131294 Adeodato Simo
import qa_group
35 cec9845c Michael Hanselmann
import qa_instance
36 cec9845c Michael Hanselmann
import qa_node
37 8947cf2b Michael Hanselmann
import qa_os
38 a47f574c Oleksiy Mishchenko
import qa_rapi
39 d74c2ca1 Michael Hanselmann
import qa_tags
40 1672a0d1 Michael Hanselmann
import qa_utils
41 a8083063 Iustin Pop
42 725ec2f1 René Nussbaumer
from ganeti import utils
43 2a7c3583 Michael Hanselmann
from ganeti import rapi
44 2a7c3583 Michael Hanselmann
45 2a7c3583 Michael Hanselmann
import ganeti.rapi.client
46 725ec2f1 René Nussbaumer
47 a8083063 Iustin Pop
48 7d88f255 Iustin Pop
def _FormatHeader(line, end=72):
49 f89d59b9 Iustin Pop
  """Fill a line up to the end column.
50 f89d59b9 Iustin Pop

51 f89d59b9 Iustin Pop
  """
52 f89d59b9 Iustin Pop
  line = "---- " + line + " "
53 f89d59b9 Iustin Pop
  line += "-" * (end-len(line))
54 f89d59b9 Iustin Pop
  line = line.rstrip()
55 f89d59b9 Iustin Pop
  return line
56 f89d59b9 Iustin Pop
57 f89d59b9 Iustin Pop
58 7d88f255 Iustin Pop
def _DescriptionOf(fn):
59 7d88f255 Iustin Pop
  """Computes the description of an item.
60 a8083063 Iustin Pop

61 a8083063 Iustin Pop
  """
62 cec9845c Michael Hanselmann
  if fn.__doc__:
63 cec9845c Michael Hanselmann
    desc = fn.__doc__.splitlines()[0].strip()
64 a8083063 Iustin Pop
  else:
65 f89d59b9 Iustin Pop
    desc = "%r" % fn
66 a8083063 Iustin Pop
67 7d88f255 Iustin Pop
  return desc.rstrip(".")
68 7d88f255 Iustin Pop
69 7d88f255 Iustin Pop
def RunTest(fn, *args):
70 7d88f255 Iustin Pop
  """Runs a test after printing a header.
71 7d88f255 Iustin Pop

72 7d88f255 Iustin Pop
  """
73 a8083063 Iustin Pop
74 f89d59b9 Iustin Pop
  tstart = datetime.datetime.now()
75 a8083063 Iustin Pop
76 7d88f255 Iustin Pop
  desc = _DescriptionOf(fn)
77 7d88f255 Iustin Pop
78 f89d59b9 Iustin Pop
  print
79 f89d59b9 Iustin Pop
  print _FormatHeader("%s start %s" % (tstart, desc))
80 f89d59b9 Iustin Pop
81 f89d59b9 Iustin Pop
  try:
82 f89d59b9 Iustin Pop
    retval = fn(*args)
83 f89d59b9 Iustin Pop
    return retval
84 f89d59b9 Iustin Pop
  finally:
85 f89d59b9 Iustin Pop
    tstop = datetime.datetime.now()
86 f89d59b9 Iustin Pop
    tdelta = tstop - tstart
87 f89d59b9 Iustin Pop
    print _FormatHeader("%s time=%s %s" % (tstop, tdelta, desc))
88 a8083063 Iustin Pop
89 a8083063 Iustin Pop
90 7d88f255 Iustin Pop
def RunTestIf(testnames, fn, *args):
91 7d88f255 Iustin Pop
  """Runs a test conditionally.
92 7d88f255 Iustin Pop

93 7d88f255 Iustin Pop
  @param testnames: either a single test name in the configuration
94 7d88f255 Iustin Pop
      file, or a list of testnames (which will be AND-ed together)
95 7d88f255 Iustin Pop

96 7d88f255 Iustin Pop
  """
97 7d88f255 Iustin Pop
  if qa_config.TestEnabled(testnames):
98 7d88f255 Iustin Pop
    RunTest(fn, *args)
99 7d88f255 Iustin Pop
  else:
100 7d88f255 Iustin Pop
    tstart = datetime.datetime.now()
101 7d88f255 Iustin Pop
    desc = _DescriptionOf(fn)
102 7d88f255 Iustin Pop
    print _FormatHeader("%s skipping %s, test(s) %s disabled" %
103 7d88f255 Iustin Pop
                        (tstart, desc, testnames))
104 7d88f255 Iustin Pop
105 7d88f255 Iustin Pop
106 b1ffe1eb Michael Hanselmann
def RunEnvTests():
107 b1ffe1eb Michael Hanselmann
  """Run several environment tests.
108 a8083063 Iustin Pop

109 a8083063 Iustin Pop
  """
110 7d88f255 Iustin Pop
  RunTestIf("env", qa_env.TestSshConnection)
111 7d88f255 Iustin Pop
  RunTestIf("env", qa_env.TestIcmpPing)
112 7d88f255 Iustin Pop
  RunTestIf("env", qa_env.TestGanetiCommands)
113 a8083063 Iustin Pop
114 94508060 Michael Hanselmann
115 725ec2f1 René Nussbaumer
def SetupCluster(rapi_user, rapi_secret):
116 b1ffe1eb Michael Hanselmann
  """Initializes the cluster.
117 a8083063 Iustin Pop

118 725ec2f1 René Nussbaumer
  @param rapi_user: Login user for RAPI
119 725ec2f1 René Nussbaumer
  @param rapi_secret: Login secret for RAPI
120 725ec2f1 René Nussbaumer

121 b1ffe1eb Michael Hanselmann
  """
122 7d88f255 Iustin Pop
  RunTestIf("create-cluster", qa_cluster.TestClusterInit,
123 7d88f255 Iustin Pop
            rapi_user, rapi_secret)
124 7d88f255 Iustin Pop
  RunTestIf("create-cluster", qa_node.TestNodeAddAll)
125 7d88f255 Iustin Pop
  if not qa_config.TestEnabled("create-cluster"):
126 8e671b7c Iustin Pop
    # consider the nodes are already there
127 8e671b7c Iustin Pop
    qa_node.MarkNodeAddedAll()
128 8201b996 Iustin Pop
129 7d88f255 Iustin Pop
  RunTestIf("test-jobqueue", qa_cluster.TestJobqueue)
130 cd04f8c2 Michael Hanselmann
131 8201b996 Iustin Pop
  # enable the watcher (unconditionally)
132 8201b996 Iustin Pop
  RunTest(qa_daemon.TestResumeWatcher)
133 8201b996 Iustin Pop
134 7d88f255 Iustin Pop
  RunTestIf("node-info", qa_node.TestNodeInfo)
135 b1ffe1eb Michael Hanselmann
136 b1ffe1eb Michael Hanselmann
137 b1ffe1eb Michael Hanselmann
def RunClusterTests():
138 b1ffe1eb Michael Hanselmann
  """Runs tests related to gnt-cluster.
139 180bdd1f Michael Hanselmann

140 b1ffe1eb Michael Hanselmann
  """
141 7d88f255 Iustin Pop
  for test, fn in [
142 7d88f255 Iustin Pop
    ("cluster-renew-crypto", qa_cluster.TestClusterRenewCrypto),
143 7d88f255 Iustin Pop
    ("cluster-verify", qa_cluster.TestClusterVerify),
144 7d88f255 Iustin Pop
    ("cluster-reserved-lvs", qa_cluster.TestClusterReservedLvs),
145 9738ca94 Iustin Pop
    # TODO: add more cluster modify tests
146 7d88f255 Iustin Pop
    ("cluster-modify", qa_cluster.TestClusterModifyBe),
147 7d88f255 Iustin Pop
    ("cluster-rename", qa_cluster.TestClusterRename),
148 7d88f255 Iustin Pop
    ("cluster-info", qa_cluster.TestClusterVersion),
149 7d88f255 Iustin Pop
    ("cluster-info", qa_cluster.TestClusterInfo),
150 7d88f255 Iustin Pop
    ("cluster-info", qa_cluster.TestClusterGetmaster),
151 7d88f255 Iustin Pop
    ("cluster-copyfile", qa_cluster.TestClusterCopyfile),
152 7d88f255 Iustin Pop
    ("cluster-command", qa_cluster.TestClusterCommand),
153 7d88f255 Iustin Pop
    ("cluster-burnin", qa_cluster.TestClusterBurnin),
154 7d88f255 Iustin Pop
    ("cluster-master-failover", qa_cluster.TestClusterMasterFailover),
155 7d88f255 Iustin Pop
    ("rapi", qa_rapi.TestVersion),
156 7d88f255 Iustin Pop
    ("rapi", qa_rapi.TestEmptyCluster),
157 7d88f255 Iustin Pop
    ]:
158 7d88f255 Iustin Pop
    RunTestIf(test, fn)
159 8947cf2b Michael Hanselmann
160 6d4a1656 Michael Hanselmann
161 b1ffe1eb Michael Hanselmann
def RunOsTests():
162 b1ffe1eb Michael Hanselmann
  """Runs all tests related to gnt-os.
163 5d640672 Michael Hanselmann

164 b1ffe1eb Michael Hanselmann
  """
165 7d88f255 Iustin Pop
  for fn in [
166 7d88f255 Iustin Pop
    qa_os.TestOsList,
167 7d88f255 Iustin Pop
    qa_os.TestOsDiagnose,
168 7d88f255 Iustin Pop
    qa_os.TestOsValid,
169 7d88f255 Iustin Pop
    qa_os.TestOsInvalid,
170 7d88f255 Iustin Pop
    qa_os.TestOsPartiallyValid,
171 7d88f255 Iustin Pop
    qa_os.TestOsModifyValid,
172 7d88f255 Iustin Pop
    qa_os.TestOsModifyInvalid,
173 7d88f255 Iustin Pop
    qa_os.TestOsStates,
174 7d88f255 Iustin Pop
    ]:
175 7d88f255 Iustin Pop
    RunTestIf("os", fn)
176 b1ffe1eb Michael Hanselmann
177 b1ffe1eb Michael Hanselmann
178 b1ffe1eb Michael Hanselmann
def RunCommonInstanceTests(instance):
179 b1ffe1eb Michael Hanselmann
  """Runs a few tests that are common to all disk types.
180 b1ffe1eb Michael Hanselmann

181 b1ffe1eb Michael Hanselmann
  """
182 7d88f255 Iustin Pop
  RunTestIf("instance-shutdown", qa_instance.TestInstanceShutdown, instance)
183 7d88f255 Iustin Pop
  RunTestIf("instance-shutdown", qa_instance.TestInstanceStartup, instance)
184 a8083063 Iustin Pop
185 7d88f255 Iustin Pop
  RunTestIf("instance-list", qa_instance.TestInstanceList)
186 283f9d4c Michael Hanselmann
187 7d88f255 Iustin Pop
  RunTestIf("instance-info", qa_instance.TestInstanceInfo, instance)
188 e9e35aaa Michael Hanselmann
189 7d88f255 Iustin Pop
  RunTestIf("instance-modify", qa_instance.TestInstanceModify, instance)
190 7d88f255 Iustin Pop
  RunTestIf(["instance-modify", "rapi"],
191 7d88f255 Iustin Pop
            qa_rapi.TestRapiInstanceModify, instance)
192 c0f74c55 Iustin Pop
193 7d88f255 Iustin Pop
  RunTestIf("instance-console", qa_instance.TestInstanceConsole, instance)
194 4379b1fa Michael Hanselmann
195 7d88f255 Iustin Pop
  RunTestIf("instance-reinstall", qa_instance.TestInstanceShutdown, instance)
196 7d88f255 Iustin Pop
  RunTestIf("instance-reinstall", qa_instance.TestInstanceReinstall, instance)
197 7d88f255 Iustin Pop
  RunTestIf("instance-reinstall", qa_instance.TestInstanceStartup, instance)
198 a8083063 Iustin Pop
199 7d88f255 Iustin Pop
  RunTestIf("instance-reboot", qa_instance.TestInstanceReboot, instance)
200 8a4e8898 Michael Hanselmann
201 18337ca9 Iustin Pop
  if qa_config.TestEnabled('instance-rename'):
202 7fb50870 Michael Hanselmann
    rename_target = qa_config.get("rename", None)
203 7fb50870 Michael Hanselmann
    if rename_target is None:
204 7fb50870 Michael Hanselmann
      print qa_utils.FormatError("Can rename instance, 'rename' entry is"
205 7fb50870 Michael Hanselmann
                                 " missing from configuration")
206 7fb50870 Michael Hanselmann
    else:
207 7fb50870 Michael Hanselmann
      RunTest(qa_instance.TestInstanceShutdown, instance)
208 7fb50870 Michael Hanselmann
      RunTest(qa_instance.TestInstanceRename, instance, rename_target)
209 7d88f255 Iustin Pop
      RunTestIf("rapi", qa_rapi.TestRapiInstanceRename, instance, rename_target)
210 7fb50870 Michael Hanselmann
      RunTest(qa_instance.TestInstanceStartup, instance)
211 18337ca9 Iustin Pop
212 7d88f255 Iustin Pop
  RunTestIf("tags", qa_tags.TestInstanceTags, instance)
213 d74c2ca1 Michael Hanselmann
214 7d88f255 Iustin Pop
  RunTestIf("rapi", qa_rapi.TestInstance, instance)
215 729c4377 Iustin Pop
216 729c4377 Iustin Pop
217 729c4377 Iustin Pop
def RunCommonNodeTests():
218 729c4377 Iustin Pop
  """Run a few common node tests.
219 729c4377 Iustin Pop

220 729c4377 Iustin Pop
  """
221 7d88f255 Iustin Pop
  RunTestIf("node-volumes", qa_node.TestNodeVolumes)
222 7d88f255 Iustin Pop
  RunTestIf("node-storage", qa_node.TestNodeStorage)
223 8e1db003 Michael Hanselmann
224 8d8d650c Michael Hanselmann
225 30131294 Adeodato Simo
def RunGroupListTests():
226 30131294 Adeodato Simo
  """Run tests for listing node groups.
227 30131294 Adeodato Simo

228 30131294 Adeodato Simo
  """
229 30131294 Adeodato Simo
  RunTestIf("group-list", qa_group.TestGroupListDefaultFields)
230 30131294 Adeodato Simo
  RunTestIf("group-list", qa_group.TestGroupListAllFields)
231 30131294 Adeodato Simo
232 30131294 Adeodato Simo
233 66787da5 Adeodato Simo
def RunGroupRwTests():
234 66787da5 Adeodato Simo
  """Run tests for adding/removing/renaming groups.
235 66787da5 Adeodato Simo

236 66787da5 Adeodato Simo
  """
237 66787da5 Adeodato Simo
  RunTestIf("group-rwops", qa_group.TestGroupAddRemoveRename)
238 66787da5 Adeodato Simo
239 638a7266 Iustin Pop
def RunExportImportTests(instance, pnode, snode):
240 b1ffe1eb Michael Hanselmann
  """Tries to export and import the instance.
241 a8083063 Iustin Pop

242 638a7266 Iustin Pop
  @param pnode: current primary node of the instance
243 638a7266 Iustin Pop
  @param snode: current secondary node of the instance, if any,
244 638a7266 Iustin Pop
      otherwise None
245 638a7266 Iustin Pop

246 b1ffe1eb Michael Hanselmann
  """
247 b1ffe1eb Michael Hanselmann
  if qa_config.TestEnabled('instance-export'):
248 bc696589 Michael Hanselmann
    RunTest(qa_instance.TestInstanceExportNoTarget, instance)
249 bc696589 Michael Hanselmann
250 b1ffe1eb Michael Hanselmann
    expnode = qa_config.AcquireNode(exclude=pnode)
251 b1ffe1eb Michael Hanselmann
    try:
252 b1ffe1eb Michael Hanselmann
      name = RunTest(qa_instance.TestInstanceExport, instance, expnode)
253 b1ffe1eb Michael Hanselmann
254 b1ffe1eb Michael Hanselmann
      RunTest(qa_instance.TestBackupList, expnode)
255 b1ffe1eb Michael Hanselmann
256 b1ffe1eb Michael Hanselmann
      if qa_config.TestEnabled('instance-import'):
257 b1ffe1eb Michael Hanselmann
        newinst = qa_config.AcquireInstance()
258 5d640672 Michael Hanselmann
        try:
259 b1ffe1eb Michael Hanselmann
          RunTest(qa_instance.TestInstanceImport, pnode, newinst,
260 b1ffe1eb Michael Hanselmann
                  expnode, name)
261 b1ffe1eb Michael Hanselmann
          RunTest(qa_instance.TestInstanceRemove, newinst)
262 5d640672 Michael Hanselmann
        finally:
263 b1ffe1eb Michael Hanselmann
          qa_config.ReleaseInstance(newinst)
264 b1ffe1eb Michael Hanselmann
    finally:
265 b1ffe1eb Michael Hanselmann
      qa_config.ReleaseNode(expnode)
266 5d640672 Michael Hanselmann
267 7d88f255 Iustin Pop
  if qa_config.TestEnabled(["rapi", "inter-cluster-instance-move"]):
268 5d831182 Michael Hanselmann
    newinst = qa_config.AcquireInstance()
269 5d831182 Michael Hanselmann
    try:
270 638a7266 Iustin Pop
      if snode is None:
271 638a7266 Iustin Pop
        excl = [pnode]
272 638a7266 Iustin Pop
      else:
273 638a7266 Iustin Pop
        excl = [pnode, snode]
274 638a7266 Iustin Pop
      tnode = qa_config.AcquireNode(exclude=excl)
275 5d831182 Michael Hanselmann
      try:
276 5d831182 Michael Hanselmann
        RunTest(qa_rapi.TestInterClusterInstanceMove, instance, newinst,
277 638a7266 Iustin Pop
                pnode, snode, tnode)
278 5d831182 Michael Hanselmann
      finally:
279 638a7266 Iustin Pop
        qa_config.ReleaseNode(tnode)
280 5d831182 Michael Hanselmann
    finally:
281 5d831182 Michael Hanselmann
      qa_config.ReleaseInstance(newinst)
282 5d831182 Michael Hanselmann
283 283f9d4c Michael Hanselmann
284 b1ffe1eb Michael Hanselmann
def RunDaemonTests(instance, pnode):
285 b1ffe1eb Michael Hanselmann
  """Test the ganeti-watcher script.
286 9df6d173 Michael Hanselmann

287 b1ffe1eb Michael Hanselmann
  """
288 8201b996 Iustin Pop
  RunTest(qa_daemon.TestPauseWatcher)
289 e9e35aaa Michael Hanselmann
290 7d88f255 Iustin Pop
  RunTestIf("instance-automatic-restart",
291 7d88f255 Iustin Pop
            qa_daemon.TestInstanceAutomaticRestart, pnode, instance)
292 7d88f255 Iustin Pop
  RunTestIf("instance-consecutive-failures",
293 7d88f255 Iustin Pop
            qa_daemon.TestInstanceConsecutiveFailures, pnode, instance)
294 e9e35aaa Michael Hanselmann
295 8201b996 Iustin Pop
  RunTest(qa_daemon.TestResumeWatcher)
296 8201b996 Iustin Pop
297 9df6d173 Michael Hanselmann
298 b1ffe1eb Michael Hanselmann
def RunHardwareFailureTests(instance, pnode, snode):
299 b1ffe1eb Michael Hanselmann
  """Test cluster internal hardware failure recovery.
300 a8083063 Iustin Pop

301 b1ffe1eb Michael Hanselmann
  """
302 7d88f255 Iustin Pop
  RunTestIf("instance-failover", qa_instance.TestInstanceFailover, instance)
303 b1ffe1eb Michael Hanselmann
304 7d88f255 Iustin Pop
  RunTestIf("instance-migrate", qa_instance.TestInstanceMigrate, instance)
305 7d88f255 Iustin Pop
  RunTestIf(["instance-migrate", "rapi"],
306 7d88f255 Iustin Pop
            qa_rapi.TestRapiInstanceMigrate, instance)
307 938bde86 Michael Hanselmann
308 7910e7a5 Michael Hanselmann
  if qa_config.TestEnabled('instance-replace-disks'):
309 76f59a32 Michael Hanselmann
    othernode = qa_config.AcquireNode(exclude=[pnode, snode])
310 7910e7a5 Michael Hanselmann
    try:
311 7910e7a5 Michael Hanselmann
      RunTest(qa_instance.TestReplaceDisks,
312 7910e7a5 Michael Hanselmann
              instance, pnode, snode, othernode)
313 7910e7a5 Michael Hanselmann
    finally:
314 7910e7a5 Michael Hanselmann
      qa_config.ReleaseNode(othernode)
315 7910e7a5 Michael Hanselmann
316 7d88f255 Iustin Pop
  RunTestIf("node-evacuate", qa_node.TestNodeEvacuate, pnode, snode)
317 b1ffe1eb Michael Hanselmann
318 7d88f255 Iustin Pop
  RunTestIf("node-failover", qa_node.TestNodeFailover, pnode, snode)
319 b1ffe1eb Michael Hanselmann
320 7d88f255 Iustin Pop
  RunTestIf("instance-disk-failure", qa_instance.TestInstanceMasterDiskFailure,
321 b1ffe1eb Michael Hanselmann
            instance, pnode, snode)
322 7d88f255 Iustin Pop
  RunTestIf("instance-disk-failure",
323 7d88f255 Iustin Pop
            qa_instance.TestInstanceSecondaryDiskFailure, instance,
324 7d88f255 Iustin Pop
            pnode, snode)
325 b1ffe1eb Michael Hanselmann
326 b1ffe1eb Michael Hanselmann
327 2a7c3583 Michael Hanselmann
@rapi.client.UsesRapiClient
328 b1ffe1eb Michael Hanselmann
def main():
329 b1ffe1eb Michael Hanselmann
  """Main program.
330 b1ffe1eb Michael Hanselmann

331 b1ffe1eb Michael Hanselmann
  """
332 a39ec11a Michael Hanselmann
  parser = optparse.OptionParser(usage="%prog [options] <config-file>")
333 b1ffe1eb Michael Hanselmann
  parser.add_option('--yes-do-it', dest='yes_do_it',
334 b1ffe1eb Michael Hanselmann
      action="store_true",
335 b1ffe1eb Michael Hanselmann
      help="Really execute the tests")
336 b1ffe1eb Michael Hanselmann
  (qa_config.options, args) = parser.parse_args()
337 5d640672 Michael Hanselmann
338 a39ec11a Michael Hanselmann
  if len(args) == 1:
339 a39ec11a Michael Hanselmann
    (config_file, ) = args
340 b1ffe1eb Michael Hanselmann
  else:
341 a39ec11a Michael Hanselmann
    parser.error("Wrong number of arguments.")
342 a8083063 Iustin Pop
343 b1ffe1eb Michael Hanselmann
  if not qa_config.options.yes_do_it:
344 b1ffe1eb Michael Hanselmann
    print ("Executing this script irreversibly destroys any Ganeti\n"
345 b1ffe1eb Michael Hanselmann
           "configuration on all nodes involved. If you really want\n"
346 b1ffe1eb Michael Hanselmann
           "to start testing, supply the --yes-do-it option.")
347 b1ffe1eb Michael Hanselmann
    sys.exit(1)
348 e9e35aaa Michael Hanselmann
349 b1ffe1eb Michael Hanselmann
  qa_config.Load(config_file)
350 a8083063 Iustin Pop
351 725ec2f1 René Nussbaumer
  rapi_user = "ganeti-qa"
352 725ec2f1 René Nussbaumer
  rapi_secret = utils.GenerateSecret()
353 725ec2f1 René Nussbaumer
354 b1ffe1eb Michael Hanselmann
  RunEnvTests()
355 725ec2f1 René Nussbaumer
  SetupCluster(rapi_user, rapi_secret)
356 2771835c Michael Hanselmann
357 2771835c Michael Hanselmann
  # Load RAPI certificate
358 76917d97 Iustin Pop
  qa_rapi.Setup(rapi_user, rapi_secret)
359 2771835c Michael Hanselmann
360 b1ffe1eb Michael Hanselmann
  RunClusterTests()
361 b1ffe1eb Michael Hanselmann
  RunOsTests()
362 4b62db14 Michael Hanselmann
363 7d88f255 Iustin Pop
  RunTestIf("tags", qa_tags.TestClusterTags)
364 d74c2ca1 Michael Hanselmann
365 729c4377 Iustin Pop
  RunCommonNodeTests()
366 30131294 Adeodato Simo
  RunGroupListTests()
367 66787da5 Adeodato Simo
  RunGroupRwTests()
368 729c4377 Iustin Pop
369 d0cb68cb Michael Hanselmann
  pnode = qa_config.AcquireNode(exclude=qa_config.GetMasterNode())
370 d0cb68cb Michael Hanselmann
  try:
371 7d88f255 Iustin Pop
    RunTestIf("node-readd", qa_node.TestNodeReadd, pnode)
372 7d88f255 Iustin Pop
    RunTestIf("node-modify", qa_node.TestNodeModify, pnode)
373 d0cb68cb Michael Hanselmann
  finally:
374 d0cb68cb Michael Hanselmann
    qa_config.ReleaseNode(pnode)
375 102b115b Michael Hanselmann
376 b1ffe1eb Michael Hanselmann
  pnode = qa_config.AcquireNode()
377 b1ffe1eb Michael Hanselmann
  try:
378 7d88f255 Iustin Pop
    RunTestIf("tags", qa_tags.TestNodeTags, pnode)
379 d74c2ca1 Michael Hanselmann
380 a47f574c Oleksiy Mishchenko
    if qa_rapi.Enabled():
381 a47f574c Oleksiy Mishchenko
      RunTest(qa_rapi.TestNode, pnode)
382 a47f574c Oleksiy Mishchenko
383 8cb70e56 Michael Hanselmann
      if qa_config.TestEnabled("instance-add-plain-disk"):
384 924e95f9 Michael Hanselmann
        for use_client in [True, False]:
385 924e95f9 Michael Hanselmann
          rapi_instance = RunTest(qa_rapi.TestRapiInstanceAdd, pnode,
386 924e95f9 Michael Hanselmann
                                  use_client)
387 924e95f9 Michael Hanselmann
          RunCommonInstanceTests(rapi_instance)
388 924e95f9 Michael Hanselmann
          RunTest(qa_rapi.TestRapiInstanceRemove, rapi_instance, use_client)
389 924e95f9 Michael Hanselmann
          del rapi_instance
390 8cb70e56 Michael Hanselmann
391 b1ffe1eb Michael Hanselmann
    if qa_config.TestEnabled('instance-add-plain-disk'):
392 b1ffe1eb Michael Hanselmann
      instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, pnode)
393 b1ffe1eb Michael Hanselmann
      RunCommonInstanceTests(instance)
394 30131294 Adeodato Simo
      RunGroupListTests()
395 638a7266 Iustin Pop
      RunExportImportTests(instance, pnode, None)
396 b1ffe1eb Michael Hanselmann
      RunDaemonTests(instance, pnode)
397 b1ffe1eb Michael Hanselmann
      RunTest(qa_instance.TestInstanceRemove, instance)
398 b1ffe1eb Michael Hanselmann
      del instance
399 9df6d173 Michael Hanselmann
400 7d7609a3 Michael Hanselmann
    multinode_tests = [
401 7d7609a3 Michael Hanselmann
      ('instance-add-drbd-disk',
402 7d7609a3 Michael Hanselmann
       qa_instance.TestInstanceAddWithDrbdDisk),
403 7d7609a3 Michael Hanselmann
    ]
404 7d7609a3 Michael Hanselmann
405 7d7609a3 Michael Hanselmann
    for name, func in multinode_tests:
406 7d7609a3 Michael Hanselmann
      if qa_config.TestEnabled(name):
407 7d7609a3 Michael Hanselmann
        snode = qa_config.AcquireNode(exclude=pnode)
408 7d7609a3 Michael Hanselmann
        try:
409 7d7609a3 Michael Hanselmann
          instance = RunTest(func, pnode, snode)
410 7d88f255 Iustin Pop
          RunTestIf("cluster-verify", qa_cluster.TestClusterVerify)
411 7d7609a3 Michael Hanselmann
          RunCommonInstanceTests(instance)
412 30131294 Adeodato Simo
          RunGroupListTests()
413 7f69aabb Iustin Pop
          if qa_config.TestEnabled('instance-convert-disk'):
414 f9f0ce7f Guido Trotter
            RunTest(qa_instance.TestInstanceShutdown, instance)
415 7f69aabb Iustin Pop
            RunTest(qa_instance.TestInstanceConvertDisk, instance, snode)
416 f9f0ce7f Guido Trotter
            RunTest(qa_instance.TestInstanceStartup, instance)
417 638a7266 Iustin Pop
          RunExportImportTests(instance, pnode, snode)
418 7d7609a3 Michael Hanselmann
          RunHardwareFailureTests(instance, pnode, snode)
419 7d7609a3 Michael Hanselmann
          RunTest(qa_instance.TestInstanceRemove, instance)
420 7d7609a3 Michael Hanselmann
          del instance
421 7d7609a3 Michael Hanselmann
        finally:
422 7d7609a3 Michael Hanselmann
          qa_config.ReleaseNode(snode)
423 a8083063 Iustin Pop
424 7d88f255 Iustin Pop
    if qa_config.TestEnabled(["instance-add-plain-disk", "instance-export"]):
425 3b01286e Michael Hanselmann
      for shutdown in [False, True]:
426 3b01286e Michael Hanselmann
        instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, pnode)
427 3b01286e Michael Hanselmann
        expnode = qa_config.AcquireNode(exclude=pnode)
428 3b01286e Michael Hanselmann
        try:
429 3b01286e Michael Hanselmann
          if shutdown:
430 3b01286e Michael Hanselmann
            # Stop instance before exporting and removing it
431 3b01286e Michael Hanselmann
            RunTest(qa_instance.TestInstanceShutdown, instance)
432 3b01286e Michael Hanselmann
          RunTest(qa_instance.TestInstanceExportWithRemove, instance, expnode)
433 3b01286e Michael Hanselmann
          RunTest(qa_instance.TestBackupList, expnode)
434 3b01286e Michael Hanselmann
        finally:
435 3b01286e Michael Hanselmann
          qa_config.ReleaseNode(expnode)
436 3b01286e Michael Hanselmann
        del expnode
437 3b01286e Michael Hanselmann
        del instance
438 8d8d650c Michael Hanselmann
439 a8083063 Iustin Pop
  finally:
440 b1ffe1eb Michael Hanselmann
    qa_config.ReleaseNode(pnode)
441 a8083063 Iustin Pop
442 7d88f255 Iustin Pop
  RunTestIf("create-cluster", qa_node.TestNodeRemoveAll)
443 a8083063 Iustin Pop
444 7d88f255 Iustin Pop
  RunTestIf("cluster-destroy", qa_cluster.TestClusterDestroy)
445 a8083063 Iustin Pop
446 cec9845c Michael Hanselmann
447 cec9845c Michael Hanselmann
if __name__ == '__main__':
448 cec9845c Michael Hanselmann
  main()