Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 703E5200BB6 for ; Fri, 21 Oct 2016 06:45:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6EC9F160AE0; Fri, 21 Oct 2016 04:45:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8EB46160AFE for ; Fri, 21 Oct 2016 06:45:51 +0200 (CEST) Received: (qmail 99688 invoked by uid 500); 21 Oct 2016 04:45:50 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 98811 invoked by uid 99); 21 Oct 2016 04:45:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Oct 2016 04:45:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 05F52E38EE; Fri, 21 Oct 2016 04:45:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bhaisaab@apache.org To: commits@cloudstack.apache.org Date: Fri, 21 Oct 2016 04:45:52 -0000 Message-Id: <0d82f2b0bf8f4d9484d432d9790a190b@git.apache.org> In-Reply-To: <6358a510b69140d791a3b736a921465e@git.apache.org> References: <6358a510b69140d791a3b736a921465e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [05/17] git commit: updated refs/heads/4.8 to a664e03 archived-at: Fri, 21 Oct 2016 04:45:52 -0000 CLOUDSTACK-9511: fix test_privategw_acl.py to handle multiple physical networks modified script to handle case where there can be multple physical networks in the zone Signed-off-by: Rohit Yadav Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/fcdc2cc5 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/fcdc2cc5 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/fcdc2cc5 Branch: refs/heads/4.8 Commit: fcdc2cc52979e74c6a67c765251c429bf354e90f Parents: 9eb8b2e Author: Murali Reddy Authored: Thu Sep 29 22:41:34 2016 +0530 Committer: Rohit Yadav Committed: Wed Oct 5 15:11:00 2016 +0530 ---------------------------------------------------------------------- test/integration/smoke/test_privategw_acl.py | 62 +++++++++++++++-------- 1 file changed, 41 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fcdc2cc5/test/integration/smoke/test_privategw_acl.py ---------------------------------------------------------------------- diff --git a/test/integration/smoke/test_privategw_acl.py b/test/integration/smoke/test_privategw_acl.py index d2e08f5..3b9e0a7 100644 --- a/test/integration/smoke/test_privategw_acl.py +++ b/test/integration/smoke/test_privategw_acl.py @@ -195,8 +195,9 @@ class TestPrivateGwACL(cloudstackTestCase): def setUp(self): self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() self.hypervisor = self.testClient.getHypervisorInfo() - + self.logger.debug("Creating Admin Account for Domain ID ==> %s" % self.domain.id) self.account = Account.create( self.apiclient, @@ -236,12 +237,16 @@ class TestPrivateGwACL(cloudstackTestCase): self.cleanup = [vpc, vpc_off, self.account] - physical_networks = get_physical_networks(self.apiclient, self.zone.id) - if not physical_networks: + physical_network = self.get_guest_traffic_physical_network(self.apiclient, self.zone.id) + if not physical_network: self.fail("No Physical Networks found!") - vlans = physical_networks[0].vlan.split('-') - vlan_1 = int(vlans[0]) + qresultset = self.dbclient.execute( + "select vnet from op_dc_vnet_alloc where physical_network_id=\ + (select id from physical_network where uuid='%s' ) and taken is NULL;" % physical_network.id + ) + vlans = qresultset + vlan_1 = int(vlans[0][0]) acl = self.createACL(vpc) self.createACLItem(acl.id) @@ -304,12 +309,16 @@ class TestPrivateGwACL(cloudstackTestCase): self.cleanup = [vpc_1, vpc_2, vpc_off, self.account] - physical_networks = get_physical_networks(self.apiclient, self.zone.id) - if not physical_networks: + physical_network = self.get_guest_traffic_physical_network(self.apiclient, self.zone.id) + if not physical_network: self.fail("No Physical Networks found!") - vlans = physical_networks[0].vlan.split('-') - vlan_1 = int(vlans[0]) + qresultset = self.dbclient.execute( + "select vnet from op_dc_vnet_alloc where physical_network_id=\ + (select id from physical_network where uuid='%s' ) and taken is NULL and reservation_id is NULL and account_id is NULL ORDER BY id DESC;" % physical_network.id + ) + vlans = qresultset + vlan_1 = int(vlans[0][0]) network_1 = self.createNetwork(vpc_1, gateway = '10.0.1.1') network_2 = self.createNetwork(vpc_2, gateway = '10.0.2.1') @@ -356,12 +365,15 @@ class TestPrivateGwACL(cloudstackTestCase): self.cleanup = [vpc_1, vpc_off, self.account] - physical_networks = get_physical_networks(self.apiclient, self.zone.id) - if not physical_networks: + physical_network = self.get_guest_traffic_physical_network(self.apiclient, self.zone.id) + if not physical_network: self.fail("No Physical Networks found!") - - vlans = physical_networks[0].vlan.split('-') - vlan_1 = int(vlans[0]) + qresultset = self.dbclient.execute( + "select vnet from op_dc_vnet_alloc where physical_network_id=\ + (select id from physical_network where uuid='%s' ) and taken is NULL;" % physical_network.id + ) + vlans = qresultset + vlan_1 = int(vlans[0][0]) net_offering_no_lb = "network_offering_no_lb" @@ -392,7 +404,7 @@ class TestPrivateGwACL(cloudstackTestCase): public_ip_1 = self.acquire_publicip(vpc_1, network_1) nat_rule_1 = self.create_natrule(vpc_1, vm1, public_ip_1, network_1) - + self.check_private_gateway_interfaces() self.check_pvt_gw_connectivity(vm1, public_ip_1, [vm2.nic[0].ipaddress, vm3.nic[0].ipaddress, vm4.nic[0].ipaddress]) @@ -573,14 +585,14 @@ class TestPrivateGwACL(cloudstackTestCase): return obj_network def createPvtGw(self, vpc, ip_address, gateway, aclId, vlan): - physical_networks = get_physical_networks(self.apiclient, self.zone.id) - if not physical_networks: + physical_network = self.get_guest_traffic_physical_network(self.apiclient, self.zone.id) + if not physical_network: self.fail("No Physical Networks found!") - self.logger.debug('::: Physical Networks ::: ==> %s' % physical_networks) + self.logger.debug('::: Physical Networks ::: ==> %s' % physical_network) createPrivateGatewayCmd = createPrivateGateway.createPrivateGatewayCmd() - createPrivateGatewayCmd.physicalnetworkid = physical_networks[0].id + createPrivateGatewayCmd.physicalnetworkid = physical_network.id createPrivateGatewayCmd.gateway = gateway createPrivateGatewayCmd.netmask = "255.255.255.0" createPrivateGatewayCmd.ipaddress = ip_address @@ -691,13 +703,13 @@ class TestPrivateGwACL(cloudstackTestCase): self.logger.debug("Ping to VM inside another Network Tier") result = str(ssh.execute(ssh_command)) - self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count("3 packets received"))) + self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count("3 received"))) except Exception as e: self.fail("SSH Access failed for %s: %s" % \ (virtual_machine, e) ) - succeeded_pings += result.count("3 packets received") + succeeded_pings += result.count("3 received") self.assertTrue(succeeded_pings >= minimum_vms_to_pass, @@ -831,3 +843,11 @@ class TestPrivateGwACL(cloudstackTestCase): if cnts[vals.index(status_to_check)] != expected_count: self.fail("Expected '%s' routers at state '%s', but found '%s'!" % (expected_count, status_to_check, cnts[vals.index(status_to_check)])) + + def get_guest_traffic_physical_network(self, apiclient, zoneid): + physical_networks = get_physical_networks(apiclient, zoneid) + if not physical_networks: + return None + for physical_network in physical_networks: + if physical_network.vlan: + return physical_network