Revision 5fa0375e

b/qa/ganeti-qa.py
354 354
      if qa_config.TestEnabled("instance-import"):
355 355
        newinst = qa_config.AcquireInstance()
356 356
        try:
357
          RunTest(qa_instance.TestInstanceImport, pnode, newinst,
357
          RunTest(qa_instance.TestInstanceImport, newinst, pnode,
358 358
                  expnode, name)
359 359
          RunTest(qa_instance.TestInstanceRemove, newinst)
360 360
        finally:
b/qa/qa_instance.py
35 35
import qa_error
36 36

  
37 37
from qa_utils import AssertIn, AssertCommand, AssertEqual
38
from qa_utils import InstanceCheck, INST_DOWN, INST_UP, FIRST_ARG, RETURN_VALUE
38 39

  
39 40

  
40 41
def _GetDiskStatePath(disk):
......
72 73
    raise
73 74

  
74 75

  
76
@InstanceCheck(None, INST_UP, RETURN_VALUE)
75 77
def TestInstanceAddWithPlainDisk(node):
76 78
  """gnt-instance add -t plain"""
77 79
  return _DiskTest(node["primary"], "plain")
78 80

  
79 81

  
82
@InstanceCheck(None, INST_UP, RETURN_VALUE)
80 83
def TestInstanceAddWithDrbdDisk(node, node2):
81 84
  """gnt-instance add -t drbd"""
82 85
  return _DiskTest("%s:%s" % (node["primary"], node2["primary"]),
83 86
                   "drbd")
84 87

  
85 88

  
89
@InstanceCheck(None, INST_DOWN, FIRST_ARG)
86 90
def TestInstanceRemove(instance):
87 91
  """gnt-instance remove"""
88 92
  AssertCommand(["gnt-instance", "remove", "-f", instance["name"]])
......
90 94
  qa_config.ReleaseInstance(instance)
91 95

  
92 96

  
97
@InstanceCheck(INST_DOWN, INST_UP, FIRST_ARG)
93 98
def TestInstanceStartup(instance):
94 99
  """gnt-instance startup"""
95 100
  AssertCommand(["gnt-instance", "startup", instance["name"]])
96 101

  
97 102

  
103
@InstanceCheck(INST_UP, INST_DOWN, FIRST_ARG)
98 104
def TestInstanceShutdown(instance):
99 105
  """gnt-instance shutdown"""
100 106
  AssertCommand(["gnt-instance", "shutdown", instance["name"]])
101 107

  
102 108

  
109
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
103 110
def TestInstanceReboot(instance):
104 111
  """gnt-instance reboot"""
105 112
  options = qa_config.get("options", {})
......
109 116
    AssertCommand(["gnt-instance", "reboot", "--type=%s" % rtype, name])
110 117

  
111 118
  AssertCommand(["gnt-instance", "shutdown", name])
119
  qa_utils.RunInstanceCheck(instance, False)
112 120
  AssertCommand(["gnt-instance", "reboot", name])
113 121

  
114 122
  master = qa_config.GetMasterNode()
......
118 126
  AssertEqual(result_output.strip(), constants.INSTST_RUNNING)
119 127

  
120 128

  
129
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
121 130
def TestInstanceReinstall(instance):
122 131
  """gnt-instance reinstall"""
123 132
  AssertCommand(["gnt-instance", "reinstall", "-f", instance["name"]])
......
147 156
           _ReadSsconfInstanceList())
148 157

  
149 158

  
159
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
150 160
def TestInstanceRenameAndBack(rename_source, rename_target):
151 161
  """gnt-instance rename
152 162

  
......
155 165

  
156 166
  """
157 167
  _CheckSsconfInstanceList(rename_source)
168

  
158 169
  # first do a rename to a different actual name, expecting it to fail
159 170
  qa_utils.AddToEtcHosts(["meeeeh-not-exists", rename_target])
160 171
  try:
......
163 174
    _CheckSsconfInstanceList(rename_source)
164 175
  finally:
165 176
    qa_utils.RemoveFromEtcHosts(["meeeeh-not-exists", rename_target])
177

  
166 178
  # and now rename instance to rename_target...
167 179
  AssertCommand(["gnt-instance", "rename", rename_source, rename_target])
168 180
  _CheckSsconfInstanceList(rename_target)
181
  qa_utils.RunInstanceCheck(rename_source, False)
182
  qa_utils.RunInstanceCheck(rename_target, True)
183

  
169 184
  # and back
170 185
  AssertCommand(["gnt-instance", "rename", rename_target, rename_source])
171 186
  _CheckSsconfInstanceList(rename_source)
187
  qa_utils.RunInstanceCheck(rename_target, False)
172 188

  
173 189

  
190
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
174 191
def TestInstanceFailover(instance):
175 192
  """gnt-instance failover"""
176 193
  cmd = ["gnt-instance", "failover", "--force", instance["name"]]
194

  
177 195
  # failover ...
178 196
  AssertCommand(cmd)
197
  qa_utils.RunInstanceCheck(instance, True)
198

  
179 199
  # ... and back
180 200
  AssertCommand(cmd)
181 201

  
182 202

  
203
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
183 204
def TestInstanceMigrate(instance):
184 205
  """gnt-instance migrate"""
185 206
  cmd = ["gnt-instance", "migrate", "--force", instance["name"]]
207

  
186 208
  # migrate ...
187 209
  AssertCommand(cmd)
210
  qa_utils.RunInstanceCheck(instance, True)
211

  
188 212
  # ... and back
189 213
  AssertCommand(cmd)
214

  
215
  # TODO: Split into multiple tests
190 216
  AssertCommand(["gnt-instance", "shutdown", instance["name"]])
217
  qa_utils.RunInstanceCheck(instance, False)
191 218
  AssertCommand(cmd, fail=True)
192 219
  AssertCommand(["gnt-instance", "migrate", "--force", "--allow-failover",
193 220
                 instance["name"]])
194 221
  AssertCommand(["gnt-instance", "start", instance["name"]])
195 222
  AssertCommand(cmd)
223
  qa_utils.RunInstanceCheck(instance, True)
224

  
196 225
  AssertCommand(["gnt-instance", "modify", "-B",
197 226
                 ("%s=%s" %
198 227
                  (constants.BE_ALWAYS_FAILOVER, constants.VALUE_TRUE)),
199 228
                 instance["name"]])
229

  
200 230
  AssertCommand(cmd, fail=True)
231
  qa_utils.RunInstanceCheck(instance, True)
201 232
  AssertCommand(["gnt-instance", "migrate", "--force", "--allow-failover",
202 233
                 instance["name"]])
234

  
235
  # TODO: Verify whether the default value is restored here (not hardcoded)
203 236
  AssertCommand(["gnt-instance", "modify", "-B",
204 237
                 ("%s=%s" %
205 238
                  (constants.BE_ALWAYS_FAILOVER, constants.VALUE_FALSE)),
206 239
                 instance["name"]])
240

  
207 241
  AssertCommand(cmd)
242
  qa_utils.RunInstanceCheck(instance, True)
208 243

  
209 244

  
210 245
def TestInstanceInfo(instance):
......
212 247
  AssertCommand(["gnt-instance", "info", instance["name"]])
213 248

  
214 249

  
250
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
215 251
def TestInstanceModify(instance):
216 252
  """gnt-instance modify"""
217 253
  # Assume /sbin/init exists on all systems
......
257 293
    AssertCommand(["gnt-instance", "modify", arg, instance["name"]], fail=True)
258 294

  
259 295

  
296
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
260 297
def TestInstanceStoppedModify(instance):
261 298
  """gnt-instance modify (stopped instance)"""
262 299
  name = instance["name"]
......
271 308
  AssertCommand(["gnt-instance", "modify", "--online", name])
272 309

  
273 310

  
311
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
274 312
def TestInstanceConvertDisk(instance, snode):
275 313
  """gnt-instance modify -t"""
276 314
  name = instance["name"]
......
279 317
                 "-n", snode["primary"], name])
280 318

  
281 319

  
320
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
282 321
def TestInstanceGrowDisk(instance):
283 322
  """gnt-instance grow-disk"""
284 323
  name = instance["name"]
......
311 350
  qa_utils.GenericQueryFieldsTest("gnt-instance", query.INSTANCE_FIELDS.keys())
312 351

  
313 352

  
353
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
314 354
def TestInstanceConsole(instance):
315 355
  """gnt-instance console"""
316 356
  AssertCommand(["gnt-instance", "console", "--show-cmd", instance["name"]])
317 357

  
318 358

  
359
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
319 360
def TestReplaceDisks(instance, pnode, snode, othernode):
320 361
  """gnt-instance replace-disks"""
321 362
  # pylint: disable=W0613
......
344 385
  AssertCommand(["gnt-instance", "start", instance["name"]])
345 386

  
346 387

  
388
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
347 389
def TestInstanceExport(instance, node):
348 390
  """gnt-backup export -n ..."""
349 391
  name = instance["name"]
......
351 393
  return qa_utils.ResolveInstanceName(name)
352 394

  
353 395

  
396
@InstanceCheck(INST_UP, None, FIRST_ARG)
354 397
def TestInstanceExportWithRemove(instance, node):
355 398
  """gnt-backup export --remove-instance"""
356 399
  AssertCommand(["gnt-backup", "export", "-n", node["primary"],
357 400
                 "--remove-instance", instance["name"]])
358 401

  
359 402

  
403
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
360 404
def TestInstanceExportNoTarget(instance):
361 405
  """gnt-backup export (without target node, should fail)"""
362 406
  AssertCommand(["gnt-backup", "export", instance["name"]], fail=True)
363 407

  
364 408

  
365
def TestInstanceImport(node, newinst, expnode, name):
409
@InstanceCheck(None, INST_UP, FIRST_ARG)
410
def TestInstanceImport(newinst, node, expnode, name):
366 411
  """gnt-backup import"""
367 412
  cmd = (["gnt-backup", "import",
368 413
          "--disk-template=plain",
b/qa/qa_rapi.py
44 44
import qa_error
45 45

  
46 46
from qa_utils import (AssertEqual, AssertIn, AssertMatch, StartLocalCommand)
47
from qa_utils import InstanceCheck, INST_DOWN, INST_UP, FIRST_ARG
47 48

  
48 49

  
49 50
_rapi_ca = None
......
349 350
        ])
350 351

  
351 352

  
353
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
352 354
def TestInstance(instance):
353 355
  """Testing getting instance(s) info via remote API.
354 356

  
......
577 579
    raise
578 580

  
579 581

  
582
@InstanceCheck(None, INST_DOWN, FIRST_ARG)
580 583
def TestRapiInstanceRemove(instance, use_client):
581 584
  """Test removing instance via RAPI"""
582 585
  if use_client:
......
591 594
  qa_config.ReleaseInstance(instance)
592 595

  
593 596

  
597
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
594 598
def TestRapiInstanceMigrate(instance):
595 599
  """Test migrating instance via RAPI"""
596 600
  # Move to secondary node
597 601
  _WaitForRapiJob(_rapi_client.MigrateInstance(instance["name"]))
602
  qa_utils.RunInstanceCheck(instance, True)
598 603
  # And back to previous primary
599 604
  _WaitForRapiJob(_rapi_client.MigrateInstance(instance["name"]))
600 605

  
601 606

  
607
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
602 608
def TestRapiInstanceFailover(instance):
603 609
  """Test failing over instance via RAPI"""
604 610
  # Move to secondary node
605 611
  _WaitForRapiJob(_rapi_client.FailoverInstance(instance["name"]))
612
  qa_utils.RunInstanceCheck(instance, True)
606 613
  # And back to previous primary
607 614
  _WaitForRapiJob(_rapi_client.FailoverInstance(instance["name"]))
608 615

  
609 616

  
617
@InstanceCheck(INST_UP, INST_DOWN, FIRST_ARG)
610 618
def TestRapiInstanceShutdown(instance):
611 619
  """Test stopping an instance via RAPI"""
612 620
  _WaitForRapiJob(_rapi_client.ShutdownInstance(instance["name"]))
613 621

  
614 622

  
623
@InstanceCheck(INST_DOWN, INST_UP, FIRST_ARG)
615 624
def TestRapiInstanceStartup(instance):
616 625
  """Test starting an instance via RAPI"""
617 626
  _WaitForRapiJob(_rapi_client.StartupInstance(instance["name"]))
618 627

  
619 628

  
629
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
620 630
def TestRapiInstanceRenameAndBack(rename_source, rename_target):
621 631
  """Test renaming instance via RAPI
622 632

  
......
625 635

  
626 636
  """
627 637
  _WaitForRapiJob(_rapi_client.RenameInstance(rename_source, rename_target))
638
  qa_utils.RunInstanceCheck(rename_source, False)
639
  qa_utils.RunInstanceCheck(rename_target, True)
628 640
  _WaitForRapiJob(_rapi_client.RenameInstance(rename_target, rename_source))
641
  qa_utils.RunInstanceCheck(rename_target, False)
629 642

  
630 643

  
644
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
631 645
def TestRapiInstanceReinstall(instance):
632 646
  """Test reinstalling an instance via RAPI"""
633 647
  _WaitForRapiJob(_rapi_client.ReinstallInstance(instance["name"]))
634 648

  
635 649

  
650
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
636 651
def TestRapiInstanceReplaceDisks(instance):
637 652
  """Test replacing instance disks via RAPI"""
638 653
  _WaitForRapiJob(_rapi_client.ReplaceInstanceDisks(instance["name"],
......
641 656
    mode=constants.REPLACE_DISK_SEC, disks="0"))
642 657

  
643 658

  
659
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
644 660
def TestRapiInstanceModify(instance):
645 661
  """Test modifying instance via RAPI"""
646 662
  def _ModifyInstance(**kwargs):
......
663 679
    })
664 680

  
665 681

  
682
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
666 683
def TestRapiInstanceConsole(instance):
667 684
  """Test getting instance console information via RAPI"""
668 685
  result = _rapi_client.GetInstanceConsole(instance["name"])
......
671 688
  AssertEqual(console.instance, qa_utils.ResolveInstanceName(instance["name"]))
672 689

  
673 690

  
691
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
674 692
def TestRapiStoppedInstanceConsole(instance):
675 693
  """Test getting stopped instance's console information via RAPI"""
676 694
  try:
......
727 745
      si,
728 746
      ]
729 747

  
748
    qa_utils.RunInstanceCheck(di, False)
730 749
    AssertEqual(StartLocalCommand(cmd).wait(), 0)
750
    qa_utils.RunInstanceCheck(si, False)
751
    qa_utils.RunInstanceCheck(di, True)

Also available in: Unified diff