Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 417CE100E5 for ; Thu, 15 Aug 2013 05:09:13 +0000 (UTC) Received: (qmail 13703 invoked by uid 500); 15 Aug 2013 05:09:12 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 13650 invoked by uid 500); 15 Aug 2013 05:09:06 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 13643 invoked by uid 99); 15 Aug 2013 05:09:05 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Aug 2013 05:09:05 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 8B5A8836BD8; Thu, 15 Aug 2013 05:09:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tsp@apache.org To: commits@cloudstack.apache.org Message-Id: <64a217a7f9a84fb790061d70e5f55945@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to 0d0409b Date: Thu, 15 Aug 2013 05:09:04 +0000 (UTC) Updated Branches: refs/heads/master 81fedcfa3 -> 0d0409bdd CLOUDSTACK-3594: New affinity group tests - list all vms in affinity group - delete an affinity group by id - admin deletes affinity groups - list affinity groups as admin - list affinity groups by accountid/domainid - list affinity groups by group id - user deletes his affinity group Signed-off-by: Prasanna Santhanam (cherry picked from commit 682e995a4a21e2d74b79bc26513055b913f3545d) Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0d0409bd Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0d0409bd Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0d0409bd Branch: refs/heads/master Commit: 0d0409bddbcd9d8543d8dcf8d4648b9fcf6f5b2c Parents: 81fedcf Author: Ashutosh K Authored: Thu Aug 15 10:09:45 2013 +0530 Committer: Prasanna Santhanam Committed: Thu Aug 15 10:38:37 2013 +0530 ---------------------------------------------------------------------- .../component/test_affinity_groups.py | 189 +++++++++++++++++++ 1 file changed, 189 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0d0409bd/test/integration/component/test_affinity_groups.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_affinity_groups.py b/test/integration/component/test_affinity_groups.py index 39baf3e..c41049b 100644 --- a/test/integration/component/test_affinity_groups.py +++ b/test/integration/component/test_affinity_groups.py @@ -489,6 +489,32 @@ class TestListAffinityGroups(cloudstackTestCase): self.aff_grp[0].delete(self.api_client) + @attr(tags=["simulator", "basic", "advanced"]) + def test_07_list_all_vms_in_aff_grp(self): + """ + List affinity group should list all for a vms associated with that group + """ + + self.create_aff_grp(aff_grp=self.services["host_anti_affinity"]) + + vm, hostid = self.create_vm_in_aff_grps([self.aff_grp[0].name]) + list_aff_grps = AffinityGroup.list(self.api_client, id=self.aff_grp[0].id) + + self.assertEqual(list_aff_grps[0].name, self.aff_grp[0].name, + "Listing Affinity Group by id failed") + + self.assertEqual(list_aff_grps[0].virtualmachineIds[0], vm.id, + "List affinity group response.virtualmachineIds for group: %s doesn't contain hostid : %s associated with the group" + %(self.aff_grp[0].name, vm.id) + ) + + + vm.delete(self.api_client) + #Wait for expunge interval to cleanup VM + wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"]) + + self.aff_grp[0].delete(self.api_client) + class TestDeleteAffinityGroups(cloudstackTestCase): @classmethod @@ -716,6 +742,42 @@ class TestDeleteAffinityGroups(cloudstackTestCase): aff_0.delete(self.api_client) aff_1.delete(userapiclient) + @attr(tags=["simulator", "basic", "advanced"]) + def test_08_delete_aff_grp_by_id(self): + """ + Delete Affinity Group by id. + """ + + aff_grp_1 = self.create_aff_grp(aff_grp=self.services["host_anti_affinity"]) + aff_grp_2 = self.create_aff_grp(aff_grp=self.services["host_anti_affinity"]) + + aff_grp_1.delete(self.api_client) + aff_grp_2.delete(self.api_client) + + @attr(tags=["simulator", "basic", "advanced"]) + def test_09_delete_aff_grp_root_admin(self): + """ + Root admin should be able to delete affinity group of other users + """ + + self.user1 = Account.create(self.api_client, + self.services["new_account"]) + + self.cleanup.append(self.user1) + user1apiclient = self.testClient.createUserApiClient( + UserName=self.user1.name, + DomainName=self.user1.domain, + acctType=0) + + aff_grp = self.create_aff_grp(api_client=user1apiclient, + aff_grp=self.services["host_anti_affinity"]) + + list_aff_grps = AffinityGroup.list(self.api_client) + self.assertNotEqual(list_aff_grps, [], "Admin not able to list Affinity " + "Groups of users") + + aff_grp.delete(self.api_client) + class TestUpdateVMAffinityGroups(cloudstackTestCase): @classmethod @@ -1504,3 +1566,130 @@ class TestAffinityGroupsAdminUser(cloudstackTestCase): self.assertNotEqual(list_aff_grps, [], "Admin not able to list Affinity " "Groups of users") aff_grp.delete(userapiclient) + + @attr(tags=["simulator", "basic", "advanced"]) + def test_04_list_all_admin_aff_grp(self): + """ + List Affinity Groups belonging to admin user + """ + + aff_grp1 = self.create_aff_grp(api_client=self.api_client, + aff_grp=self.services["host_anti_affinity"]) + aff_grp2 = self.create_aff_grp(api_client=self.api_client, + aff_grp=self.services["host_anti_affinity"]) + + list_aff_grps = AffinityGroup.list(self.api_client) + + self.assertNotEqual(list_aff_grps, [], "Admin not able to list Affinity " + "Groups belonging to him") + grp_names = [aff_grp1.name, aff_grp2.name] + list_names = [] + for grp in list_aff_grps: + list_names.append(grp.name) + + for name in grp_names: + self.assertTrue(name in list_names, + "Listing affinity groups belonging to Admin didn't return group %s" %(name)) + + aff_grp1.delete(self.api_client) + aff_grp2.delete(self.api_client) + + @attr(tags=["simulator", "basic", "advanced"]) + def test_05_list_all_users_aff_grp(self): + """ + List Affinity Groups belonging to regular user passing account id and domain id + """ + + self.user1 = Account.create(self.api_client, + self.services["new_account"]) + + self.cleanup.append(self.user1) + userapiclient = self.testClient.createUserApiClient( + UserName=self.user1.name, + DomainName=self.user1.domain, + acctType=0) + + aff_grp1 = self.create_aff_grp(api_client=userapiclient, + aff_grp=self.services["host_anti_affinity"]) + aff_grp2 = self.create_aff_grp(api_client=userapiclient, + aff_grp=self.services["host_anti_affinity"]) + + list_aff_grps = AffinityGroup.list(self.api_client, accountId=self.user1.id, domainId=self.user1.domainid) + + self.assertNotEqual(list_aff_grps, [], "Admin not able to list Affinity " + "Groups of users") + grp_names = [aff_grp1.name, aff_grp2.name] + list_names = [] + for grp in list_aff_grps: + list_names.append(grp.name) + + for name in grp_names: + self.assertTrue(name in list_names, + "Missing Group %s from listing" %(name)) + + aff_grp1.delete(self.api_client) + aff_grp2.delete(self.api_client) + + @attr(tags=["simulator", "basic", "advanced"]) + def test_06_list_all_users_aff_grp_by_id(self): + """ + List Affinity Groups belonging to regular user passing group id + """ + + self.user1 = Account.create(self.api_client, + self.services["new_account"]) + + self.cleanup.append(self.user1) + userapiclient = self.testClient.createUserApiClient( + UserName=self.user1.name, + DomainName=self.user1.domain, + acctType=0) + + aff_grp = self.create_aff_grp(api_client=userapiclient, + aff_grp=self.services["host_anti_affinity"]) + + list_aff_grps = AffinityGroup.list(userapiclient) + aff_grp_by_id = AffinityGroup.list(self.api_client, id=list_aff_grps[0].id) + + self.assertNotEqual(aff_grp_by_id, [], "Admin not able to list Affinity " + "Groups of users") + self.assertEqual(len(aff_grp_by_id), 1, "%s affinity groups listed by admin with id %s. Expected 1" + %(len(aff_grp_by_id), list_aff_grps[0].id)) + self.assertEqual(aff_grp_by_id[0].name, aff_grp.name, + "Incorrect name returned when listing user affinity groups as admin by id Expected : %s Got: %s" + %(aff_grp.name, aff_grp_by_id[0].name ) + ) + + aff_grp.delete(self.api_client) + + @attr(tags=["simulator", "basic", "advanced"]) + def test_07_delete_aff_grp_of_other_user(self): + """ + Delete Affinity Group belonging to regular user + """ + + self.user1 = Account.create(self.api_client, + self.services["new_account"]) + + self.cleanup.append(self.user1) + userapiclient = self.testClient.createUserApiClient( + UserName=self.user1.name, + DomainName=self.user1.domain, + acctType=0) + + aff_grp = self.create_aff_grp(api_client=userapiclient, + aff_grp=self.services["host_anti_affinity"]) + + list_aff_grps = AffinityGroup.list(userapiclient) + aff_grp_by_id = AffinityGroup.list(self.api_client, id=list_aff_grps[0].id) + + self.assertNotEqual(aff_grp_by_id, [], "Admin not able to list Affinity " + "Groups of users") + self.assertEqual(len(aff_grp_by_id), 1, "%s affinity groups listed by admin with id %s. Expected 1" + %(len(aff_grp_by_id), list_aff_grps[0].id)) + self.assertEqual(aff_grp_by_id[0].name, aff_grp.name, + "Incorrect name returned when listing user affinity groups as admin by id Expected : %s Got: %s" + %(aff_grp.name, aff_grp_by_id[0].name ) + ) + + aff_grp.delete(self.api_client) \ No newline at end of file