From d4dc4f7e70159609f51cf66a032073e31b23eb97 Mon Sep 17 00:00:00 2001 From: Girish Shilamkar Date: Fri, 13 Sep 2013 20:43:45 -0400 Subject: [PATCH] CLOUDSTACK-4637: Add 30sec sleep before router is ssh'd Egress rules testcases access vm via router. Sleep before accessing router else the expect fails since router is not accessible. Also use router.hostid instead of vm.hostid to identify the host. Signed-off-by: venkataswamybabu budumuru (cherry picked from commit 7d06e77ed9bfacf6d3b74f396c705567d4bf8ba2) --- .../component/test_egress_fw_rules.py | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/test/integration/component/test_egress_fw_rules.py b/test/integration/component/test_egress_fw_rules.py index ef0fc5a7e9c..5c18f9c10a2 100644 --- a/test/integration/component/test_egress_fw_rules.py +++ b/test/integration/component/test_egress_fw_rules.py @@ -18,7 +18,7 @@ """ """ #Import Local Modules -#import unittest +import unittest from nose.plugins.attrib import attr from marvin.cloudstackTestCase import cloudstackTestCase from marvin.integration.lib.base import (Account, @@ -198,7 +198,6 @@ class TestEgressFWRules(cloudstackTestCase): # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - def create_vm(self, pfrule=False, egress_policy=True, RR=False): self.create_network_offering(egress_policy, RR) # Creating network using the network offering created @@ -229,20 +228,7 @@ class TestEgressFWRules(cloudstackTestCase): def exec_script_on_user_vm(self, script, exec_cmd_params, expected_result, negative_test=False): try: - if self.apiclient.hypervisor.lower() == 'vmware': - #SSH is done via management server for Vmware - sourceip = self.apiclient.connection.mgtSvr - else: - #For others, we will have to get the ipaddress of host connected to vm - hosts = list_hosts(self.apiclient, - id=self.virtual_machine.hostid) - self.assertEqual(isinstance(hosts, list), - True, - "Check list response returns a valid list") - host = hosts[0] - sourceip = host.ipaddress - #Once host or mgt server is reached, SSH to the router connected to VM - # look for Router for Cloudstack VM network. + vm_network_id = self.virtual_machine.nic[0].networkid vm_ipaddress = self.virtual_machine.nic[0].ipaddress list_routers_response = list_routers(self.apiclient, @@ -253,6 +239,26 @@ class TestEgressFWRules(cloudstackTestCase): True, "Check for list routers response return valid data") router = list_routers_response[0] + + #Once host or mgt server is reached, SSH to the router connected to VM + # look for Router for Cloudstack VM network. + if self.apiclient.hypervisor.lower() == 'vmware': + #SSH is done via management server for Vmware + sourceip = self.apiclient.connection.mgtSvr + else: + #For others, we will have to get the ipaddress of host connected to vm + hosts = list_hosts(self.apiclient, + id=router.hostid) + self.assertEqual(isinstance(hosts, list), + True, + "Check list response returns a valid list") + host = hosts[0] + sourceip = host.ipaddress + + self.debug("Sleep %s seconds for network on router to be up" + % self.services['sleep']) + time.sleep(self.services['sleep']) + if self.apiclient.hypervisor.lower() == 'vmware': key_file = " -i /var/cloudstack/management/.ssh/id_rsa " else: @@ -266,7 +272,6 @@ class TestEgressFWRules(cloudstackTestCase): "expect \"root@%s's password: \"\n" % (vm_ipaddress) + \ "send \"password\r\"\n" + \ "interact\n" - self.debug("expect_script>>\n%s<