cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [02/50] [abbrv] git commit: updated refs/heads/ui-vpc-redesign to d00077a
Date Fri, 10 May 2013 20:33:03 GMT
CLOUDSTACK-2329, CLOUDSTACK-1820: Tests for regions

Marvin tests and corresponding library changes for the regions feature.

Signed-off-by: Prasanna Santhanam <tsp@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5ef2f1f2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5ef2f1f2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5ef2f1f2

Branch: refs/heads/ui-vpc-redesign
Commit: 5ef2f1f26fcd159cb48b25882ea10cb3fc44d1b9
Parents: b6cb23c
Author: Sangeetha Hariharan <sangeetha.hariharan@citrix.com>
Authored: Fri May 3 17:02:32 2013 -0700
Committer: Prasanna Santhanam <tsp@apache.org>
Committed: Wed May 8 13:49:13 2013 +0530

----------------------------------------------------------------------
 test/integration/component/test_regions.py  |  443 ++++++++++++++++++++++
 tools/marvin/marvin/integration/lib/base.py |   54 +++
 2 files changed, 497 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5ef2f1f2/test/integration/component/test_regions.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_regions.py b/test/integration/component/test_regions.py
new file mode 100644
index 0000000..1b24871
--- /dev/null
+++ b/test/integration/component/test_regions.py
@@ -0,0 +1,443 @@
+#!/usr/bin/env python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from marvin.cloudstackTestCase import *
+from marvin.cloudstackAPI import *
+from marvin.integration.lib.utils import *
+from marvin.integration.lib.base import *
+from marvin.integration.lib.common import *
+from marvin import remoteSSHClient
+from nose.plugins.attrib import attr
+
+class Services:
+    """
+    """
+
+    def __init__(self):
+        self.services = {
+       "domain": {
+       "name": "testuuid",
+       "domainUUID": "domain1"
+       },
+            "account": {
+                "email": "test@test.com",
+                "firstname": "Testuuid",
+                "lastname": "Useruuid",
+                "username": "test",
+                # Random characters are appended for unique
+                # username
+                "password": "password",
+       "accountUUID": "account1",
+       "userUUID": "user1"
+            },
+            "user": {
+                "email": "test@test.com",
+                "firstname": "Testuuid",
+                "lastname": "Useruuid",
+                "username": "test",
+                # Random characters are appended for unique
+                # username
+                "password": "password",
+       "userUUID": "user2"
+            },
+            "ostype": 'CentOS 5.3 (64-bit)',
+       "region": {
+       "regionid": "2",
+       "regionname": "Region2",
+       "regionendpoint": "http://region2:8080/client"
+       }
+        }
+
+
+class TestRegions(cloudstackTestCase):
+    """
+   Testing Regions related Apis
+    """
+    @classmethod
+    def setUpClass(cls):
+        cls.api_client = super(TestRegions, cls).getClsTestClient().getApiClient()
+        cls.services = Services().services
+   cls.domain = get_domain(cls.api_client, cls.services)
+   cls.cleanup = []
+        return
+
+    @attr(tags=["basic", "advanced"])
+    def test_createAccountWithUUID(self):
+   """
+   Test for creating Account by passing id parameter
+
+        # Validate the following
+        # 1.Create an Account by passing id parameter.Verify the account is created.
+        # 2.List this account by passing id parameter.Verify that list account is able to
lis this account.
+        # 3.Delete account should succeed.
+
+   """
+        account = Account.create(
+            self.api_client,
+            self.services["account"],
+            domainid=self.domain.id
+   )
+   self.assertIn ( self.services["account"]["accountUUID"] , account.id,
+            "Account is not created with the accountId passed")
+
+   list_account = Account.list(self.api_client,
+            id=account.id
+   )
+
+   self.assertEqual(
+                         isinstance(list_account, list),
+                         True,
+                         "Check for list account response by uuid failed"
+                         )
+
+   print (list_account)
+
+        account_response = list_account[0]
+
+   print (account_response)
+
+        self.assertEqual( account_response.id,
+                            account.id,
+                            "listAccount response does not match with account Id "
+                        )
+        self.assertEqual(
+                            account_response.user[0].firstname,
+                            self.services["account"]["firstname"],
+                            "listAccount response does not match with account firstname"
+                        )
+
+   self.cleanup.append(account)
+   return
+
+    @attr(tags=["basic", "advanced"])
+    def test_createUserWithUUID(self):
+   """
+   Test for creating User by passing id parameter
+
+        # Validate the following
+        # 1.Create a User by passing id parameter.Verify the user is created.
+        # 2.List this user by passing id parameter.Verify that list user is able to list
this user.
+        # 3.Delete User should succeed.
+
+   """
+
+        user = User.create(
+            self.api_client,
+            self.services["user"],
+       account="Admin",
+            domainid=self.domain.id
+   )
+   self.assertIn ( self.services["user"]["userUUID"] , user.id,
+            "User is not created successfully with the userId passed")
+
+   list_user = User.list(self.api_client,
+                     id=user.id
+        )
+
+        self.assertEqual(
+                         isinstance(list_user, list),
+                         True,
+                         "Check for list user response by uuid failed"
+                         )
+
+
+        user_response = list_user[0]
+
+
+        self.assertEqual( user_response.id,
+                            user.id,
+                            "list User response does not match with user Id "
+                        )
+        self.assertEqual(
+                            user_response.firstname,
+                            self.services["user"]["firstname"],
+                            "listUser response does not match with user firstname"
+                        )
+
+   user.delete(self.api_client)
+
+        list_user = User.list(self.api_client,
+                     id=user.id
+        )
+
+        self.assertIsNone(
+                         list_user,
+                         "Deletion of user failed"
+                         )
+
+
+   return
+
+    @attr(tags=["basic", "advanced"])
+    def test_createdomainWithUUID(self):
+   """
+   Test for creating Domain by passing id parameter
+
+        # Validate the following
+        # 1.Create a domain by passing id parameter.Verify the domain is created.
+        # 2.List this domain by passing id parameter.Verify that list domain is able to list
this domain.
+        # 3.Delete domain should succeed.
+
+   """
+
+        domain = Domain.create(
+            self.api_client,
+            self.services["domain"]
+   )
+   self.assertIn ( self.services["domain"]["domainUUID"] , domain.id,
+            "Domain is not created with the doaminId passed")
+
+        list_domain = Domain.list(self.api_client,
+                     id=domain.id
+        )
+
+        self.assertEqual(
+                         isinstance(list_domain, list),
+                         True,
+                         "Check for list domain response by uuid failed"
+                         )
+
+
+        domain_response = list_domain[0]
+
+
+        self.assertEqual( domain_response.id,
+                            domain.id,
+                            "list domain response does not match with domain Id "
+                        )
+        self.assertIn(
+                            self.services["domain"]["name"],
+                            domain_response.name,
+                            "list domaiin response does not match with user firstname"
+                        )
+        try:
+            domain.delete(self.api_client)
+        except Exception as e:
+            self.fail("Failed to delete domain: %s" % e)
+
+   return
+
+    @attr(tags=["basic", "advanced"])
+    def test_createRegion(self):
+   """
+       Test for add Region
+   """
+
+   region = Region.create(self.api_client,
+            self.services["region"]
+   )
+
+   list_region = Region.list(self.api_client,
+            id=self.services["region"]["regionid"]
+   )
+
+   self.assertEqual(
+                         isinstance(list_region, list),
+                         True,
+                         "Check for list Region response"
+                         )
+        region_response = list_region[0]
+
+   print (region_response)
+   print (self.services["region"])
+
+        self.assertEqual(
+                            str(region_response.id),
+                            self.services["region"]["regionid"],
+                            "listRegion response does not match with region Id created"
+                        )
+
+        self.assertEqual(
+                            region_response.name,
+                            self.services["region"]["regionname"],
+                            "listRegion response does not match with region name created"
+                        )
+        self.assertEqual(
+                            region_response.endpoint,
+                            self.services["region"]["regionendpoint"],
+                            "listRegion response does not match with region endpoint created"
+                        )
+
+   region = region.delete(self.api_client)
+
+   return
+
+    @attr(tags=["basic", "advanced"])
+    def test_createDupRegion(self):
+   """
+       Test for duplicate checks on id and name parameters when adding regions
+   """
+
+   self.services["region"]["regionid"]="5"
+        self.services["region"]["regionname"]="Region5"
+        self.services["region"]["regionendpoint"]="http://region5:8080/client"
+
+
+   region = Region.create(self.api_client,
+            self.services["region"]
+   )
+
+   list_region = Region.list(self.api_client,
+            id=self.services["region"]["regionid"]
+   )
+
+   self.assertEqual(
+                         isinstance(list_region, list),
+                         True
+           )
+   """
+        Creating regions with duplicate id should not be allowed
+        """
+
+   self.services["region"]["regionid"]="5"
+        self.services["region"]["regionname"]="Region51"
+        self.services["region"]["regionendpoint"]="http://region51:8080/client"
+
+   try:
+       region = Region.create(self.api_client,
+            self.services["region"]
+       )
+       self.assertIsNone(region,
+                         "Creating regions with duplicate id is allowed"
+           )
+   except:
+       print " Creating Region with duplicate Id is not allowed"
+       pass
+
+   """
+   Creating regions with duplicate name should not be allowed
+   """
+
+   self.services["region"]["regionid"]="51"
+        self.services["region"]["regionname"]="Region5"
+        self.services["region"]["regionendpoint"]="http://region51:8080/client"
+
+   try:
+       region = Region.create(self.api_client,
+            self.services["region"]
+       )
+   except:
+       print " Creating Region with duplicate Name is not allowed"
+       pass
+
+   region.delete(self.api_client)
+
+   return
+
+    @attr(tags=["basic", "advanced"])
+    def test_updateRegion(self):
+   """
+       Test for update Region
+   """
+
+   self.services["region"]["regionid"]="3"
+   self.services["region"]["regionname"]="Region3"
+   self.services["region"]["regionendpoint"]="http://region3:8080/client"
+   region = Region.create(self.api_client,
+            self.services["region"]
+   )
+
+   self.services["region"]["regionname"]="Region3upd"
+   self.services["region"]["regionendpoint"]="http://region3upd:8080/client"
+
+   updated_region = region.update(self.api_client,
+                          self.services["region"]
+   )
+
+   list_region = Region.list(self.api_client,
+               id=self.services["region"]["regionid"]
+   )
+
+   self.assertEqual(
+                         isinstance(list_region, list),
+                         True,
+                         "Check for list Region response"
+                         )
+        region_response = list_region[0]
+
+        self.assertEqual(
+                            str(region_response.id),
+                            self.services["region"]["regionid"],
+                            "listRegion response does not match with region Id created"
+                        )
+
+        self.assertEqual(
+                            region_response.name,
+                            self.services["region"]["regionname"],
+                            "listRegion response does not match with region name created"
+                        )
+        self.assertEqual(
+                            region_response.endpoint,
+                            self.services["region"]["regionendpoint"],
+                            "listRegion response does not match with region endpoint created"
+                        )
+
+   region.delete(self.api_client)
+
+   return
+
+    @attr(tags=["basic", "advanced"])
+    def test_deleteRegion(self):
+   """
+       Test for delete Region
+   """
+
+   self.services["region"]["regionid"]="4"
+   self.services["region"]["regionname"]="Region4"
+   self.services["region"]["regionendpoint"]="http://region4:8080/client"
+
+   region = Region.create(self.api_client,
+            self.services["region"]
+   )
+
+   list_region = Region.list(self.api_client,
+            id=self.services["region"]["regionid"]
+   )
+
+   print (list_region);
+
+   self.assertEqual(
+                         len(list_region),
+                         1,
+            "Check for Region response"
+           )
+
+   region = region.delete(self.api_client)
+
+   list_region = Region.list(self.api_client,
+            id=self.services["region"]["regionid"]
+   )
+
+   print (list_region);
+
+   self.assertIsNone(list_region,
+                         "Check for empty Region response"
+                         )
+
+   return
+
+
+        @classmethod
+        def tearDown(cls):
+
+            try:
+                cls.api_client = super(TestRegions, cls).getClsTestClient().getApiClient()
+                #Clean up
+                cleanup_resources(cls.api_client, cls.cleanup)
+            except Exception as e:
+                raise Exception("Warning: Exception during cleanup : %s" % e)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5ef2f1f2/tools/marvin/marvin/integration/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py
index 92b8a2d..899c203 100755
--- a/tools/marvin/marvin/integration/lib/base.py
+++ b/tools/marvin/marvin/integration/lib/base.py
@@ -40,6 +40,9 @@ class Domain:
 
         cmd = createDomain.createDomainCmd()
 
+   if "domainUUID" in services:
+            cmd.domainid = "-".join([services["domainUUID"],random_gen()])
+
         if name:
             cmd.name = "-".join([name, random_gen()])
         elif "name" in services:
@@ -97,6 +100,13 @@ class Account:
         cmd.password = services["password"]
         cmd.username = "-".join([services["username"], random_gen()])
 
+        if "accountUUID" in services:
+            cmd.accountid =  "-".join([services["accountUUID"],random_gen()])
+
+        if "userUUID" in services:
+            cmd.userid = "-".join([services["userUUID"],random_gen()])
+
+
         if domainid:
             cmd.domainid = domainid
         account = apiclient.createAccount(cmd)
@@ -135,6 +145,9 @@ class User:
         cmd.firstname = services["firstname"]
         cmd.lastname = services["lastname"]
 
+        if "userUUID" in services:
+            cmd.userid = "-".join([services["userUUID"],random_gen()])
+
         # Password Encoding
         mdf = hashlib.md5()
         mdf.update(services["password"])
@@ -3108,3 +3121,44 @@ class VmSnapshot:
         cmd.vmsnapshotid = vmsnapshotid
         
         return apiclient.deleteVMSnapshot(cmd)
+
+class Region:
+    """ Regions related Api """
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+    @classmethod
+    def create(cls, apiclient, services):
+        cmd = addRegion.addRegionCmd()
+        cmd.id = services["regionid"]
+        cmd.endpoint = services["regionendpoint"]
+        cmd.name = services["regionname"]
+        try:
+            region = apiclient.addRegion(cmd)
+            if region is not None:
+                return Region(region.__dict__)
+        except Exception as e:
+            raise e
+
+    @classmethod
+    def list(cls, apiclient, **kwargs):
+        cmd = listRegions.listRegionsCmd()
+        [setattr(cmd, k, v) for k, v in kwargs.items()]
+        region = apiclient.listRegions(cmd)
+        return region
+
+    def update(self, apiclient, services):
+        cmd = updateRegion.updateRegionCmd()
+        cmd.id = self.id
+        if services["regionendpoint"]:
+                cmd.endpoint = services["regionendpoint"]
+        if services["regionname"]:
+                cmd.name = services["regionname"]
+        region = apiclient.updateRegion(cmd)
+        return region
+
+    def delete(self, apiclient):
+        cmd = removeRegion.removeRegionCmd()
+        cmd.id = self.id
+        region = apiclient.removeRegion(cmd)
+        return region


Mime
View raw message