CLOUDSTACK-3961: multi network test in VPC

Test delete network rules in a VPC. Multiple Fixes
- correct protocol ICMP->TCP
- Remove LB actions from non-lb network
- correct private gateway CIDRs to not overlap with vpc guest cidrs
- remove unrequired SSH on non-lb network
- typos

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
Prasanna Santhanam 2013-08-14 17:01:56 +05:30
parent d7f738fb64
commit d771e3fa5b

View File

@ -137,7 +137,7 @@ class Services:
"startport": 80, "startport": 80,
"endport": 80, "endport": 80,
"cidrlist": '0.0.0.0/0', "cidrlist": '0.0.0.0/0',
"protocol": "ICMP" "protocol": "TCP"
}, },
"virtual_machine": { "virtual_machine": {
"displayname": "Test VM", "displayname": "Test VM",
@ -1973,24 +1973,7 @@ class TestVMDeployVPC(cloudstackTestCase):
network_2.id network_2.id
)) ))
self.debug("Creating LB rule for IP address: %s" % self.debug("Adding NetworkACl rules to make PF accessible")
public_ip_3.ipaddress.ipaddress)
lb_rule = LoadBalancerRule.create(
self.apiclient,
self.services["lbrule"],
ipaddressid=public_ip_3.ipaddress.id,
accountid=self.account.name,
networkid=network_2.id,
vpcid=vpc.id,
domainid=self.account.domainid
)
self.debug("Adding virtual machines %s and %s to LB rule" % (
vm_3.name, vm_4.name))
lb_rule.assign(self.apiclient, [vm_3, vm_4])
self.debug("Adding NetwrokACl rules to make PF and LB accessible")
nwacl_lb = NetworkACL.create( nwacl_lb = NetworkACL.create(
self.apiclient, self.apiclient,
networkid=network_2.id, networkid=network_2.id,
@ -2016,8 +1999,8 @@ class TestVMDeployVPC(cloudstackTestCase):
self.debug("Creating private gateway in VPC: %s" % vpc.name) self.debug("Creating private gateway in VPC: %s" % vpc.name)
private_gateway = PrivateGateway.create( private_gateway = PrivateGateway.create(
self.apiclient, self.apiclient,
gateway='10.1.3.1', gateway='10.2.3.1',
ipaddress='10.1.3.2', ipaddress='10.2.3.2',
netmask='255.255.255.0', netmask='255.255.255.0',
vlan=678, vlan=678,
vpcid=vpc.id vpcid=vpc.id
@ -2036,7 +2019,7 @@ class TestVMDeployVPC(cloudstackTestCase):
self.debug("Creating static route for this gateway") self.debug("Creating static route for this gateway")
static_route = StaticRoute.create( static_route = StaticRoute.create(
self.apiclient, self.apiclient,
cidr='10.1.3.0/24', cidr='10.2.3.0/24',
gatewayid=private_gateway.id gatewayid=private_gateway.id
) )
self.debug("Check if the static route created successfully?") self.debug("Check if the static route created successfully?")
@ -2075,7 +2058,7 @@ class TestVMDeployVPC(cloudstackTestCase):
vpcid=vpc.id vpcid=vpc.id
) )
self.debug("Adding NetwrokACl rules to make NAT rule accessible") self.debug("Adding NetworkACl rules to make NAT rule accessible")
nwacl_nat = NetworkACL.create( nwacl_nat = NetworkACL.create(
self.apiclient, self.apiclient,
networkid=network_2.id, networkid=network_2.id,
@ -2144,24 +2127,7 @@ class TestVMDeployVPC(cloudstackTestCase):
network_2.id network_2.id
)) ))
self.debug("Creating LB rule for IP address: %s" % self.debug("Adding NetwrokACl rules to make PF accessible")
public_ip_7.ipaddress.ipaddress)
lb_rule = LoadBalancerRule.create(
self.apiclient,
self.services["lbrule"],
ipaddressid=public_ip_7.ipaddress.id,
accountid=self.account.name,
networkid=network_2.id,
vpcid=vpc.id,
domainid=self.account.domainid
)
self.debug("Adding virtual machines %s and %s to LB rule" % (
vm_3.name, vm_4.name))
lb_rule.assign(self.apiclient, [vm_3, vm_4])
self.debug("Adding NetwrokACl rules to make PF and LB accessible")
nwacl_lb = NetworkACL.create( nwacl_lb = NetworkACL.create(
self.apiclient, self.apiclient,
networkid=network_2.id, networkid=network_2.id,
@ -2187,8 +2153,8 @@ class TestVMDeployVPC(cloudstackTestCase):
self.debug("Creating private gateway in VPC: %s" % vpc.name) self.debug("Creating private gateway in VPC: %s" % vpc.name)
private_gateway = PrivateGateway.create( private_gateway = PrivateGateway.create(
self.apiclient, self.apiclient,
gateway='10.1.4.1', gateway='10.2.4.1',
ipaddress='10.1.4.2', ipaddress='10.2.4.2',
netmask='255.255.255.0', netmask='255.255.255.0',
vlan=678, vlan=678,
vpcid=vpc.id vpcid=vpc.id
@ -2207,7 +2173,7 @@ class TestVMDeployVPC(cloudstackTestCase):
self.debug("Creating static route for this gateway") self.debug("Creating static route for this gateway")
static_route = StaticRoute.create( static_route = StaticRoute.create(
self.apiclient, self.apiclient,
cidr='10.1.4.0/24', cidr='10.2.4.0/24',
gatewayid=private_gateway.id gatewayid=private_gateway.id
) )
self.debug("Check if the static route created successfully?") self.debug("Check if the static route created successfully?")
@ -2281,32 +2247,10 @@ class TestVMDeployVPC(cloudstackTestCase):
"Ping to outside world from VM should be successful" "Ping to outside world from VM should be successful"
) )
self.debug("Checking if we can SSH into VM using LB rule?")
try:
ssh_3 = vm_3.get_ssh_client(
ipaddress=public_ip_3.ipaddress.ipaddress,
reconnect=True,
port=self.services["lbrule"]["publicport"]
)
self.debug("SSH into VM is successfully")
self.debug("Verifying if we can ping to outside world from VM?")
res = ssh_3.execute("ping -c 1 www.google.com")
except Exception as e:
self.fail("Failed to SSH into VM - %s, %s" %
(public_ip_3.ipaddress.ipaddress, e))
result = str(res)
self.assertEqual(
result.count("1 received"),
1,
"Ping to outside world from VM should be successful"
)
self.debug("Trying to delete network: %s" % network_1.name) self.debug("Trying to delete network: %s" % network_1.name)
with self.assertRaises(Exception): with self.assertRaises(Exception):
network_1.delete(self.apiclient) network_1.delete(self.apiclient)
self.debug("Delete netwpork failed as there are running instances") self.debug("Delete network failed as there are running instances")
self.debug("Destroying all the instances in network1: %s" % self.debug("Destroying all the instances in network1: %s" %
network_1.name) network_1.name)
@ -2394,28 +2338,6 @@ class TestVMDeployVPC(cloudstackTestCase):
"Ping to outside world from VM should be successful" "Ping to outside world from VM should be successful"
) )
self.debug("Checking if we can SSH into VM using LB rule?")
try:
ssh_6 = vm_3.get_ssh_client(
ipaddress=public_ip_7.ipaddress.ipaddress,
reconnect=True,
port=self.services["lbrule"]["publicport"]
)
self.debug("SSH into VM is successfully")
self.debug("Verifying if we can ping to outside world from VM?")
res = ssh_6.execute("ping -c 1 www.google.com")
except Exception as e:
self.fail("Failed to SSH into VM - %s, %s" %
(public_ip_7.ipaddress.ipaddress, e))
result = str(res)
self.assertEqual(
result.count("1 received"),
1,
"Ping to outside world from VM should be successful"
)
self.debug("Deleting the account..") self.debug("Deleting the account..")
try: try:
self.account.delete(self.apiclient) self.account.delete(self.apiclient)