added integration tests for testing portable ip ranges
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ecca117e Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ecca117e Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ecca117e Branch: refs/heads/portablepublicip Commit: ecca117e345224059297f5c1ffa0f442209b3160 Parents: 895a27c Author: Murali Reddy <[email protected]> Authored: Mon May 13 20:05:29 2013 +0530 Committer: Murali Reddy <[email protected]> Committed: Mon May 13 20:05:29 2013 +0530 ---------------------------------------------------------------------- test/integration/smoke/test_portable_publicip.py | 237 +++++++++++++++++ tools/marvin/marvin/integration/lib/base.py | 36 +++ 2 files changed, 273 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ecca117e/test/integration/smoke/test_portable_publicip.py ---------------------------------------------------------------------- diff --git a/test/integration/smoke/test_portable_publicip.py b/test/integration/smoke/test_portable_publicip.py new file mode 100644 index 0000000..101747d --- /dev/null +++ b/test/integration/smoke/test_portable_publicip.py @@ -0,0 +1,237 @@ +#!/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: + """Test Data + """ + + def __init__(self): + self.services = { + "domain": { + "name": "Domain", + }, + "account": { + "email": "[email protected]", + "firstname": "Test", + "lastname": "User", + "username": "test", + # Random characters are appended for unique + # username + "password": "password", + }, + "service_offering": { + "name": "Tiny Instance", + "displaytext": "Tiny Instance", + "cpunumber": 1, + "cpuspeed": 100, + # in MHz + "memory": 128, + # In MBs + }, + "network_offering": { + "name": 'Test Network offering', + "displaytext": 'Test Network offering', + "guestiptype": 'Isolated', + "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding', + "traffictype": 'GUEST', + "availability": 'Optional', + "serviceProviderList" : { + "Dhcp": 'VirtualRouter', + "Dns": 'VirtualRouter', + "SourceNat": 'VirtualRouter', + "PortForwarding": 'VirtualRouter', + }, + }, + "network": { + "name": "Test Network", + "displaytext": "Test Network", + }, + "ostype": 'CentOS 5.3 (64-bit)', + "gateway" : "10.1.1.1", + "netmask" : "255.255.255.0", + "startip" : "10.1.1.10", + "endip" : "10.1.1.20", + "regionid" : "1", + "vlan" :"10", + "isportable" : "true", + "virtual_machine" : { + "affinity": { + "name": "webvms", + "type": "host anti-affinity", + }, + "hypervisor" : "XenServer", + } + } + +class TestPortablePublicIPRange(cloudstackTestCase): + + """ + This test validates functionality where + - admin can provision a portable public ip range + - list provisioned portable public ip range + - delete provisioned portable public ip range + """ + @classmethod + def setUpClass(cls): + cls.api_client = super(TestPortablePublicIPRange, cls).getClsTestClient().getApiClient() + cls.services = Services().services + # Get Zone, Domain + cls.domain = get_domain(cls.api_client, cls.services) + cls.zone = get_zone(cls.api_client, cls.services) + + # Create Account + cls.account = Account.create( + cls.api_client, + cls.services["account"], + domainid=cls.domain.id + ) + cls._cleanup = [ + cls.account, + ] + return + + @classmethod + def tearDownClass(cls): + try: + # Cleanup resources used + cleanup_resources(cls.api_client, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() + self.cleanup = [] + return + + def tearDown(self): + try: + # Clean up + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + @attr(tags = ["simulator", "basic", "advanced", "portablepublicip"]) + def test_createPortablePublicIPRange(self): + """ + """ + self.debug("attempting to create a portable Public IP range") + self.portable_ip_range = PortablePublicIpRange.create( + self.api_client, + self.services + ) + self.debug("attempting to verify portable Public IP range is created") + list_portbale_ip_range_response = PortablePublicIpRange.list( + self.apiclient, + id=self.portable_ip_range.id + ) + self.portable_ip_range.delete(self.apiclient) + return + + +class TestPortablePublicIPAcquire(cloudstackTestCase): + + """ + This test validates functionality where + - admin has provisioned a portable public ip range + - user can acquire portable ip from the provisioned ip range + """ + @classmethod + def setUpClass(cls): + cls.api_client = super(TestPortablePublicIPAcquire, cls).getClsTestClient().getApiClient() + cls.services = Services().services + # Get Zone, Domain + cls.domain = get_domain(cls.api_client, cls.services) + cls.zone = get_zone(cls.api_client, cls.services) + # Create Account + cls.account = Account.create( + cls.api_client, + cls.services["account"], + domainid=cls.domain.id + ) + cls.services["network"]["zoneid"] = cls.zone.id + + cls.network_offering = NetworkOffering.create( + cls.api_client, + cls.services["network_offering"], + ) + # Enable Network offering + cls.network_offering.update(cls.api_client, state='Enabled') + + cls.services["network"]["networkoffering"] = cls.network_offering.id + cls.account_network = Network.create( + cls.api_client, + cls.services["network"], + cls.account.name, + cls.account.domainid + ) + cls._cleanup = [ + cls.account_network, + cls.network_offering, + cls.account + ] + + return + + @classmethod + def tearDownClass(cls): + try: + # Cleanup resources used + cleanup_resources(cls.api_client, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() + self.cleanup = [] + return + + def tearDown(self): + try: + # Clean up + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + @attr(tags = ["simulator", "basic", "advanced", "portablepublicip"]) + def test_createPortablePublicIPAcquire(self): + """ + """ + self.debug("attempting to create a portable Public IP range") + self.portable_ip_range = PortablePublicIpRange.create( + self.api_client, + self.services + ) + + ip_address = PublicIPAddress.create(self.api_client, self.account.name, self.zone.id, self.account.domainid) + + self.portable_ip_range.delete(self.apiclient) + return \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ecca117e/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 ecdc841..27c7703 100755 --- a/tools/marvin/marvin/integration/lib/base.py +++ b/tools/marvin/marvin/integration/lib/base.py @@ -2126,6 +2126,42 @@ class PublicIpRange: cmd.id = self.vlan.id return apiclient.releasePublicIpRange(cmd) + +class PortablePublicIpRange: + """Manage portable public Ip Range""" + + def __init__(self, items): + self.__dict__.update(items) + + @classmethod + def create(cls, apiclient, services): + """Create portable public Ip Range""" + + cmd = createPortableIpRange.createPortableIpRangeCmd() + cmd.gateway = services["gateway"] + cmd.netmask = services["netmask"] + cmd.startip = services["startip"] + cmd.endip = services["endip"] + cmd.regionid = services["regionid"] + cmd.vlan = services["vlan"] + + return PortablePublicIpRange(apiclient.createVlanIpRange(cmd).__dict__) + + def delete(self, apiclient): + """Delete portable IpRange""" + + cmd = deletePortableIpRange.deletePortableIpRangeCmd() + cmd.id = self.id + apiclient.deletePortableIpRange(cmd) + + @classmethod + def list(cls, apiclient, **kwargs): + """Lists all portable public IP ranges.""" + + cmd = listPortableIpRanges.listPortableIpRangesCmd() + [setattr(cmd, k, v) for k, v in kwargs.items()] + return(apiclient.listPortableIpRanges(cmd)) + class SecondaryStorage: """Manage Secondary storage"""
