Revision ec996117 qa/ganeti-qa.py
b/qa/ganeti-qa.py | ||
---|---|---|
523 | 523 |
|
524 | 524 |
|
525 | 525 |
def _BuildSpecDict(par, mn, st, mx): |
526 |
return {par: {"min": mn, "std": st, "max": mx}} |
|
526 |
return { |
|
527 |
"min": {par: mn}, |
|
528 |
"max": {par: mx}, |
|
529 |
"std": {par: st}, |
|
530 |
} |
|
527 | 531 |
|
528 | 532 |
|
529 | 533 |
def TestIPolicyPlainInstance(): |
... | ... | |
534 | 538 |
return |
535 | 539 |
|
536 | 540 |
# This test assumes that the group policy is empty |
537 |
(_, old_specs) = qa_cluster.TestClusterSetISpecs({})
|
|
541 |
(_, old_specs) = qa_cluster.TestClusterSetISpecs() |
|
538 | 542 |
node = qa_config.AcquireNode() |
539 | 543 |
try: |
540 |
# Log of policy changes, list of tuples: (change, policy_violated) |
|
544 |
# Log of policy changes, list of tuples: |
|
545 |
# (full_change, incremental_change, policy_violated) |
|
541 | 546 |
history = [] |
542 | 547 |
instance = qa_instance.TestInstanceAddWithPlainDisk([node]) |
543 | 548 |
try: |
... | ... | |
547 | 552 |
(iminval, imaxval) = qa_instance.GetInstanceSpec(instance.name, par) |
548 | 553 |
# Some specs must be multiple of 4 |
549 | 554 |
new_spec = _BuildSpecDict(par, imaxval + 4, imaxval + 4, imaxval + 4) |
550 |
history.append((new_spec, True)) |
|
551 |
qa_cluster.TestClusterSetISpecs(new_spec) |
|
555 |
history.append((None, new_spec, True))
|
|
556 |
qa_cluster.TestClusterSetISpecs(diff_specs=new_spec)
|
|
552 | 557 |
qa_cluster.AssertClusterVerify(warnings=policyerror) |
553 | 558 |
if iminval > 0: |
554 | 559 |
# Some specs must be multiple of 4 |
... | ... | |
557 | 562 |
else: |
558 | 563 |
upper = iminval - 1 |
559 | 564 |
new_spec = _BuildSpecDict(par, 0, upper, upper) |
560 |
history.append((new_spec, True)) |
|
561 |
qa_cluster.TestClusterSetISpecs(new_spec) |
|
565 |
history.append((None, new_spec, True))
|
|
566 |
qa_cluster.TestClusterSetISpecs(diff_specs=new_spec)
|
|
562 | 567 |
qa_cluster.AssertClusterVerify(warnings=policyerror) |
563 |
qa_cluster.TestClusterSetISpecs(old_specs) |
|
564 |
history.append((old_specs, False)) |
|
568 |
qa_cluster.TestClusterSetISpecs(new_specs=old_specs)
|
|
569 |
history.append((old_specs, None, False))
|
|
565 | 570 |
qa_instance.TestInstanceRemove(instance) |
566 | 571 |
finally: |
567 | 572 |
instance.Release() |
568 | 573 |
|
569 | 574 |
# Now we replay the same policy changes, and we expect that the instance |
570 | 575 |
# cannot be created for the cases where we had a policy violation above |
571 |
for (change, failed) in history: |
|
572 |
qa_cluster.TestClusterSetISpecs(change) |
|
576 |
for (new_specs, diff_specs, failed) in history: |
|
577 |
qa_cluster.TestClusterSetISpecs(new_specs=new_specs, |
|
578 |
diff_specs=diff_specs) |
|
573 | 579 |
if failed: |
574 | 580 |
qa_instance.TestInstanceAddWithPlainDisk([node], fail=True) |
575 | 581 |
# Instance creation with no policy violation has been tested already |
Also available in: Unified diff