Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 13D5610744 for ; Thu, 17 Oct 2013 23:50:55 +0000 (UTC) Received: (qmail 90958 invoked by uid 500); 17 Oct 2013 23:50:54 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 90936 invoked by uid 500); 17 Oct 2013 23:50:54 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 90923 invoked by uid 99); 17 Oct 2013 23:50:54 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Oct 2013 23:50:54 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 88740917B5E; Thu, 17 Oct 2013 23:50:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sangeethah@apache.org To: commits@cloudstack.apache.org Date: Thu, 17 Oct 2013 23:50:54 -0000 Message-Id: <97606ae93bc343908753fa3667234749@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: updated refs/heads/master to b6d12f7 Updated Branches: refs/heads/master a504c004b -> b6d12f794 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. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a65f1ebe Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a65f1ebe Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a65f1ebe Branch: refs/heads/master Commit: a65f1ebefca7b22512762faf1832291153782f58 Parents: ec3302a Author: Gaurav Aradhye Authored: Wed Oct 16 03:33:35 2013 -0400 Committer: Sangeetha Committed: Thu Oct 17 19:20:30 2013 -0700 ---------------------------------------------------------------------- .../component/test_egress_fw_rules.py | 108 ++++++++----------- 1 file changed, 42 insertions(+), 66 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a65f1ebe/test/integration/component/test_egress_fw_rules.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_egress_fw_rules.py b/test/integration/component/test_egress_fw_rules.py index 5c18f9c..253cc46 100644 --- a/test/integration/component/test_egress_fw_rules.py +++ b/test/integration/component/test_egress_fw_rules.py @@ -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 """