Revision 5fdf8491
b/qa/ganeti-qa.py | ||
---|---|---|
26 | 26 |
# pylint: disable=C0103 |
27 | 27 |
# due to invalid name |
28 | 28 |
|
29 |
import sys
|
|
29 |
import copy
|
|
30 | 30 |
import datetime |
31 | 31 |
import optparse |
32 |
import sys |
|
32 | 33 |
|
33 | 34 |
import qa_cluster |
34 | 35 |
import qa_config |
... | ... | |
532 | 533 |
} |
533 | 534 |
|
534 | 535 |
|
536 |
def _BuildDoubleSpecDict(index, par, mn, st, mx): |
|
537 |
new_spec = { |
|
538 |
constants.ISPECS_MINMAX: [{}, {}], |
|
539 |
} |
|
540 |
if st is not None: |
|
541 |
new_spec[constants.ISPECS_STD] = {par: st} |
|
542 |
new_spec[constants.ISPECS_MINMAX][index] = { |
|
543 |
constants.ISPECS_MIN: {par: mn}, |
|
544 |
constants.ISPECS_MAX: {par: mx}, |
|
545 |
} |
|
546 |
return new_spec |
|
547 |
|
|
548 |
|
|
535 | 549 |
def TestIPolicyPlainInstance(): |
536 | 550 |
"""Test instance policy interaction with instances""" |
537 | 551 |
params = ["memory-size", "cpu-count", "disk-count", "disk-size", "nic-count"] |
... | ... | |
552 | 566 |
try: |
553 | 567 |
policyerror = [constants.CV_EINSTANCEPOLICY] |
554 | 568 |
for par in params: |
555 |
qa_cluster.AssertClusterVerify() |
|
556 | 569 |
(iminval, imaxval) = qa_instance.GetInstanceSpec(instance.name, par) |
557 | 570 |
# Some specs must be multiple of 4 |
558 | 571 |
new_spec = _BuildSpecDict(par, imaxval + 4, imaxval + 4, imaxval + 4) |
559 | 572 |
history.append((None, new_spec, True)) |
560 |
qa_cluster.TestClusterSetISpecs(diff_specs=new_spec) |
|
561 |
qa_cluster.AssertClusterVerify(warnings=policyerror) |
|
562 | 573 |
if iminval > 0: |
563 | 574 |
# Some specs must be multiple of 4 |
564 | 575 |
if iminval >= 4: |
... | ... | |
567 | 578 |
upper = iminval - 1 |
568 | 579 |
new_spec = _BuildSpecDict(par, 0, upper, upper) |
569 | 580 |
history.append((None, new_spec, True)) |
570 |
qa_cluster.TestClusterSetISpecs(diff_specs=new_spec) |
|
571 |
qa_cluster.AssertClusterVerify(warnings=policyerror) |
|
572 |
qa_cluster.TestClusterSetISpecs(new_specs=old_specs) |
|
573 | 581 |
history.append((old_specs, None, False)) |
582 |
|
|
583 |
# Test with two instance specs |
|
584 |
double_specs = copy.deepcopy(old_specs) |
|
585 |
double_specs[constants.ISPECS_MINMAX] = \ |
|
586 |
double_specs[constants.ISPECS_MINMAX] * 2 |
|
587 |
(par1, par2) = params[0:2] |
|
588 |
(_, imaxval1) = qa_instance.GetInstanceSpec(instance.name, par1) |
|
589 |
(_, imaxval2) = qa_instance.GetInstanceSpec(instance.name, par2) |
|
590 |
old_minmax = old_specs[constants.ISPECS_MINMAX][0] |
|
591 |
history.extend([ |
|
592 |
(double_specs, None, False), |
|
593 |
# The first min/max limit is being violated |
|
594 |
(None, |
|
595 |
_BuildDoubleSpecDict(0, par1, imaxval1 + 4, imaxval1 + 4, |
|
596 |
imaxval1 + 4), |
|
597 |
False), |
|
598 |
# Both min/max limits are being violated |
|
599 |
(None, |
|
600 |
_BuildDoubleSpecDict(1, par2, imaxval2 + 4, None, imaxval2 + 4), |
|
601 |
True), |
|
602 |
# The second min/max limit is being violated |
|
603 |
(None, |
|
604 |
_BuildDoubleSpecDict(0, par1, |
|
605 |
old_minmax[constants.ISPECS_MIN][par1], |
|
606 |
old_specs[constants.ISPECS_STD][par1], |
|
607 |
old_minmax[constants.ISPECS_MAX][par1]), |
|
608 |
False), |
|
609 |
(old_specs, None, False), |
|
610 |
]) |
|
611 |
|
|
612 |
# Apply the changes, and check policy violations after each change |
|
613 |
qa_cluster.AssertClusterVerify() |
|
614 |
for (new_specs, diff_specs, failed) in history: |
|
615 |
qa_cluster.TestClusterSetISpecs(new_specs=new_specs, |
|
616 |
diff_specs=diff_specs) |
|
617 |
if failed: |
|
618 |
qa_cluster.AssertClusterVerify(warnings=policyerror) |
|
619 |
else: |
|
620 |
qa_cluster.AssertClusterVerify() |
|
621 |
|
|
574 | 622 |
qa_instance.TestInstanceRemove(instance) |
575 | 623 |
finally: |
576 | 624 |
instance.Release() |
Also available in: Unified diff