Commit cb178a1e authored by Bernardo Dal Seno's avatar Bernardo Dal Seno

QA: Update tests for new ipolicy specs command-line options

The old command-line options weren't working any more. Utility functions
are updated, and broken tests are removed (new tests are coming in the
following patches).
Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent cd315ad9
......@@ -528,7 +528,7 @@ def _BuildSpecDict(par, mn, st, mx):
def TestIPolicyPlainInstance():
"""Test instance policy interaction with instances"""
params = ["mem-size", "cpu-count", "disk-count", "disk-size", "nic-count"]
params = ["memory-size", "cpu-count", "disk-count", "disk-size", "nic-count"]
if not qa_config.IsTemplateSupported(constants.DT_PLAIN):
print "Template %s not supported" % constants.DT_PLAIN
return
......
......@@ -544,8 +544,6 @@ def _GetClusterIPolicy():
for (key, val) in policy.items():
if key in ispec_keys:
for (par, pval) in val.items():
if par == "memory-size":
par = "mem-size"
d = ret_specs.setdefault(par, {})
d[key] = pval
else:
......@@ -617,6 +615,20 @@ def TestClusterModifyIPolicy():
AssertEqual(eff_policy[p], old_policy[p])
def _GetParameterOptions(key, specs, old_specs):
values = ["%s=%s" % (par, keyvals[key])
for (par, keyvals) in specs.items()
if key in keyvals]
if old_specs:
present_pars = frozenset(par
for (par, keyvals) in specs.items()
if key in keyvals)
values.extend("%s=%s" % (par, keyvals[key])
for (par, keyvals) in old_specs.items()
if key in keyvals and par not in present_pars)
return ",".join(values)
def TestClusterSetISpecs(new_specs, fail=False, old_values=None):
"""Change instance specs.
......@@ -637,15 +649,20 @@ def TestClusterSetISpecs(new_specs, fail=False, old_values=None):
(old_policy, old_specs) = _GetClusterIPolicy()
if new_specs:
cmd = ["gnt-cluster", "modify"]
for (par, keyvals) in new_specs.items():
if par == "spindle-use":
# ignore spindle-use, which is not settable
continue
cmd += [
"--specs-%s" % par,
",".join(["%s=%s" % (k, v) for (k, v) in keyvals.items()]),
]
if any(("min" in val or "max" in val) for val in new_specs.values()):
minmax_opt_items = []
for key in ["min", "max"]:
keyopt = _GetParameterOptions(key, new_specs, old_specs)
minmax_opt_items.append("%s:%s" % (key, keyopt))
cmd.extend([
"--ipolicy-bounds-specs",
"/".join(minmax_opt_items)
])
std_opt = _GetParameterOptions("std", new_specs, {})
if std_opt:
cmd.extend(["--ipolicy-std-specs", std_opt])
AssertCommand(cmd, fail=fail)
# Check the new state
(eff_policy, eff_specs) = _GetClusterIPolicy()
AssertEqual(eff_policy, old_policy)
......@@ -663,7 +680,7 @@ def TestClusterSetISpecs(new_specs, fail=False, old_values=None):
def TestClusterModifyISpecs():
"""gnt-cluster modify --specs-*"""
params = ["mem-size", "disk-size", "disk-count", "cpu-count", "nic-count"]
params = ["memory-size", "disk-size", "disk-count", "cpu-count", "nic-count"]
(cur_policy, cur_specs) = _GetClusterIPolicy()
for par in params:
test_values = [
......
......@@ -80,10 +80,6 @@ def TestGroupAddWithOptions():
def _TestGroupModifyISpecs(groupname):
std_defaults = constants.IPOLICY_DEFAULTS[constants.ISPECS_STD]
min_v = std_defaults[constants.ISPEC_MEM_SIZE] * 10
max_v = min_v * 10
# Get the ipolicy command (from the cluster config)
mnode = qa_config.GetMasterNode()
addcmd = GetCommandOutput(mnode.primary, utils.ShellQuoteArgs([
......@@ -104,13 +100,6 @@ def _TestGroupModifyISpecs(groupname):
]))
AssertEqual(addcmd, new_addcmd)
AssertCommand(["gnt-group", "modify", "--specs-mem-size",
"min=%s,max=%s,std=0" % (min_v, max_v), groupname], fail=True)
AssertCommand(["gnt-group", "modify", "--specs-mem-size",
"min=%s,max=%s" % (min_v, max_v), groupname])
AssertCommand(["gnt-group", "modify", "--specs-mem-size",
"min=default,max=default", groupname])
def _TestGroupModifyIPolicy(groupname):
_TestGroupModifyISpecs(groupname)
......
......@@ -338,7 +338,7 @@ def GetInstanceSpec(instance, spec):
@type instance: string
@param instance: Instance name
@type spec: string
@param spec: one of the supported parameters: "mem-size", "cpu-count",
@param spec: one of the supported parameters: "memory-size", "cpu-count",
"disk-count", "disk-size", "nic-count"
@rtype: tuple
@return: (minspec, maxspec); minspec and maxspec can be different only for
......@@ -346,7 +346,7 @@ def GetInstanceSpec(instance, spec):
"""
specmap = {
"mem-size": ["be/minmem", "be/maxmem"],
"memory-size": ["be/minmem", "be/maxmem"],
"cpu-count": ["vcpus"],
"disk-count": ["disk.count"],
"disk-size": ["disk.size/ "],
......
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