Commit 4b10fb65 authored by Adeodato Simo's avatar Adeodato Simo
Browse files

More QA tests for group operations



This adds QA tests for the SetGroupParams operation, both for CLI and
RAPI. Additionally, it adds tests for add/rename/remove groups via RAPI,
which had not been included in a previous patch series. Finally, it also
tests setting "alloc_policy" (and, for the CLI, "ndparams") at group
creation time.
Signed-off-by: default avatarAdeodato Simo <dato@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 2bac48c4
......@@ -249,6 +249,10 @@ def RunGroupRwTests():
"""
RunTestIf("group-rwops", qa_group.TestGroupAddRemoveRename)
RunTestIf("group-rwops", qa_group.TestGroupAddWithOptions)
RunTestIf("group-rwops", qa_group.TestGroupModify)
RunTestIf("rapi", qa_rapi.TestRapiNodeGroups)
def RunExportImportTests(instance, pnode, snode):
"""Tries to export and import the instance.
......
......@@ -53,6 +53,36 @@ def TestGroupAddRemoveRename():
AssertCommand(["gnt-group", "rename", group1, existing_group_with_nodes])
def TestGroupAddWithOptions():
"""gnt-group add with options"""
groups = qa_config.get("groups", {})
group1 = groups.get("inexistent-groups", ["group1"])[0]
AssertCommand(["gnt-group", "add", "--alloc-policy", "notvalid", group1],
fail=True)
AssertCommand(["gnt-group", "add", "--alloc-policy", "last_resort",
"--node-parameters", "oob_program=/bin/true", group1])
AssertCommand(["gnt-group", "remove", group1])
def TestGroupModify():
"""gnt-group modify"""
groups = qa_config.get("groups", {})
group1 = groups.get("inexistent-groups", ["group1"])[0]
AssertCommand(["gnt-group", "add", group1])
try:
AssertCommand(["gnt-group", "modify", "--alloc-policy", "unallocable",
"--node-parameters", "oob_program=/bin/false", group1])
AssertCommand(["gnt-group", "modify",
"--alloc-policy", "notvalid", group1], fail=True)
finally:
AssertCommand(["gnt-group", "remove", group1])
def TestGroupListDefaultFields():
"""gnt-group list"""
AssertCommand(["gnt-group", "list"])
......
......@@ -337,6 +337,68 @@ def _WaitForRapiJob(job_id):
cli.StdioJobPollReportCb())
def TestRapiNodeGroups():
"""Test several node group operations using RAPI.
"""
groups = qa_config.get("groups", {})
group1, group2, group3 = groups.get("inexistent-groups",
["group1", "group2", "group3"])[:3]
# Create a group with no attributes
body = {
"name": group1,
}
(job_id, ) = _DoTests([
("/2/groups", _VerifyReturnsJob, "POST", body),
])
_WaitForRapiJob(job_id)
# Create a group specifying alloc_policy
body = {
"name": group2,
"alloc_policy": constants.ALLOC_POLICY_UNALLOCABLE,
}
(job_id, ) = _DoTests([
("/2/groups", _VerifyReturnsJob, "POST", body),
])
_WaitForRapiJob(job_id)
# Modify alloc_policy
body = {
"alloc_policy": constants.ALLOC_POLICY_UNALLOCABLE,
}
(job_id, ) = _DoTests([
("/2/groups/%s/modify" % group1, _VerifyReturnsJob, "PUT", body),
])
_WaitForRapiJob(job_id)
# Rename a group
body = {
"new_name": group3,
}
(job_id, ) = _DoTests([
("/2/groups/%s/rename" % group2, _VerifyReturnsJob, "PUT", body),
])
_WaitForRapiJob(job_id)
# Delete groups
for group in [group1, group3]:
(job_id, ) = _DoTests([
("/2/groups/%s" % group, _VerifyReturnsJob, "DELETE", None),
])
_WaitForRapiJob(job_id)
def TestRapiInstanceAdd(node, use_client):
"""Test adding a new instance via RAPI"""
instance = qa_config.AcquireInstance()
......
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