mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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 <talluri@apache.org>
This commit is contained in:
parent
fa8f0a43c3
commit
a3d08aebb7
@ -18,7 +18,7 @@
|
|||||||
""" Component tests for VPC network functionality - Port Forwarding Rules.
|
""" Component tests for VPC network functionality - Port Forwarding Rules.
|
||||||
"""
|
"""
|
||||||
from nose.plugins.attrib import attr
|
from nose.plugins.attrib import attr
|
||||||
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
|
from marvin.cloudstackTestCase import cloudstackTestCase
|
||||||
from marvin.lib.base import (stopRouter,
|
from marvin.lib.base import (stopRouter,
|
||||||
startRouter,
|
startRouter,
|
||||||
Account,
|
Account,
|
||||||
@ -327,20 +327,31 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
|||||||
else:
|
else:
|
||||||
self.debug("Failed to SSH into VM - %s" % (public_ip.ipaddress.ipaddress))
|
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
|
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))
|
self.debug("Checking if we can wget from a VM=%s http server on public_ip=%s" % (vm.name, public_ip.ipaddress.ipaddress))
|
||||||
try:
|
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")
|
urllib.urlretrieve("http://%s/test.html" % public_ip.ipaddress.ipaddress, filename="test.html")
|
||||||
if not testnegative:
|
if not testnegative:
|
||||||
self.debug("Successesfull to wget from VM=%s http server on public_ip=%s" % (vm.name, public_ip.ipaddress.ipaddress))
|
self.debug("Successesfull to wget from VM=%s http server on public_ip=%s" % (vm.name, public_ip.ipaddress.ipaddress))
|
||||||
else:
|
else:
|
||||||
self.fail("Successesfull to wget from VM=%s http server on public_ip=%s" % (vm.name, public_ip.ipaddress.ipaddress))
|
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:
|
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:
|
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):
|
def create_natrule(self, vm, public_ip, network, services=None):
|
||||||
self.debug("Creating NAT rule in network for vm with public IP")
|
self.debug("Creating NAT rule in network for vm with public IP")
|
||||||
@ -687,7 +698,8 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
|||||||
nat_rule.delete(self.apiclient)
|
nat_rule.delete(self.apiclient)
|
||||||
self.start_vpcrouter(router)
|
self.start_vpcrouter(router)
|
||||||
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
|
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
|
return
|
||||||
|
|
||||||
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
||||||
@ -717,7 +729,8 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
|||||||
http_rule.delete(self.apiclient)
|
http_rule.delete(self.apiclient)
|
||||||
nat_rule.delete(self.apiclient)
|
nat_rule.delete(self.apiclient)
|
||||||
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
|
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
|
return
|
||||||
|
|
||||||
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
@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_2, public_ip_2, testnegative=True)
|
||||||
self.check_ssh_into_vm(vm_3, public_ip_3, 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_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_1, public_ip_1, testnegative=True,
|
||||||
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)
|
self.check_wget_from_vm(vm_2, public_ip_2, testnegative=True,
|
||||||
self.check_wget_from_vm(vm_4, public_ip_4, 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
|
return
|
||||||
|
|
||||||
@attr(tags=["advanced", "intervlan"], required_hardware="true")
|
@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_2, public_ip_2, testnegative=True)
|
||||||
self.check_ssh_into_vm(vm_3, public_ip_3, 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_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_1, public_ip_1, testnegative=True,
|
||||||
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)
|
self.check_wget_from_vm(vm_2, public_ip_2, testnegative=True,
|
||||||
self.check_wget_from_vm(vm_4, public_ip_4, 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
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user