You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ta...@apache.org on 2014/11/10 12:38:22 UTC

git commit: updated refs/heads/4.5 to 23df5f2

Repository: cloudstack
Updated Branches:
  refs/heads/4.5 2f7959d21 -> 23df5f22a


CLOUDSTACK-7856: test_vpc_network_pf_rules.py - Check if httpd service is running or not, if not, start it

Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>


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

Branch: refs/heads/4.5
Commit: 23df5f22ac96bf8032d10a5b65c6016534d67fcb
Parents: 2f7959d
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Thu Nov 6 18:23:08 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Mon Nov 10 17:07:46 2014 +0530

----------------------------------------------------------------------
 .../component/test_vpc_network_pfrules.py       | 51 ++++++++++++++------
 1 file changed, 36 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/23df5f22/test/integration/component/test_vpc_network_pfrules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_network_pfrules.py b/test/integration/component/test_vpc_network_pfrules.py
index c3a8161..e49642b 100644
--- a/test/integration/component/test_vpc_network_pfrules.py
+++ b/test/integration/component/test_vpc_network_pfrules.py
@@ -18,7 +18,7 @@
 """ Component tests for VPC network functionality - Port Forwarding Rules.
 """
 from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import cloudstackTestCase, unittest
+from marvin.cloudstackTestCase import cloudstackTestCase
 from marvin.lib.base import (stopRouter,
                                          startRouter,
                                          Account,
@@ -327,20 +327,31 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
                 else:
                     self.debug("Failed to SSH into VM - %s" % (public_ip.ipaddress.ipaddress))
 
-    def check_wget_from_vm(self, vm, public_ip, testnegative=False):
+    def check_wget_from_vm(self, vm, public_ip, network=None, testnegative=False, isVmAccessible=True):
         import urllib
         self.debug("Checking if we can wget from a VM=%s http server on public_ip=%s"  % (vm.name, public_ip.ipaddress.ipaddress))
         try:
+                if not isVmAccessible:
+                    self.create_natrule(vm, public_ip, network)
+                # Start httpd service on VM first
+                sshClient = vm.get_ssh_client()
+                sshClient.execute("service httpd start")
+                time.sleep(5)
+                ssh_response = str(sshClient.execute("service httpd status")).lower()
+                self.debug("httpd service status is: %s" % ssh_response)
+                if not "running" in ssh_response:
+                    raise Exception("Failed to start httpd service")
+
                 urllib.urlretrieve("http://%s/test.html" % public_ip.ipaddress.ipaddress, filename="test.html")
                 if not testnegative:
                     self.debug("Successesfull to wget from VM=%s http server on public_ip=%s" % (vm.name, public_ip.ipaddress.ipaddress))
                 else:
                     self.fail("Successesfull to wget from VM=%s http server on public_ip=%s" % (vm.name, public_ip.ipaddress.ipaddress))
-        except:
+        except Exception as e:
                 if not testnegative:
-                    self.fail("Failed to wget from VM=%s http server on public_ip=%s" % (vm.name, public_ip.ipaddress.ipaddress))
+                    self.fail("Failed to wget from VM=%s http server on public_ip=%s: %s" % (vm.name, public_ip.ipaddress.ipaddress, e))
                 else:
-                    self.debug("Failed to wget from VM=%s http server on public_ip=%s" % (vm.name, public_ip.ipaddress.ipaddress))
+                    self.debug("Failed to wget from VM=%s http server on public_ip=%s: %s" % (vm.name, public_ip.ipaddress.ipaddress, e))
 
     def create_natrule(self, vm, public_ip, network, services=None):
         self.debug("Creating NAT rule in network for vm with public IP")
@@ -687,7 +698,8 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
         nat_rule.delete(self.apiclient)
         self.start_vpcrouter(router)
         self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
-        self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
+        self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True,
+                isVmAccessible=False, network=network_1)
         return
 
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
@@ -717,7 +729,8 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
         http_rule.delete(self.apiclient)
         nat_rule.delete(self.apiclient)
         self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
-        self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
+        self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True,
+                isVmAccessible=False, network=network_1)
         return
 
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
@@ -781,10 +794,14 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
         self.check_ssh_into_vm(vm_2, public_ip_2, testnegative=True)
         self.check_ssh_into_vm(vm_3, public_ip_3, testnegative=True)
         self.check_ssh_into_vm(vm_4, public_ip_4, testnegative=True)
-        self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
-        self.check_wget_from_vm(vm_2, public_ip_2, testnegative=True)
-        self.check_wget_from_vm(vm_3, public_ip_3, testnegative=True)
-        self.check_wget_from_vm(vm_4, public_ip_4, testnegative=True)
+        self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True,
+                isVmAccessible=False, network=network_1)
+        self.check_wget_from_vm(vm_2, public_ip_2, testnegative=True,
+                isVmAccessible=False, network=network_1)
+        self.check_wget_from_vm(vm_3, public_ip_3, testnegative=True,
+                isVmAccessible=False, network=network_2)
+        self.check_wget_from_vm(vm_4, public_ip_4, testnegative=True,
+                isVmAccessible=False, network=network_2)
         return
 
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
@@ -843,8 +860,12 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
         self.check_ssh_into_vm(vm_2, public_ip_2, testnegative=True)
         self.check_ssh_into_vm(vm_3, public_ip_3, testnegative=True)
         self.check_ssh_into_vm(vm_4, public_ip_4, testnegative=True)
-        self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
-        self.check_wget_from_vm(vm_2, public_ip_2, testnegative=True)
-        self.check_wget_from_vm(vm_3, public_ip_3, testnegative=True)
-        self.check_wget_from_vm(vm_4, public_ip_4, testnegative=True)
+        self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True,
+                isVmAccessible=False, network=network_1)
+        self.check_wget_from_vm(vm_2, public_ip_2, testnegative=True,
+                isVmAccessible=False, network=network_1)
+        self.check_wget_from_vm(vm_3, public_ip_3, testnegative=True,
+                isVmAccessible=False, network=network_2)
+        self.check_wget_from_vm(vm_4, public_ip_4, testnegative=True,
+                isVmAccessible=False, network=network_2)
         return