From a0b16449e7fd257b2abee347ae211ab6a33bc53c Mon Sep 17 00:00:00 2001 From: Ganesh Murthy Date: Tue, 31 Jan 2017 14:18:10 -0500 Subject: [PATCH] DISPATCH-216 - Added code to skip system_tests_protocol_family.py if IPv6 is turned off --- tests/system_test.py | 14 ++++++++++++++ tests/system_tests_protocol_family.py | 10 +++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/system_test.py b/tests/system_test.py index 0c67a6e242..e25ffc6718 100755 --- a/tests/system_test.py +++ b/tests/system_test.py @@ -143,6 +143,20 @@ def get_local_host_socket(protocol_family='IPv4'): return s, host +def is_ipv6_enabled(): + """ + Returns true if IPV6 is enabled, false otherwise + """ + sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + ipv6_enabled = True + try: + sock.bind(('::1', 0)) + except Exception as e: + if "Cannot assign requested address" in str(e): + ipv6_enabled = False + + return ipv6_enabled + def port_available(port, protocol_family='IPv4'): """Return true if connecting to host:port gives 'connection refused'.""" s, host = get_local_host_socket(protocol_family) diff --git a/tests/system_tests_protocol_family.py b/tests/system_tests_protocol_family.py index 20822c142b..9c0e9feb0b 100644 --- a/tests/system_tests_protocol_family.py +++ b/tests/system_tests_protocol_family.py @@ -20,7 +20,7 @@ import unittest from time import sleep from proton import Message -from system_test import TestCase, Qdrouterd, main_module +from system_test import TestCase, Qdrouterd, main_module, is_ipv6_enabled try: from proton import MODIFIED @@ -31,6 +31,7 @@ class ProtocolFamilyTest(TestCase): @classmethod def setUpClass(cls): + """ Starts three routers with various listeners and connectors. There is a call to wait_router_connected to make sure that the routers are able to communicate with each @@ -71,6 +72,9 @@ def router(name, connection): # and tests each connector cls.routers.append(cls.tester.qdrouterd(name, config, wait=True)) + if not is_ipv6_enabled(): + return + cls.routers = [] inter_router_port = cls.tester.get_port(protocol_family='IPv6') @@ -105,6 +109,10 @@ def router(name, connection): # If this test has started executing, it means that the setUpClass() has successfully executed which means that # the routers were able to communicate with each other successfully using the specified protocol family. def test_simple_pre_settled(self): + + if not is_ipv6_enabled(): + return self.skipTest("Skipping test..IPV6 not enabled") + addr = self.routers[0].addresses[4]+"/test/1" M1 = self.messenger() M2 = self.messenger()