Revision fa84c8a4 qa/ganeti-qa.py

b/qa/ganeti-qa.py
499 499
  (_, old_specs) = qa_cluster.TestClusterSetISpecs({})
500 500
  node = qa_config.AcquireNode()
501 501
  try:
502
    # Log of policy changes, list of tuples: (change, policy_violated)
503
    history = []
502 504
    instance = qa_instance.TestInstanceAddWithPlainDisk([node])
503 505
    try:
504 506
      policyerror = [constants.CV_EINSTANCEPOLICY]
......
507 509
        (iminval, imaxval) = qa_instance.GetInstanceSpec(instance["name"], par)
508 510
        # Some specs must be multiple of 4
509 511
        new_spec = _BuildSpecDict(par, imaxval + 4, imaxval + 4, imaxval + 4)
512
        history.append((new_spec, True))
510 513
        qa_cluster.TestClusterSetISpecs(new_spec)
511 514
        qa_cluster.AssertClusterVerify(warnings=policyerror)
512 515
        if iminval > 0:
......
516 519
          else:
517 520
            upper = iminval - 1
518 521
          new_spec = _BuildSpecDict(par, 0, upper, upper)
522
          history.append((new_spec, True))
519 523
          qa_cluster.TestClusterSetISpecs(new_spec)
520 524
          qa_cluster.AssertClusterVerify(warnings=policyerror)
521 525
        qa_cluster.TestClusterSetISpecs(old_specs)
526
        history.append((old_specs, False))
522 527
      qa_instance.TestInstanceRemove(instance)
523 528
    finally:
524 529
      qa_config.ReleaseInstance(instance)
530

  
531
    # Now we replay the same policy changes, and we expect that the instance
532
    # cannot be created for the cases where we had a policy violation above
533
    for (change, failed) in history:
534
      qa_cluster.TestClusterSetISpecs(change)
535
      if failed:
536
        qa_instance.TestInstanceAddWithPlainDisk([node], fail=True)
537
      # Instance creation with no policy violation has been tested already
525 538
  finally:
526 539
    qa_config.ReleaseNode(node)
527 540

  

Also available in: Unified diff