cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gir...@apache.org
Subject [1/2] git commit: updated refs/heads/master to 2231fc8
Date Mon, 04 Aug 2014 05:32:21 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master c792f149f -> 2231fc892


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

This reverts commit 613eb12104af5c27935091127a1a19941f96e336.


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

Branch: refs/heads/master
Commit: 98e2a0444f74e3e8f6993319c822cc12bc491931
Parents: c792f14
Author: Girish Shilamkar <girish@clogeny.com>
Authored: Mon Aug 4 11:01:09 2014 +0530
Committer: Girish Shilamkar <girish@clogeny.com>
Committed: Mon Aug 4 11:01:09 2014 +0530

----------------------------------------------------------------------
 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, 152 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/98e2a044/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 a4f8416..a93b883 100644
--- a/tools/marvin/marvin/config/test_data.py
+++ b/tools/marvin/marvin/config/test_data.py
@@ -886,8 +886,7 @@ test_data = {
         "netmask": "255.255.255.192",
         "startip": "10.223.252.196",
         "endip": "10.223.252.197",
-        "vlan": "1001",
-        "regionid": ""
+        "vlan": "1001"
     },
     "sparse": {
         "name": "Sparse Type Disk offering",

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/98e2a044/tools/marvin/marvin/lib/common.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py
index 187ede6..bc6b9c7 100644
--- a/tools/marvin/marvin/lib/common.py
+++ b/tools/marvin/marvin/lib/common.py
@@ -1165,6 +1165,42 @@ 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