diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py index 41dc3f9b6ab967ad6db23820c8f39f5804bd4633..f94746cfae861006c6cf1fcecd00d14d3018748d 100755 --- a/qa/ganeti-qa.py +++ b/qa/ganeti-qa.py @@ -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. diff --git a/qa/qa_group.py b/qa/qa_group.py index eda710fc212af928604e3e7363941616a6826758..4283291627df0e4e65571e668c6714bcc8165e0b 100644 --- a/qa/qa_group.py +++ b/qa/qa_group.py @@ -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"]) diff --git a/qa/qa_rapi.py b/qa/qa_rapi.py index ea74bb5f8a7036f1869fba87436e9b6d2738b81d..2e19bf51308a2c921d7bb75bf726ed7f8e7fdbe4 100644 --- a/qa/qa_rapi.py +++ b/qa/qa_rapi.py @@ -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()