cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject git commit: updated refs/heads/master to 0d0409b
Date Thu, 15 Aug 2013 05:09:04 GMT
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 <tsp@apache.org>
(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 <ashutosh@clogeny.com>
Authored: Thu Aug 15 10:09:45 2013 +0530
Committer: Prasanna Santhanam <tsp@apache.org>
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


Mime
View raw message