cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gir...@apache.org
Subject git commit: updated refs/heads/master to 613eb12
Date Tue, 22 Jul 2014 18:32:14 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 981becc73 -> 613eb1210


CLOUDSTACK-7044: Portable IP Range test case changes - reading portable ip range from test_data.py
file


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

Branch: refs/heads/master
Commit: 613eb12104af5c27935091127a1a19941f96e336
Parents: 981becc
Author: Ashutosh K <ashutosh@clogeny.com>
Authored: Tue Jul 22 04:57:46 2014 -0400
Committer: Girish Shilamkar <girish@clogeny.com>
Committed: Tue Jul 22 07:44:35 2014 -0400

----------------------------------------------------------------------
 test/integration/component/test_portable_ip.py | 165 ++++++--------------
 tools/marvin/marvin/config/test_data.py        |   3 +-
 tools/marvin/marvin/lib/common.py              |  36 -----
 3 files changed, 52 insertions(+), 152 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/613eb121/test/integration/component/test_portable_ip.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_portable_ip.py b/test/integration/component/test_portable_ip.py
index ce27dd8..81f1359 100644
--- a/test/integration/component/test_portable_ip.py
+++ b/test/integration/component/test_portable_ip.py
@@ -37,11 +37,9 @@ from marvin.lib.common import (get_zone,
                                get_domain,
                                get_region,
                                get_pod,
-                               isIpInDesiredState,
-                               getPortableIpRangeServices)
+                               isIpInDesiredState)
 from netaddr import IPAddress
 from marvin.sshClient import SshClient
-from marvin.codes import FAILED
 from nose.plugins.attrib import attr
 
 class Services:
@@ -143,14 +141,7 @@ class Services:
                                   "publicport": 22,
                                   "protocol": 'TCP',
                         },
-                        "portableIpRange":
-                                {
-			         "gateway": "10.223.252.195",
-			         "netmask": "255.255.255.192",
-			         "startip": "10.223.252.196",
-			         "endip": "10.223.252.197",
-			         "vlan": "1001",
-			},
+                        "portableiprange":"",
                         "ostype": 'CentOS 5.3 (64-bit)'
           }
 
@@ -164,7 +155,7 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
         cls.testClient = super(TestCreatePortablePublicIpRanges, cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
         cls.services = Services().services
-        cls.config = cls.services
+        cls.services["portableiprange"] = cls.testClient.getParsedTestDataConfig()["portableIpRange"]
         # Get Zone, Domain and templates
         cls.region = get_region(cls.api_client)
         cls.domain = get_domain(cls.api_client)
@@ -190,6 +181,7 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
     def setUp(self):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
+        self.services["portableiprange"]["regionid"] = self.region.id
 
         self.cleanup = []
         return
@@ -208,17 +200,10 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
         """
         # 1. Create new portable ip range with root admin api
         # 2. Portable ip range should be created successfully
-
-        portable_ip_range_services = getPortableIpRangeServices(self.config)
-        if portable_ip_range_services is FAILED:
-            self.skipTest('Failed to read config values related to portable ip range')
-
-        portable_ip_range_services["regionid"] = self.region.id
-
         try:
             #create new portable ip range
             new_portable_ip_range = PortablePublicIpRange.create(self.apiclient,
-                                                             portable_ip_range_services)
+                                                                 self.services["portableiprange"])
 
             self.cleanup.append(new_portable_ip_range)
         except Exception as e:
@@ -232,11 +217,6 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
         # 1. Create new portable ip range with non root admin api client
         # 2. Portable ip range should not be created
 
-        portable_ip_range_services = getPortableIpRangeServices(self.config)
-
-        if portable_ip_range_services is FAILED:
-            self.skipTest('Failed to read config values related to portable ip range')
-
         try:
             self.account = Account.create(
                             self.apiclient,
@@ -250,12 +230,10 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
                                             DomainName=self.account.domain
                                             )
 
-            portable_ip_range_services["regionid"] = self.region.id
-
             self.debug("Trying to create portable ip range with non root-admin api client,
should raise exception")
             with self.assertRaises(Exception):
                 portable_ip_range = PortablePublicIpRange.create(self.api_client_user,
-                                         portable_ip_range_services)
+                                                                 self.services["portableiprange"])
                 self.cleanup.append(portable_ip_range)
         except Exception as e:
             self.fail(e)
@@ -269,19 +247,14 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
         # 1. Try to create new portable ip range with invalid region id
         # 2. Portable ip range creation should fail
 
-        portable_ip_range_services = getPortableIpRangeServices(self.config)
-
-        if portable_ip_range_services is FAILED:
-            self.skipTest('Failed to read config values related to portable ip range')
-
-        portable_ip_range_services["regionid"] = -1
+        self.services["portableiprange"]["regionid"] = -1
 
         #create new portable ip range
         self.debug("Trying to create portable ip range with wrong region id")
 
         with self.assertRaises(Exception):
             portable_ip_range = PortablePublicIpRange.create(self.apiclient,
-                                         portable_ip_range_services)
+                                         self.services["portableiprange"])
             self.cleanup.append(portable_ip_range)
 
         return
@@ -296,7 +269,7 @@ class TestDeletePortablePublicIpRanges(cloudstackTestCase):
         cls.testClient = super(TestDeletePortablePublicIpRanges, cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
         cls.services = Services().services
-        cls.config = cls.services
+        cls.services["portableiprange"] = cls.testClient.getParsedTestDataConfig()["portableIpRange"]
         # Get Zone, Domain and templates
         cls.region = get_region(cls.api_client)
         cls.domain = get_domain(cls.api_client)
@@ -306,7 +279,7 @@ class TestDeletePortablePublicIpRanges(cloudstackTestCase):
         cls.services["domainid"] = cls.domain.id
         cls.services["zoneid"] = cls.zone.id
         cls.services["regionid"] = cls.region.id
-
+        cls.services["portableiprange"]["regionid"] = cls.region.id
         cls._cleanup = []
         return
 
@@ -323,16 +296,9 @@ class TestDeletePortablePublicIpRanges(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
 
-        portable_ip_range_services = getPortableIpRangeServices(self.config)
-
-        if portable_ip_range_services is FAILED:
-            self.skipTest('Failed to read config values related to portable ip range')
-
-        portable_ip_range_services["regionid"] = self.region.id
-
         #create new portable ip range
         self.portable_ip_range = PortablePublicIpRange.create(self.apiclient,
-                                                             portable_ip_range_services)
+                                                              self.services["portableiprange"])
 
         self.cleanup = []
         return
@@ -454,7 +420,7 @@ class TestListPortablePublicIpRanges(cloudstackTestCase):
         cls.testClient = super(TestListPortablePublicIpRanges, cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
         cls.services = Services().services
-        cls.config = cls.services
+        cls.services["portableiprange"] = cls.testClient.getParsedTestDataConfig()["portableIpRange"]
         # Get Zone, Domain and templates
         cls.region = get_region(cls.api_client)
         cls.domain = get_domain(cls.api_client)
@@ -464,7 +430,7 @@ class TestListPortablePublicIpRanges(cloudstackTestCase):
         cls.services["domainid"] = cls.domain.id
         cls.services["zoneid"] = cls.zone.id
         cls.services["regionid"] = cls.region.id
-
+        cls.services["portableiprange"]["regionid"] = cls.region.id
         cls._cleanup = []
         return
 
@@ -480,27 +446,13 @@ class TestListPortablePublicIpRanges(cloudstackTestCase):
     def setUp(self):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
-
-        #create new portable ip range
-        self.portable_ip_range_services = getPortableIpRangeServices(self.config)
-
-        if self.portable_ip_range_services is FAILED:
-            self.skipTest('Failed to read config values related to portable ip range')
-
-        self.portable_ip_range_services["regionid"] = self.region.id
-
         self.debug("Creating new portable IP range with startip:%s and endip:%s" %
-                    (str(self.portable_ip_range_services["startip"]),
-                     str(self.portable_ip_range_services["endip"])))
+                    (str(self.services["portableiprange"]["startip"]),
+                     str(self.services["portableiprange"]["endip"])))
 
         #create new portable ip range
         self.portable_ip_range = PortablePublicIpRange.create(self.apiclient,
-                                                             self.portable_ip_range_services)
-
-        self.debug("Created new portable IP range with startip:%s and endip:%s and id:%s"
%
-                    (self.portable_ip_range.startip,
-                     self.portable_ip_range.endip,
-                     self.portable_ip_range.id))
+                                                              self.services["portableiprange"])
 
         self.cleanup = [self.portable_ip_range, ]
         return
@@ -532,16 +484,16 @@ class TestListPortablePublicIpRanges(cloudstackTestCase):
 
         portable_ip_range = list_portable_ip_range[0]
 
-        self.assertEqual(str(portable_ip_range.startip), str(self.portable_ip_range_services["startip"]),
+        self.assertEqual(str(portable_ip_range.startip), str(self.services["portableiprange"]["startip"]),
                          "Listed startip not matching with the startip of created public
ip range")
 
-        self.assertEqual(str(portable_ip_range.endip), str(self.portable_ip_range_services["endip"]),
+        self.assertEqual(str(portable_ip_range.endip), str(self.services["portableiprange"]["endip"]),
                          "Listed endip not matching with the endip of created public ip range")
 
-        self.assertEqual(str(portable_ip_range.gateway), str(self.portable_ip_range_services["gateway"]),
+        self.assertEqual(str(portable_ip_range.gateway), str(self.services["portableiprange"]["gateway"]),
                          "Listed gateway not matching with the gateway of created public
ip range")
 
-        self.assertEqual(str(portable_ip_range.netmask), str(self.portable_ip_range_services["netmask"]),
+        self.assertEqual(str(portable_ip_range.netmask), str(self.services["portableiprange"]["netmask"]),
                          "Listed netmask not matching with the netmask of created public
ip range")
         return
 
@@ -580,7 +532,7 @@ class TestAssociatePublicIp(cloudstackTestCase):
         cls.testClient = super(TestAssociatePublicIp, cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
         cls.services = Services().services
-        cls.config = cls.services
+        cls.services["portableiprange"] = cls.testClient.getParsedTestDataConfig()["portableIpRange"]
         # Get Zone, Domain and templates
         cls.region = get_region(cls.api_client)
         cls.domain = get_domain(cls.api_client)
@@ -590,6 +542,7 @@ class TestAssociatePublicIp(cloudstackTestCase):
         cls.services["domainid"] = cls.domain.id
         cls.services["zoneid"] = cls.zone.id
         cls.services["regionid"] = cls.region.id
+        cls.services["portableiprange"]["regionid"] = cls.region.id
 
         template = get_template(
             cls.api_client,
@@ -641,19 +594,10 @@ class TestAssociatePublicIp(cloudstackTestCase):
     def setUp(self):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
-
         self.cleanup = []
-
-        portable_ip_range_services = getPortableIpRangeServices(self.config)
-
-        if portable_ip_range_services is FAILED:
-            self.skipTest('Failed to read config values related to portable ip range')
-
-        portable_ip_range_services["regionid"] = self.region.id
-
         #create new portable ip range
         self.portable_ip_range = PortablePublicIpRange.create(self.apiclient,
-                                                             portable_ip_range_services)
+                                                              self.services["portableiprange"])
         self.cleanup.append(self.portable_ip_range)
         return
 
@@ -896,7 +840,7 @@ class TestDisassociatePublicIp(cloudstackTestCase):
         cls.testClient = super(TestDisassociatePublicIp, cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
         cls.services = Services().services
-        cls.config = cls.services
+        cls.services["portableiprange"] = cls.testClient.getParsedTestDataConfig()["portableIpRange"]
         # Get Zone, Domain and templates
         cls.region = get_region(cls.api_client)
         cls.domain = get_domain(cls.api_client)
@@ -906,6 +850,7 @@ class TestDisassociatePublicIp(cloudstackTestCase):
         cls.services["domainid"] = cls.domain.id
         cls.services["zoneid"] = cls.zone.id
         cls.services["regionid"] = cls.region.id
+        cls.services["portableiprange"]["regionid"] = cls.region.id
 
         template = get_template(
             cls.api_client,
@@ -977,16 +922,9 @@ class TestDisassociatePublicIp(cloudstackTestCase):
         self.dbclient = self.testClient.getDbConnection()
         self.cleanup = []
 
-        portable_ip_range_services = getPortableIpRangeServices(self.config)
-
-        if portable_ip_range_services is FAILED:
-            self.skipTest('Failed to read config values related to portable ip range')
-
-        portable_ip_range_services["regionid"] = self.region.id
-
         #create new portable ip range
         new_portable_ip_range = PortablePublicIpRange.create(self.apiclient,
-                                                             portable_ip_range_services)
+                                                             self.services["portableiprange"])
         self.cleanup.append(new_portable_ip_range)
         return
 
@@ -1135,7 +1073,7 @@ class TestDeleteAccount(cloudstackTestCase):
         cls.testClient = super(TestDeleteAccount, cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
         cls.services = Services().services
-        cls.config = cls.services
+        cls.services["portableiprange"] = cls.testClient.getParsedTestDataConfig()["portableIpRange"]
         # Get Zone, Domain and templates
         cls.region = get_region(cls.api_client)
         cls.domain = get_domain(cls.api_client)
@@ -1146,6 +1084,7 @@ class TestDeleteAccount(cloudstackTestCase):
         cls.services["domainid"] = cls.domain.id
         cls.services["zoneid"] = cls.zone.id
         cls.services["regionid"] = cls.region.id
+        cls.services["portableiprange"]["regionid"] = cls.region.id
         template = get_template(
             cls.api_client,
             cls.zone.id,
@@ -1171,10 +1110,6 @@ class TestDeleteAccount(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
 
-        portable_ip_range_services = getPortableIpRangeServices(self.config)
-        if portable_ip_range_services is FAILED:
-            self.skipTest('Failed to read config values related to portable ip range')
-
         self.cleanup = []
         try:
             self.account = Account.create(
@@ -1184,10 +1119,10 @@ class TestDeleteAccount(cloudstackTestCase):
                             admin=True
                             )
             self.cleanup.append(self.account)
-            portable_ip_range_services["regionid"] = self.region.id
+            self.debug("portable ip range services: %s" % self.services["portableiprange"])
             #create new portable ip range
             new_portable_ip_range = PortablePublicIpRange.create(self.apiclient,
-                                                             portable_ip_range_services)
+                                                                 self.services["portableiprange"])
             self.cleanup.append(new_portable_ip_range)
             self.network_offering = NetworkOffering.create(
                                             self.apiclient,
@@ -1226,8 +1161,7 @@ class TestDeleteAccount(cloudstackTestCase):
         # 2. Delete account
         # 3. Account should get deleted successfully
 
-        try:
-            portableip = PublicIPAddress.create(
+        portableip = PublicIPAddress.create(
                                     self.apiclient,
                                     accountid=self.account.name,
                                     zoneid=self.zone.id,
@@ -1235,12 +1169,16 @@ class TestDeleteAccount(cloudstackTestCase):
                                     networkid=self.network.id,
                                     isportable=True
                                     )
+        try:
             self.account.delete(self.apiclient)
-            with self.assertRaises(Exception):
-                PublicIPAddress.list(self.apiclient,
-                                 id=portableip.ipaddress.id)
+            self.cleanup.remove(self.account)
         except Exception as e:
+            portableip.delete(self.apiclient)
             self.fail(e)
+
+        listpublicips = PublicIPAddress.list(self.apiclient,
+                                 id=portableip.ipaddress.id)
+        self.assertTrue(listpublicips is None, "list of public ips should be None")
         return
 
     @attr(tags=["advanced", "selfservice"])
@@ -1312,19 +1250,24 @@ class TestDeleteAccount(cloudstackTestCase):
         except Exception as e:
             portableip.delete(self.apiclient)
             self.account.delete(self.apiclient)
+            self.cleanup.remove(self.account)
             self.fail("Error %s" % e)
 
         self.debug("Deleting account: %s :" % self.account.name)
 
-        self.account.delete(self.apiclient)
+        try:
+            self.account.delete(self.apiclient)
+            self.cleanup.remove(self.account)
+        except Exception as e:
+            portableip.delete(self.apiclient)
+            self.fail(e)
 
         self.debug("Trying to list the ip address associated with deleted account, \
                 should throw exception")
 
-        with self.assertRaises(Exception):
-            PublicIPAddress.list(self.apiclient,
+        listpublicips = PublicIPAddress.list(self.apiclient,
                                  id=portableip.ipaddress.id)
-
+        self.assertTrue(listpublicips is None, "list of public ips should be None")
         return
 
 class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
@@ -1337,7 +1280,7 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
         cls.testClient = super(TestPortableIpTransferAcrossNetworks, cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
         cls.services = Services().services
-        cls.config = cls.services
+        cls.services["portableiprange"] = cls.testClient.getParsedTestDataConfig()["portableIpRange"]
         # Get Zone, Domain and templates
         cls.region = get_region(cls.api_client)
         cls.domain = get_domain(cls.api_client)
@@ -1347,6 +1290,7 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
         cls.services["domainid"] = cls.domain.id
         cls.services["zoneid"] = cls.zone.id
         cls.services["regionid"] = cls.region.id
+        cls.services["portableiprange"]["regionid"] = cls.region.id
 
         template = get_template(
             cls.api_client,
@@ -1431,18 +1375,9 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
     def setUp(self):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
-
-        #create new portable ip range
-        self.portable_ip_range_services = getPortableIpRangeServices(self.config)
-
-        if self.portable_ip_range_services is FAILED:
-            self.skipTest('Failed to read config values related to portable ip range')
-
-        self.portable_ip_range_services["regionid"] = self.region.id
-
         #create new portable ip range
         self.portable_ip_range = PortablePublicIpRange.create(self.apiclient,
-                                                             self.portable_ip_range_services)
+                                                              self.services["portableiprange"])
 
         self.cleanup = [self.portable_ip_range, ]
         return

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/613eb121/tools/marvin/marvin/config/test_data.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/config/test_data.py b/tools/marvin/marvin/config/test_data.py
index 19b9aa4..2b60626 100644
--- a/tools/marvin/marvin/config/test_data.py
+++ b/tools/marvin/marvin/config/test_data.py
@@ -871,7 +871,8 @@ test_data = {
         "netmask": "255.255.255.192",
         "startip": "10.223.252.196",
         "endip": "10.223.252.197",
-        "vlan": "1001"
+        "vlan": "1001",
+        "regionid": ""
     },
     "sparse": {
         "name": "Sparse Type Disk offering",

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/613eb121/tools/marvin/marvin/lib/common.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py
index bc6b9c7..187ede6 100644
--- a/tools/marvin/marvin/lib/common.py
+++ b/tools/marvin/marvin/lib/common.py
@@ -1165,42 +1165,6 @@ def createNetworkRulesForVM(apiclient, virtualmachine, ruletype,
         [FAIL, e]
     return [PASS, public_ip]
 
-def getPortableIpRangeServices(config):
-    """ Reads config values related to portable ip and fills up
-    services accordingly"""
-
-    services = {}
-    attributeError = False
-
-    if config["portableIpRange"]["startip"]:
-        services["startip"] = config["portableIpRange"]["startip"]
-    else:
-        attributeError = True
-
-    if config["portableIpRange"]["endip"]:
-        services["endip"] = config["portableIpRange"]["endip"]
-    else:
-        attributeError = True
-
-    if config["portableIpRange"]["netmask"]:
-        services["netmask"] = config["portableIpRange"]["netmask"]
-    else:
-        attributeError = True
-
-    if config["portableIpRange"]["gateway"]:
-        services["gateway"] = config["portableIpRange"]["gateway"]
-    else:
-        attributeError = True
-
-    if config["portableIpRange"]["vlan"]:
-        services["vlan"] = config["portableIpRange"]["vlan"]
-
-    if attributeError:
-        services = FAILED
-
-    return services
-
-
 def uploadVolume(apiclient, zoneid, account, services):
     try:
         # Upload the volume


Mime
View raw message