Revision ab4832d1 qa/ganeti-qa.py

b/qa/ganeti-qa.py
484 484
    qa_config.ReleaseNode(node)
485 485

  
486 486

  
487
def _BuildSpecDict(par, mn, st, mx):
488
  return {par: {"min": mn, "std": st, "max": mx}}
489

  
490

  
491
def TestIPolicyPlainInstance():
492
  """Test instance policy interaction with instances"""
493
  params = ["mem-size", "cpu-count", "disk-count", "disk-size", "nic-count"]
494
  if not qa_config.IsTemplateSupported(constants.DT_PLAIN):
495
    print "Template %s not supported" % constants.DT_PLAIN
496
    return
497

  
498
  # This test assumes that the group policy is empty
499
  (_, old_specs) = qa_cluster.TestClusterSetISpecs({})
500
  node = qa_config.AcquireNode()
501
  try:
502
    instance = qa_instance.TestInstanceAddWithPlainDisk([node])
503
    try:
504
      policyerror = [constants.CV_EINSTANCEPOLICY]
505
      for par in params:
506
        qa_cluster.AssertClusterVerify()
507
        (iminval, imaxval) = qa_instance.GetInstanceSpec(instance["name"], par)
508
        # Some specs must be multiple of 4
509
        new_spec = _BuildSpecDict(par, imaxval + 4, imaxval + 4, imaxval + 4)
510
        qa_cluster.TestClusterSetISpecs(new_spec)
511
        qa_cluster.AssertClusterVerify(warnings=policyerror)
512
        if iminval > 0:
513
          # Some specs must be multiple of 4
514
          if iminval >= 4:
515
            upper = iminval - 4
516
          else:
517
            upper = iminval - 1
518
          new_spec = _BuildSpecDict(par, 0, upper, upper)
519
          qa_cluster.TestClusterSetISpecs(new_spec)
520
          qa_cluster.AssertClusterVerify(warnings=policyerror)
521
        qa_cluster.TestClusterSetISpecs(old_specs)
522
      qa_instance.TestInstanceRemove(instance)
523
    finally:
524
      qa_config.ReleaseInstance(instance)
525
  finally:
526
    qa_config.ReleaseNode(node)
527

  
528

  
487 529
def RunInstanceTests():
488 530
  """Create and exercise instances."""
489 531
  instance_tests = [
......
612 654
    qa_config.ReleaseNode(pnode)
613 655

  
614 656
  RunExclusiveStorageTests()
657
  RunTestIf(["cluster-instance-policy", "instance-add-plain-disk"],
658
            TestIPolicyPlainInstance)
615 659

  
616 660
  # Test removing instance with offline drbd secondary
617 661
  if qa_config.TestEnabled("instance-remove-drbd-offline"):

Also available in: Unified diff