mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4637: Fix failures in test_egress_fw_rules.py
Removed log_test_exceptions which did not add any value. Skipped few tests which are incomplete. Added timeout logic and to wait for router to boot.
This commit is contained in:
parent
ec3302afd6
commit
a65f1ebefc
|
|
@ -42,16 +42,6 @@ from marvin.cloudstackAPI.deleteEgressFirewallRule import deleteEgressFirewallRu
|
|||
from marvin.remoteSSHClient import remoteSSHClient
|
||||
import time
|
||||
|
||||
def log_test_exceptions(func):
|
||||
def test_wrap_exception_log(self, *args, **kwargs):
|
||||
try:
|
||||
func(self, *args, **kwargs)
|
||||
except Exception as e:
|
||||
self.debug('Test %s Failed due to Exception=%s' % (func, e))
|
||||
raise e
|
||||
test_wrap_exception_log.__doc__ = func.__doc__
|
||||
return test_wrap_exception_log
|
||||
|
||||
class Services:
|
||||
"""Test service data: Egress Firewall rules Tests for Advance Zone.
|
||||
"""
|
||||
|
|
@ -117,6 +107,7 @@ class Services:
|
|||
"serviceCapabilityList": {
|
||||
"SourceNat": {
|
||||
"SupportedSourceNatTypes": "peraccount",
|
||||
"RedundantRouter": "true"
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
@ -186,7 +177,7 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
|
||||
if RR:
|
||||
self.debug("Redundant Router Enabled")
|
||||
self.services["network_offering"]["serviceCapabilityList"]["RedundantRouter"] = "true"
|
||||
self.services["network_offering"]["serviceCapabilityList"]["SourceNat"]["RedundantRouter"] = "true"
|
||||
|
||||
self.network_offering = NetworkOffering.create(self.apiclient,
|
||||
self.services["network_offering"],
|
||||
|
|
@ -288,16 +279,31 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
ssh.execute('chmod +x %s' % script_file)
|
||||
self.debug("%s %s" % (script_file, exec_cmd_params))
|
||||
|
||||
self.debug('sleep %s seconds for egress rule to affect on Router.' % self.services['sleep'])
|
||||
time.sleep(self.services['sleep'])
|
||||
|
||||
result = ssh.execute("%s %s" % (script_file, exec_cmd_params))
|
||||
self.debug('Result is=%s' % result)
|
||||
|
||||
exec_success = False
|
||||
if str(result).strip() == expected_result:
|
||||
self.debug('script executed successfully exec_success=True')
|
||||
exec_success = True
|
||||
#Timeout set to 3 minutes
|
||||
timeout = 180
|
||||
while timeout:
|
||||
self.debug('sleep %s seconds for egress rule to affect on Router.' % self.services['sleep'])
|
||||
time.sleep(self.services['sleep'])
|
||||
result = ssh.execute("%s %s" % (script_file, exec_cmd_params))
|
||||
self.debug('Result is=%s' % result)
|
||||
self.debug('Expected result is=%s' % expected_result)
|
||||
|
||||
if str(result).strip() == expected_result:
|
||||
exec_success = True
|
||||
break
|
||||
else:
|
||||
if result == []:
|
||||
self.fail("Router is not accessible")
|
||||
# This means router network did not come up as yet loop back.
|
||||
if "send" in result[0]:
|
||||
timeout -= self.services['sleep']
|
||||
else: # Failed due to some other error
|
||||
break
|
||||
#end while
|
||||
|
||||
if timeout == 0:
|
||||
self.fail("Router network failed to come up after 3 minutes.")
|
||||
|
||||
ssh.execute('rm -rf %s' % script_file)
|
||||
|
||||
|
|
@ -371,18 +377,17 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
self.virtual_machine.delete(self.apiclient)
|
||||
wait_for_cleanup(self.apiclient, ["expunge.interval", "expunge.delay"])
|
||||
self.debug("Sleep for VM cleanup to complete.")
|
||||
time.sleep(self.services['sleep'])
|
||||
#time.sleep(self.services['sleep'])
|
||||
self.network.delete(self.apiclient)
|
||||
wait_for_cleanup(self.apiclient, ["network.gc.wait", "network.gc.interval"])
|
||||
self.debug("Sleep for Network cleanup to complete.")
|
||||
time.sleep(self.services['sleep'])
|
||||
wait_for_cleanup(self.apiclient, ["network.gc.wait", "network.gc.interval"])
|
||||
#time.sleep(self.services['sleep'])
|
||||
cleanup_resources(self.apiclient, reversed(self.cleanup))
|
||||
self.debug("Cleanup complete!")
|
||||
except Exception as e:
|
||||
self.debug("Warning! Exception in tearDown: %s" % e)
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_01_egress_fr1(self):
|
||||
"""Test By-default the communication from guest n/w to public n/w is allowed.
|
||||
"""
|
||||
|
|
@ -398,7 +403,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
negative_test=False)
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_01_1_egress_fr1(self):
|
||||
"""Test By-default the communication from guest n/w to public n/w is NOT allowed.
|
||||
"""
|
||||
|
|
@ -415,7 +419,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_02_egress_fr2(self):
|
||||
"""Test Allow Communication using Egress rule with CIDR + Port Range + Protocol.
|
||||
"""
|
||||
|
|
@ -433,7 +436,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
negative_test=False)
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_02_1_egress_fr2(self):
|
||||
"""Test Allow Communication using Egress rule with CIDR + Port Range + Protocol.
|
||||
"""
|
||||
|
|
@ -450,9 +452,7 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
"['0']",
|
||||
negative_test=False)
|
||||
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_03_egress_fr3(self):
|
||||
"""Test Communication blocked with network that is other than specified
|
||||
"""
|
||||
|
|
@ -474,7 +474,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
negative_test=False)
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_03_1_egress_fr3(self):
|
||||
"""Test Communication blocked with network that is other than specified
|
||||
"""
|
||||
|
|
@ -483,7 +482,7 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
# 3. create egress rule with specific CIDR + port range.
|
||||
# 4. login to VM.
|
||||
# 5. Try to reach to public network with other protocol/port range
|
||||
self.create_vm()
|
||||
self.create_vm(egress_policy=False)
|
||||
self.exec_script_on_user_vm('ping -c 1 www.google.com',
|
||||
"| grep -oP \'\d+(?=% packet loss)\'",
|
||||
"['100']",
|
||||
|
|
@ -495,9 +494,7 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
"['failed:']",
|
||||
negative_test=False)
|
||||
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_04_egress_fr4(self):
|
||||
"""Test Create Egress rule and check the Firewall_Rules DB table
|
||||
"""
|
||||
|
|
@ -517,10 +514,10 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
"Check DB Query result set")
|
||||
self.assertEqual(qresultset[0][0],
|
||||
"Firewall",
|
||||
"DB results not matching")
|
||||
"DB results not matching, expected: Firewall found: %s " % qresultset[0][0])
|
||||
self.assertEqual(qresultset[0][1],
|
||||
"Egress",
|
||||
"DB results not matching")
|
||||
"DB results not matching, expected: Egress, found: %s" % qresultset[0][1])
|
||||
qresultset = self.dbclient.execute("select egress_default_policy from network_offerings where name='%s';" % self.network_offering.name)
|
||||
self.assertEqual(isinstance(qresultset, list),
|
||||
True,
|
||||
|
|
@ -530,12 +527,11 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
0,
|
||||
"Check DB Query result set")
|
||||
self.assertEqual(qresultset[0][0],
|
||||
"1",
|
||||
"DB results not matching")
|
||||
1,
|
||||
"DB results not matching, expected: 1, found: %s" % qresultset[0][0])
|
||||
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_04_1_egress_fr4(self):
|
||||
"""Test Create Egress rule and check the Firewall_Rules DB table
|
||||
"""
|
||||
|
|
@ -555,10 +551,10 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
"Check DB Query result set")
|
||||
self.assertEqual(qresultset[0][0],
|
||||
"Firewall",
|
||||
"DB results not matching")
|
||||
"DB results not matching, expected: Firewall found: %s " % qresultset[0][0])
|
||||
self.assertEqual(qresultset[0][1],
|
||||
"Egress",
|
||||
"DB results not matching")
|
||||
"DB results not matching, expected: Egress, found: %s" % qresultset[0][1])
|
||||
qresultset = self.dbclient.execute("select egress_default_policy from network_offerings where name='%s';" % self.network_offering.name)
|
||||
self.assertEqual(isinstance(qresultset, list),
|
||||
True,
|
||||
|
|
@ -568,13 +564,11 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
0,
|
||||
"Check DB Query result set")
|
||||
self.assertEqual(qresultset[0][0],
|
||||
"0",
|
||||
"DB results not matching")
|
||||
|
||||
|
||||
0,
|
||||
"DB results not matching, expected: 0, found: %s" % qresultset[0][0])
|
||||
|
||||
@unittest.skip("Skip")
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_05_egress_fr5(self):
|
||||
"""Test Create Egress rule and check the IP tables
|
||||
"""
|
||||
|
|
@ -592,8 +586,8 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
#TODO: Query VR for expected route rules.
|
||||
|
||||
|
||||
@unittest.skip("Skip")
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_05_1_egress_fr5(self):
|
||||
"""Test Create Egress rule and check the IP tables
|
||||
"""
|
||||
|
|
@ -612,7 +606,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_06_egress_fr6(self):
|
||||
"""Test Create Egress rule without CIDR
|
||||
"""
|
||||
|
|
@ -629,7 +622,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
negative_test=False)
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_06_1_egress_fr6(self):
|
||||
"""Test Create Egress rule without CIDR
|
||||
"""
|
||||
|
|
@ -645,10 +637,7 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
"['0']",
|
||||
negative_test=False)
|
||||
|
||||
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_07_egress_fr7(self):
|
||||
"""Test Create Egress rule without End Port
|
||||
"""
|
||||
|
|
@ -665,7 +654,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
negative_test=False)
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_07_1_egress_fr7(self):
|
||||
"""Test Create Egress rule without End Port
|
||||
"""
|
||||
|
|
@ -681,9 +669,8 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
"['failed:']",
|
||||
negative_test=False)
|
||||
|
||||
|
||||
@unittest.skip("Skip")
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_08_egress_fr8(self):
|
||||
"""Test Port Forwarding and Egress Conflict
|
||||
"""
|
||||
|
|
@ -694,8 +681,8 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
self.create_vm(pfrule=True)
|
||||
self.createEgressRule()
|
||||
|
||||
@unittest.skip("Skip")
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_08_1_egress_fr8(self):
|
||||
"""Test Port Forwarding and Egress Conflict
|
||||
"""
|
||||
|
|
@ -708,7 +695,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_09_egress_fr9(self):
|
||||
"""Test Delete Egress rule
|
||||
"""
|
||||
|
|
@ -733,7 +719,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
negative_test=False)
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_09_1_egress_fr9(self):
|
||||
"""Test Delete Egress rule
|
||||
"""
|
||||
|
|
@ -759,7 +744,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_10_egress_fr10(self):
|
||||
"""Test Invalid CIDR and Invalid Port ranges
|
||||
"""
|
||||
|
|
@ -771,7 +755,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
self.assertRaises(Exception, self.createEgressRule, '10.2.2.0/24')
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_10_1_egress_fr10(self):
|
||||
"""Test Invalid CIDR and Invalid Port ranges
|
||||
"""
|
||||
|
|
@ -784,7 +767,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_11_egress_fr11(self):
|
||||
"""Test Regression on Firewall + PF + LB + SNAT
|
||||
"""
|
||||
|
|
@ -795,7 +777,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
self.create_vm(pfrule=True)
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_11_1_egress_fr11(self):
|
||||
"""Test Regression on Firewall + PF + LB + SNAT
|
||||
"""
|
||||
|
|
@ -807,7 +788,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_12_egress_fr12(self):
|
||||
"""Test Reboot Router
|
||||
"""
|
||||
|
|
@ -825,7 +805,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
negative_test=False)
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_12_1_egress_fr12(self):
|
||||
"""Test Reboot Router
|
||||
"""
|
||||
|
|
@ -842,9 +821,7 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
"['0']",
|
||||
negative_test=False)
|
||||
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_13_egress_fr13(self):
|
||||
"""Test Redundant Router : Master failover
|
||||
"""
|
||||
|
|
@ -900,7 +877,6 @@ class TestEgressFWRules(cloudstackTestCase):
|
|||
negative_test=False)
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@log_test_exceptions
|
||||
def test_13_1_egress_fr13(self):
|
||||
"""Test Redundant Router : Master failover
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue