From 632ee18ab709f0d0255796e50198ec8fd97e968a Mon Sep 17 00:00:00 2001 From: Wilder Rodrigues Date: Thu, 10 Dec 2015 13:27:53 +0100 Subject: [PATCH 1/3] CLOUDSTACK-9135 - Moves test into smoke directory - Missed this test when moved the other 5 ones. --- test/integration/smoke/test_internal_lb.py | 134 ++++++++++++++---- .../test_password_server.py | 0 2 files changed, 107 insertions(+), 27 deletions(-) rename test/integration/{component => smoke}/test_password_server.py (100%) diff --git a/test/integration/smoke/test_internal_lb.py b/test/integration/smoke/test_internal_lb.py index 0807b2a8680..7f03eb1a1d5 100644 --- a/test/integration/smoke/test_internal_lb.py +++ b/test/integration/smoke/test_internal_lb.py @@ -128,7 +128,7 @@ class Services: }, "egress_policy": "true", }, - "vpc_offering": { + "redundant_vpc_offering": { "name": 'Redundant VPC off', "displaytext": 'Redundant VPC off', "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat', @@ -149,6 +149,12 @@ class Services: } }, }, + "vpc_offering": { + "name": "VPC off", + "displaytext": "VPC off", + "supportedservices": + "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,NetworkACL" + }, "vpc": { "name": "TestVPC", "displaytext": "TestVPC", @@ -286,9 +292,12 @@ class TestInternalLb(cloudstackTestCase): %s" % (cls.account.name, cls.account.id)) - cls.cleanup = [cls.template, cls.account, cls.compute_offering] + cls._cleanup = [cls.template, cls.account, cls.compute_offering] return + def setUp(self): + self.cleanup = [] + def get_networkoffering_state(self, offering): result = list_network_offerings(self.apiclient, id=offering.id) if result: @@ -314,39 +323,34 @@ class TestInternalLb(cloudstackTestCase): offering), "Enabled", "Failed to enable network offering") self.logger.debug("Enabled network offering: %s" % offering.id) + + self.cleanup.insert(0, offering) return offering except Exception as e: - self.fail("Failed to create and enable network offering: %s because of %s" % ( - offering_name, e)) + self.fail("Failed to create and enable network offering due to %s" % e) - def create_vpc(self, name, cidr): - print name, cidr + def create_vpc(self, vpc_offering): + self.logger.debug("Creating VPC using offering ==> ID %s / Name %s" % (vpc_offering.id, vpc_offering.name)) try: - vpcOffering = VpcOffering.list(self.apiclient, isdefault=True) - self.assert_(vpcOffering is not None and len( - vpcOffering) > 0, "No VPC offerings found") - - self.services["vpc"] = {} - self.services["vpc"]["name"] = name - self.services["vpc"]["displaytext"] = name - self.services["vpc"]["cidr"] = cidr - vpc = VPC.create( apiclient=self.apiclient, services=self.services["vpc"], networkDomain="vpc.internallb", - vpcofferingid=vpcOffering[0].id, + vpcofferingid=vpc_offering.id, zoneid=self.zone.id, account=self.account.name, domainid=self.domain.id ) + self.assertIsNotNone(vpc, "VPC creation failed") self.logger.debug("Created VPC %s" % vpc.id) + + self.cleanup.insert(0, vpc) return vpc except Exception as e: - self.fail("Failed to create VPC: %s due to %s" % (name, e)) + self.fail("Failed to create VPC due to %s" % e) def create_network_tier(self, name, vpcid, gateway, network_offering): self.services["network"]["name"] = name @@ -367,10 +371,12 @@ class TestInternalLb(cloudstackTestCase): netmask=self.services["network"]["netmask"], aclid=default_acl.id ) + self.assertIsNotNone(network, "Network failed to create") self.logger.debug( "Created network %s in VPC %s" % (network.id, vpcid)) + self.cleanup.insert(0, network) return network except Exception as e: @@ -393,6 +399,7 @@ class TestInternalLb(cloudstackTestCase): self.assert_(vm.state == 'Running', "VM is not running") self.logger.debug("Deployed VM id: %s in VPC %s" % (vm.id, vpc.id)) + self.cleanup.insert(0, vm) return vm except Exception as e: @@ -565,8 +572,41 @@ class TestInternalLb(cloudstackTestCase): @attr(tags=["smoke", "advanced"], required_hardware="true") def test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80(self): - """Test create, assign, remove of an Internal LB with roundrobin http traffic to 3 vm's """ + Test create, assign, remove of an Internal LB with roundrobin http traffic to 3 vm's in a Single VPC + """ + self.logger.debug("Starting test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80") + + self.logger.debug("Creating a VPC offering..") + vpc_offering = VpcOffering.create( + self.apiclient, + self.services["vpc_offering"]) + + self.logger.debug("Enabling the VPC offering created") + vpc_offering.update(self.apiclient, state='Enabled') + + self.cleanup.insert(0, vpc_offering) + self.execute_internallb_roundrobin_tests(vpc_offering) + + @attr(tags=["smoke", "advanced"], required_hardware="true") + def test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80(self): + """ + Test create, assign, remove of an Internal LB with roundrobin http traffic to 3 vm's in a Redundant VPC + """ + self.logger.debug("Starting test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80") + + self.logger.debug("Creating a Redundant VPC offering..") + redundant_vpc_offering = VpcOffering.create( + self.apiclient, + self.services["redundant_vpc_offering"]) + + self.logger.debug("Enabling the Redundant VPC offering created") + redundant_vpc_offering.update(self.apiclient, state='Enabled') + + self.cleanup.insert(0, redundant_vpc_offering) + self.execute_internallb_roundrobin_tests(redundant_vpc_offering) + + def execute_internallb_roundrobin_tests(self, vpc_offering): max_http_requests = 30 algorithm = "roundrobin" public_lb_port = 80 @@ -582,7 +622,7 @@ class TestInternalLb(cloudstackTestCase): self.services["network_offering_internal_lb"]) # Create VPC - vpc = self.create_vpc("vpc_intlb_test01", "10.1.0.0/16") + vpc = self.create_vpc(vpc_offering) # Create network tiers network_guestnet = self.create_network_tier( @@ -692,14 +732,48 @@ class TestInternalLb(cloudstackTestCase): return False @attr(tags=["smoke", "advanced"], required_hardware="true") - def test02_internallb_haproxy_stats_on_all_interfaces(self): + def test_03_vpc_internallb_haproxy_stats_on_all_interfaces(self): """ Test to verify access to loadbalancer haproxy admin stats page when global setting network.loadbalancer.haproxy.stats.visibility is set to 'all' with credentials from global setting network.loadbalancer.haproxy.stats.auth - using the uri from global setting network.loadbalancer.haproxy.stats.uri""" + using the uri from global setting network.loadbalancer.haproxy.stats.uri. - self.logger.debug( - "Starting test_02_internallb_haproxy_stats_on_all_interfaces") + It uses a Single Router VPC + """ + self.logger.debug("Starting test_03_vpc_internallb_haproxy_stats_on_all_interfaces") + + self.logger.debug("Creating a VPC offering..") + vpc_offering = VpcOffering.create( + self.apiclient, + self.services["vpc_offering"]) + + self.logger.debug("Enabling the VPC offering created") + vpc_offering.update(self.apiclient, state='Enabled') + + self.execute_internallb_haproxy_tests(vpc_offering) + + @attr(tags=["smoke", "advanced"], required_hardware="true") + def test_04_rvpc_internallb_haproxy_stats_on_all_interfaces(self): + """ Test to verify access to loadbalancer haproxy admin stats page + when global setting network.loadbalancer.haproxy.stats.visibility is set to 'all' + with credentials from global setting network.loadbalancer.haproxy.stats.auth + using the uri from global setting network.loadbalancer.haproxy.stats.uri. + + It uses a Redundant Routers VPC + """ + self.logger.debug("Starting test_04_rvpc_internallb_haproxy_stats_on_all_interfaces") + + self.logger.debug("Creating a Redundant VPC offering..") + redundant_vpc_offering = VpcOffering.create( + self.apiclient, + self.services["redundant_vpc_offering"]) + + self.logger.debug("Enabling the Redundant VPC offering created") + redundant_vpc_offering.update(self.apiclient, state='Enabled') + + self.execute_internallb_haproxy_tests(redundant_vpc_offering) + + def execute_internallb_haproxy_tests(self, vpc_offering): settings = self.get_lb_stats_settings() @@ -720,7 +794,7 @@ class TestInternalLb(cloudstackTestCase): self.services["network_offering_internal_lb"]) # Create VPC - vpc = self.create_vpc("vpc_intlb_test_02", "10.1.0.0/16") + vpc = self.create_vpc(vpc_offering) # Create network tier with internal lb service enabled network_internal_lb = self.create_network_tier( @@ -757,8 +831,14 @@ class TestInternalLb(cloudstackTestCase): @classmethod def tearDownClass(cls): try: - cls.logger.debug("Cleaning up testcase resources") - cleanup_resources(cls.apiclient, cls.cleanup) - + cls.logger.debug("Cleaning up class resources") + cleanup_resources(cls.apiclient, cls._cleanup) + except Exception as e: + raise Exception("Cleanup failed with %s" % e) + + def tearDown(self): + try: + self.logger.debug("Cleaning up test resources") + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Cleanup failed with %s" % e) diff --git a/test/integration/component/test_password_server.py b/test/integration/smoke/test_password_server.py similarity index 100% rename from test/integration/component/test_password_server.py rename to test/integration/smoke/test_password_server.py From 590af145b0c703f9c957c6f81ef450856dc2c407 Mon Sep 17 00:00:00 2001 From: Wilder Rodrigues Date: Fri, 11 Dec 2015 15:02:55 +0100 Subject: [PATCH 2/3] CLOUDSTACK-9135 - Makes possible to add multiple providers per service - Same is done in the Java side. Check the createVpcOffering() method in the VpcManagerImpl class --- tools/marvin/marvin/lib/base.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 4b04e778bd4..ab15a78c4ea 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -4055,17 +4055,25 @@ class VpcOffering: @classmethod def create(cls, apiclient, services): """Create vpc offering""" - + + import logging + cmd = createVPCOffering.createVPCOfferingCmd() cmd.name = "-".join([services["name"], random_gen()]) cmd.displaytext = services["displaytext"] cmd.supportedServices = services["supportedservices"] if "serviceProviderList" in services: for service, provider in services["serviceProviderList"].items(): - cmd.serviceproviderlist.append({ - 'service': service, - 'provider': provider - }) + providers = provider + if isinstance(provider, str): + providers = [provider] + + for provider_item in providers: + cmd.serviceproviderlist.append({ + 'service': service, + 'provider': provider_item + }) + if "serviceCapabilityList" in services: cmd.servicecapabilitylist = [] for service, capability in \ From 43ce049d43ce7aa0e4d25b0630cbcd1c423156b9 Mon Sep 17 00:00:00 2001 From: Wilder Rodrigues Date: Fri, 11 Dec 2015 15:03:50 +0100 Subject: [PATCH 3/3] CLOUDSTACK-9135 - Makes test compliant with Redundant VPCs --- test/integration/smoke/test_internal_lb.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/integration/smoke/test_internal_lb.py b/test/integration/smoke/test_internal_lb.py index 7f03eb1a1d5..c4be42b6702 100644 --- a/test/integration/smoke/test_internal_lb.py +++ b/test/integration/smoke/test_internal_lb.py @@ -137,8 +137,8 @@ class Services: "Dhcp": 'VpcVirtualRouter', "Dns": 'VpcVirtualRouter', "SourceNat": 'VpcVirtualRouter', + "Lb" : ["InternalLbVm", "VpcVirtualRouter"], "PortForwarding": 'VpcVirtualRouter', - "Lb": 'VpcVirtualRouter', "UserData": 'VpcVirtualRouter', "StaticNat": 'VpcVirtualRouter', "NetworkACL": 'VpcVirtualRouter' @@ -146,14 +146,24 @@ class Services: "serviceCapabilityList": { "SourceNat": { "RedundantRouter": 'true' - } + }, }, }, "vpc_offering": { "name": "VPC off", "displaytext": "VPC off", - "supportedservices": - "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,NetworkACL" + "supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,NetworkACL", + "serviceProviderList": { + "Vpn": 'VpcVirtualRouter', + "Dhcp": 'VpcVirtualRouter', + "Dns": 'VpcVirtualRouter', + "SourceNat": 'VpcVirtualRouter', + "Lb" : ["InternalLbVm", "VpcVirtualRouter"], + "PortForwarding": 'VpcVirtualRouter', + "UserData": 'VpcVirtualRouter', + "StaticNat": 'VpcVirtualRouter', + "NetworkACL": 'VpcVirtualRouter' + }, }, "vpc": { "name": "TestVPC",