Commit 5fdf8491 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

QA: Test multiple instance specs



The test of the interaction between policy and instances is extended.
Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 7c8ae421
......@@ -26,9 +26,10 @@
# pylint: disable=C0103
# due to invalid name
import sys
import copy
import datetime
import optparse
import sys
import qa_cluster
import qa_config
......@@ -532,6 +533,19 @@ def _BuildSpecDict(par, mn, st, mx):
}
def _BuildDoubleSpecDict(index, par, mn, st, mx):
new_spec = {
constants.ISPECS_MINMAX: [{}, {}],
}
if st is not None:
new_spec[constants.ISPECS_STD] = {par: st}
new_spec[constants.ISPECS_MINMAX][index] = {
constants.ISPECS_MIN: {par: mn},
constants.ISPECS_MAX: {par: mx},
}
return new_spec
def TestIPolicyPlainInstance():
"""Test instance policy interaction with instances"""
params = ["memory-size", "cpu-count", "disk-count", "disk-size", "nic-count"]
......@@ -552,13 +566,10 @@ def TestIPolicyPlainInstance():
try:
policyerror = [constants.CV_EINSTANCEPOLICY]
for par in params:
qa_cluster.AssertClusterVerify()
(iminval, imaxval) = qa_instance.GetInstanceSpec(instance.name, par)
# Some specs must be multiple of 4
new_spec = _BuildSpecDict(par, imaxval + 4, imaxval + 4, imaxval + 4)
history.append((None, new_spec, True))
qa_cluster.TestClusterSetISpecs(diff_specs=new_spec)
qa_cluster.AssertClusterVerify(warnings=policyerror)
if iminval > 0:
# Some specs must be multiple of 4
if iminval >= 4:
......@@ -567,10 +578,47 @@ def TestIPolicyPlainInstance():
upper = iminval - 1
new_spec = _BuildSpecDict(par, 0, upper, upper)
history.append((None, new_spec, True))
qa_cluster.TestClusterSetISpecs(diff_specs=new_spec)
qa_cluster.AssertClusterVerify(warnings=policyerror)
qa_cluster.TestClusterSetISpecs(new_specs=old_specs)
history.append((old_specs, None, False))
# Test with two instance specs
double_specs = copy.deepcopy(old_specs)
double_specs[constants.ISPECS_MINMAX] = \
double_specs[constants.ISPECS_MINMAX] * 2
(par1, par2) = params[0:2]
(_, imaxval1) = qa_instance.GetInstanceSpec(instance.name, par1)
(_, imaxval2) = qa_instance.GetInstanceSpec(instance.name, par2)
old_minmax = old_specs[constants.ISPECS_MINMAX][0]
history.extend([
(double_specs, None, False),
# The first min/max limit is being violated
(None,
_BuildDoubleSpecDict(0, par1, imaxval1 + 4, imaxval1 + 4,
imaxval1 + 4),
False),
# Both min/max limits are being violated
(None,
_BuildDoubleSpecDict(1, par2, imaxval2 + 4, None, imaxval2 + 4),
True),
# The second min/max limit is being violated
(None,
_BuildDoubleSpecDict(0, par1,
old_minmax[constants.ISPECS_MIN][par1],
old_specs[constants.ISPECS_STD][par1],
old_minmax[constants.ISPECS_MAX][par1]),
False),
(old_specs, None, False),
])
# Apply the changes, and check policy violations after each change
qa_cluster.AssertClusterVerify()
for (new_specs, diff_specs, failed) in history:
qa_cluster.TestClusterSetISpecs(new_specs=new_specs,
diff_specs=diff_specs)
if failed:
qa_cluster.AssertClusterVerify(warnings=policyerror)
else:
qa_cluster.AssertClusterVerify()
qa_instance.TestInstanceRemove(instance)
finally:
instance.Release()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment