From 6d10fc94131e22872a84489e81fd4f1ec5f1e1b7 Mon Sep 17 00:00:00 2001 From: Ganesh Murthy Date: Wed, 6 Dec 2017 10:08:24 -0500 Subject: [PATCH] DISPATCH 894 - Made the following changes to make the system tests work on CentOS 6. 1. Modified system tests to use unittest2 instead of unittest test framework. 2. Modified tests/CMakeLists.txt to use the unit2 test runner. 3. Fixed some tests to use backwards compatible assert functions. 4. Remove unused imports in tests --- README | 1 + tests/CMakeLists.txt | 8 ++-- tests/router_engine_test.py | 2 +- tests/router_policy_test.py | 3 +- tests/run_system_tests.py | 2 +- tests/system_tests_auth_service_plugin.py | 9 +++-- tests/system_tests_autolinks.py | 6 +-- tests/system_tests_broker.py | 5 ++- tests/system_tests_default_distribution.py | 10 +++-- tests/system_tests_delivery_abort.py | 9 ++--- ...system_tests_denied_unsettled_multicast.py | 9 ++--- tests/system_tests_distribution.py | 19 ++------- tests/system_tests_drain.py | 5 ++- tests/system_tests_drain_support.py | 6 ++- tests/system_tests_dynamic_terminus.py | 9 ++--- tests/system_tests_failover_list.py | 15 ++----- tests/system_tests_handle_failover.py | 15 +++++-- tests/system_tests_http.py | 7 +++- tests/system_tests_link_routes.py | 7 ++-- tests/system_tests_log_message_components.py | 5 +++ tests/system_tests_management.py | 40 ++++++++++--------- tests/system_tests_multi_tenancy.py | 7 ++-- tests/system_tests_one_router.py | 3 +- tests/system_tests_policy.py | 5 ++- tests/system_tests_protocol_family.py | 4 +- tests/system_tests_protocol_settings.py | 24 +++++++---- tests/system_tests_qdmanage.py | 4 +- tests/system_tests_qdstat.py | 4 +- tests/system_tests_sasl_plain.py | 9 +++-- tests/system_tests_topology.py | 20 +++------- tests/system_tests_two_routers.py | 11 ++--- tests/system_tests_user_id.py | 5 ++- tests/system_tests_user_id_proxy.py | 6 +-- 33 files changed, 156 insertions(+), 138 deletions(-) diff --git a/README b/README index bbb8de2315..22ad2ce73f 100644 --- a/README +++ b/README @@ -19,6 +19,7 @@ packages installed: - cyrus-sasl-plain - cyrus-sasl-devel - asciidoc (for building docs) +- python-unittest2 (python2-unittest2 on Fedora) (we use unittest2 for running python tests) Dispatch will not build on Windows. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0c6454ce0b..205c1fc3f1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -65,9 +65,9 @@ add_test(unit_tests_size_1 ${TEST_WRAP} -x unit_tests_size 1) add_test(unit_tests ${TEST_WRAP} -x unit_tests ${CMAKE_CURRENT_SOURCE_DIR}/threads4.conf) # Unit test python modules -add_test(router_engine_test ${TEST_WRAP} -m unittest -v router_engine_test) -add_test(management_test ${TEST_WRAP} -m unittest -v management) -add_test(router_policy_test ${TEST_WRAP} -m unittest -v router_policy_test) +add_test(router_engine_test ${TEST_WRAP} -x unit2 -v router_engine_test) +add_test(management_test ${TEST_WRAP} -x unit2 -v management) +add_test(router_policy_test ${TEST_WRAP} -x unit2 -v router_policy_test) if(USE_LIBWEBSOCKETS) set(SYSTEM_TESTS_HTTP system_tests_http) @@ -104,7 +104,7 @@ foreach(py_test_module ${SYSTEM_TESTS_HTTP} ) - add_test(${py_test_module} ${TEST_WRAP} -m unittest -v ${py_test_module}) + add_test(${py_test_module} ${TEST_WRAP} -x unit2 -v ${py_test_module}) list(APPEND SYSTEM_TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${py_test_module}.py) endforeach() diff --git a/tests/router_engine_test.py b/tests/router_engine_test.py index 174365c333..aef261d2a3 100644 --- a/tests/router_engine_test.py +++ b/tests/router_engine_test.py @@ -19,7 +19,7 @@ import os import sys -import unittest +import unittest2 as unittest import mock # Mock definitions for tests. sys.path.append(os.path.join(os.environ["SOURCE_DIR"], "python")) diff --git a/tests/router_policy_test.py b/tests/router_policy_test.py index 326f71e6d1..27ad56e923 100644 --- a/tests/router_policy_test.py +++ b/tests/router_policy_test.py @@ -17,7 +17,7 @@ # under the License. # -import unittest +import unittest2 as unittest from qpid_dispatch_internal.policy.policy_util import HostAddr, is_ipv6_enabled from qpid_dispatch_internal.policy.policy_util import HostStruct @@ -316,5 +316,6 @@ def test_policy_app_conn_mgr_larger_counts(self): self.assertTrue(stats.connections_approved == 10000) self.assertTrue(stats.connections_denied == 1) + if __name__ == '__main__': unittest.main(main_module()) diff --git a/tests/run_system_tests.py b/tests/run_system_tests.py index a9b3232d0b..460692f280 100644 --- a/tests/run_system_tests.py +++ b/tests/run_system_tests.py @@ -28,7 +28,7 @@ import os import sys from fnmatch import fnmatch -import unittest +import unittest2 as unittest import system_test # Collect all system_tests_*.py scripts in the same directory as this script. diff --git a/tests/system_tests_auth_service_plugin.py b/tests/system_tests_auth_service_plugin.py index 2c03ac50d0..b1a8e327b9 100644 --- a/tests/system_tests_auth_service_plugin.py +++ b/tests/system_tests_auth_service_plugin.py @@ -17,13 +17,15 @@ # under the License. # -import unittest, os, json -from subprocess import PIPE, Popen, STDOUT -from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process +import unittest2 as unittest +import os +from subprocess import PIPE, Popen +from system_test import TestCase, Qdrouterd, main_module from proton import SASL from proton.handlers import MessagingHandler from proton.reactor import Container + class AuthServicePluginTest(TestCase): @classmethod def createSaslFiles(cls): @@ -135,6 +137,7 @@ def on_transport_error(self, event): def run(self): Container(self).run() + if __name__ == '__main__': unittest.main(main_module()) diff --git a/tests/system_tests_autolinks.py b/tests/system_tests_autolinks.py index 1776e935a9..a8e1d5cd0a 100644 --- a/tests/system_tests_autolinks.py +++ b/tests/system_tests_autolinks.py @@ -17,11 +17,11 @@ # under the License. # -import unittest -from proton import Message, Delivery, PENDING, ACCEPTED, REJECTED +import unittest2 as unittest +from proton import Message from system_test import TestCase, Qdrouterd, main_module, TIMEOUT from proton.handlers import MessagingHandler -from proton.reactor import Container, AtMostOnce, AtLeastOnce +from proton.reactor import Container CONNECTION_PROPERTIES = {u'connection': u'properties', u'int_property': 6451} diff --git a/tests/system_tests_broker.py b/tests/system_tests_broker.py index 98a164a224..3832bf05eb 100644 --- a/tests/system_tests_broker.py +++ b/tests/system_tests_broker.py @@ -21,10 +21,12 @@ System tests involving one or more brokers and dispatch routers integrated with waypoints. """ -import unittest, system_test +import unittest2 as unittest +import system_test from system_test import Qdrouterd, message, MISSING_REQUIREMENTS from itertools import cycle + class DistributedQueueTest(system_test.TestCase): # pylint: disable=too-many-public-methods """System tests involving routers and qpidd brokers""" @@ -101,5 +103,6 @@ def router(i): addrs = [r.addresses[0]+"/"+self.testq for r in routers] self.verify_equal_spread(addrs, addrs) + if __name__ == '__main__': unittest.main(system_test.main_module()) diff --git a/tests/system_tests_default_distribution.py b/tests/system_tests_default_distribution.py index 90adbd2783..6d66996e0b 100644 --- a/tests/system_tests_default_distribution.py +++ b/tests/system_tests_default_distribution.py @@ -17,14 +17,15 @@ # under the License. # +import unittest2 as unittest import re -import system_test from subprocess import PIPE -from system_test import TestCase, Qdrouterd, TIMEOUT +from system_test import TestCase, Qdrouterd, TIMEOUT, main_module from proton.handlers import MessagingHandler from proton.reactor import Container from proton import Message + class DefaultDistributionTest(TestCase): """System tests for testing the defaultDistribution attribute of the router entity""" @classmethod @@ -46,7 +47,7 @@ def setUpClass(cls): def run_qdstat(self, args, regexp=None, address=None): p = self.popen( - ['qdstat', '--bus', str(address or self.address), '--timeout', str(system_test.TIMEOUT) ] + args, + ['qdstat', '--bus', str(address or self.address), '--timeout', str(TIMEOUT) ] + args, name='qdstat-'+self.id(), stdout=PIPE, expect=None) out = p.communicate()[0] @@ -184,3 +185,6 @@ def on_rejected(self, event): def run(self): Container(self).run() + +if __name__ == '__main__': + unittest.main(main_module()) diff --git a/tests/system_tests_delivery_abort.py b/tests/system_tests_delivery_abort.py index dcf763a118..30c7a13214 100644 --- a/tests/system_tests_delivery_abort.py +++ b/tests/system_tests_delivery_abort.py @@ -17,12 +17,11 @@ # under the License. # -import unittest, os, json -from subprocess import PIPE, STDOUT -from proton import Message, PENDING, ACCEPTED, REJECTED, RELEASED, SSLDomain, SSLUnavailable, Timeout -from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process +import unittest2 as unittest +from proton import Message, Timeout +from system_test import TestCase, Qdrouterd, main_module from proton.handlers import MessagingHandler -from proton.reactor import Container, DynamicNodeProperties +from proton.reactor import Container # PROTON-828: try: diff --git a/tests/system_tests_denied_unsettled_multicast.py b/tests/system_tests_denied_unsettled_multicast.py index b139733f3a..bc85084460 100644 --- a/tests/system_tests_denied_unsettled_multicast.py +++ b/tests/system_tests_denied_unsettled_multicast.py @@ -17,12 +17,11 @@ # under the License. # -import unittest, os, json -from subprocess import PIPE, STDOUT -from proton import Message, PENDING, ACCEPTED, REJECTED, RELEASED, SSLDomain, SSLUnavailable, Timeout -from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process +import unittest2 as unittest +from proton import Message, Timeout +from system_test import TestCase, Qdrouterd, main_module, TIMEOUT from proton.handlers import MessagingHandler -from proton.reactor import Container, DynamicNodeProperties +from proton.reactor import Container # PROTON-828: try: diff --git a/tests/system_tests_distribution.py b/tests/system_tests_distribution.py index 0156afccb4..ed5307e3a2 100644 --- a/tests/system_tests_distribution.py +++ b/tests/system_tests_distribution.py @@ -17,19 +17,11 @@ # under the License. # -import unittest, os, json -from subprocess import PIPE, STDOUT -from proton import Message, PENDING, ACCEPTED, REJECTED, RELEASED, SSLDomain, SSLUnavailable, Timeout -from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process +import unittest2 as unittest +from proton import Message, Timeout +from system_test import TestCase, Qdrouterd, main_module, TIMEOUT from proton.handlers import MessagingHandler -from proton.reactor import Container, AtMostOnce, AtLeastOnce, DynamicNodeProperties, LinkOption, ApplicationEvent, EventInjector -from proton.utils import BlockingConnection -from qpid_dispatch.management.client import Node - -import time -import datetime - - +from proton.reactor import Container, LinkOption, ApplicationEvent, EventInjector # PROTON-828: try: @@ -4201,8 +4193,5 @@ def run(self): container.run() - - - if __name__ == '__main__': unittest.main(main_module()) diff --git a/tests/system_tests_drain.py b/tests/system_tests_drain.py index b379d27eba..b2ecadb7c9 100644 --- a/tests/system_tests_drain.py +++ b/tests/system_tests_drain.py @@ -17,12 +17,12 @@ # under the License. # -import unittest - +import unittest2 as unittest from system_test import TestCase, Qdrouterd, main_module from system_tests_drain_support import DrainMessagesHandler, DrainOneMessageHandler from system_tests_drain_support import DrainNoMessagesHandler, DrainNoMoreMessagesHandler + class DrainSupportTest(TestCase): @classmethod @@ -62,5 +62,6 @@ def test_drain_support_4_no_more_messages(self): drain_support.run() self.assertEqual(drain_support.error, None) + if __name__ == '__main__': unittest.main(main_module()) diff --git a/tests/system_tests_drain_support.py b/tests/system_tests_drain_support.py index 661cf20f8c..2600ec0530 100644 --- a/tests/system_tests_drain_support.py +++ b/tests/system_tests_drain_support.py @@ -17,10 +17,11 @@ # under the License. # +import unittest2 as unittest from proton.handlers import MessagingHandler from proton.reactor import Container from proton import Message, Endpoint -from system_test import TIMEOUT +from system_test import main_module, TIMEOUT class Timeout(object): def __init__(self, parent): @@ -205,3 +206,6 @@ def on_link_flow(self, event): def run(self): Container(self).run() + +if __name__ == '__main__': + unittest.main(main_module()) \ No newline at end of file diff --git a/tests/system_tests_dynamic_terminus.py b/tests/system_tests_dynamic_terminus.py index bd43cf3f0f..f00c478268 100644 --- a/tests/system_tests_dynamic_terminus.py +++ b/tests/system_tests_dynamic_terminus.py @@ -17,12 +17,11 @@ # under the License. # -import unittest, os, json -from subprocess import PIPE, STDOUT -from proton import Message, PENDING, ACCEPTED, REJECTED, RELEASED, SSLDomain, SSLUnavailable, Timeout -from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process +import unittest2 as unittest +from proton import Message, Timeout +from system_test import TestCase, Qdrouterd, main_module, TIMEOUT from proton.handlers import MessagingHandler -from proton.reactor import Container, DynamicNodeProperties, LinkOption +from proton.reactor import Container, LinkOption # PROTON-828: try: diff --git a/tests/system_tests_failover_list.py b/tests/system_tests_failover_list.py index af76835b71..b62faefb22 100644 --- a/tests/system_tests_failover_list.py +++ b/tests/system_tests_failover_list.py @@ -17,12 +17,11 @@ # under the License. # -import unittest, os, json -from subprocess import PIPE, STDOUT -from proton import Message, PENDING, ACCEPTED, REJECTED, RELEASED, SSLDomain, SSLUnavailable, Timeout -from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process +import unittest2 as unittest +from proton import Timeout +from system_test import TestCase, Qdrouterd, main_module, TIMEOUT from proton.handlers import MessagingHandler -from proton.reactor import Container, DynamicNodeProperties +from proton.reactor import Container # PROTON-828: try: @@ -33,8 +32,6 @@ class RouterTest(TestCase): - inter_router_port = None - @classmethod def setUpClass(cls): """Start a router""" @@ -55,12 +52,9 @@ def router(name): cls.routers = [] - inter_router_port = cls.tester.get_port() - router('A') cls.routers[0].wait_ready() - def test_01_no_failover_list(self): test = FailoverTest(self.routers[0].addresses[0], 0) test.run() @@ -130,7 +124,6 @@ def on_connection_opened(self, event): self.timer.cancel() self.conn.close() - def run(self): Container(self).run() diff --git a/tests/system_tests_handle_failover.py b/tests/system_tests_handle_failover.py index 0204a48554..eb8663ebc1 100644 --- a/tests/system_tests_handle_failover.py +++ b/tests/system_tests_handle_failover.py @@ -17,9 +17,10 @@ # under the License. # +import unittest2 as unittest import json, re from time import sleep -import system_test +from system_test import main_module, TIMEOUT from system_test import TestCase, Qdrouterd, Process, TIMEOUT from subprocess import PIPE, STDOUT @@ -95,7 +96,7 @@ def run_qdmanage(self, cmd, input=None, expect=Process.EXIT_OK, address=None): def run_qdstat(self, args, regexp=None, address=None): p = self.popen( - ['qdstat', '--bus', str(address or self.router.addresses[0]), '--timeout', str(system_test.TIMEOUT) ] + args, + ['qdstat', '--bus', str(address or self.router.addresses[0]), '--timeout', str(TIMEOUT) ] + args, name='qdstat-'+self.id(), stdout=PIPE, expect=None) out = p.communicate()[0] @@ -118,7 +119,9 @@ def test_connector_has_failover_list(self): def test_remove_router_B(self): # First make sure there are no inter-router connections on router C outs = self.run_qdstat(['--connections'], address=self.routers[2].addresses[1]) - self.assertNotIn('inter-router', outs) + + inter_router = 'inter-router' in outs + self.assertFalse(inter_router) # Kill the router B FailoverTest.routers[0].teardown() @@ -133,8 +136,12 @@ def test_remove_router_B(self): output = json.loads(self.run_qdmanage(query_command, address=self.routers[1].addresses[0])) # The failoverList must now be gone since the backup router does not send a failoverList in its # connection properties. - self.assertIsNone(output[0].get('failoverList')) + self.assertTrue(output[0].get('failoverList') == None) # Since router B has been killed, router A should now try to connect to a listener on router C. # Use qdstat to connect to router C and determine that there is an inter-router connection with router A. self.run_qdstat(['--connections'], regexp=r'QDR.A.*inter-router.*', address=self.routers[2].addresses[1]) + + +if __name__ == '__main__': + unittest.main(main_module()) \ No newline at end of file diff --git a/tests/system_tests_http.py b/tests/system_tests_http.py index adfbd54eb9..7fc8a237b2 100644 --- a/tests/system_tests_http.py +++ b/tests/system_tests_http.py @@ -17,9 +17,11 @@ # under the License. # -import unittest, os, json, threading, sys, ssl, urllib2 +import unittest2 as unittest +import os, threading, sys, urllib2 import ssl -from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process +from system_test import TestCase, Qdrouterd, main_module, DIR + class RouterTestHttp(TestCase): @@ -132,5 +134,6 @@ def listener(**kwargs): # Provide client cert self.assert_get_cert("https://localhost:%d" % r.ports[2]) + if __name__ == '__main__': unittest.main(main_module()) diff --git a/tests/system_tests_link_routes.py b/tests/system_tests_link_routes.py index 0cdc22b849..afee3a54c8 100644 --- a/tests/system_tests_link_routes.py +++ b/tests/system_tests_link_routes.py @@ -17,17 +17,16 @@ # under the License. # -import unittest +import unittest2 as unittest from time import sleep, time from subprocess import PIPE, STDOUT from system_test import TestCase, Qdrouterd, main_module, TIMEOUT, Process -from proton import Message, Endpoint +from proton import Message from proton.handlers import MessagingHandler from proton.reactor import AtMostOnce, Container, DynamicNodeProperties, LinkOption -from proton.utils import BlockingConnection, LinkDetached - +from proton.utils import BlockingConnection from system_tests_drain_support import DrainMessagesHandler, DrainOneMessageHandler, DrainNoMessagesHandler, DrainNoMoreMessagesHandler from qpid_dispatch.management.client import Node diff --git a/tests/system_tests_log_message_components.py b/tests/system_tests_log_message_components.py index bba36f4e20..e6b674e5a2 100644 --- a/tests/system_tests_log_message_components.py +++ b/tests/system_tests_log_message_components.py @@ -17,6 +17,7 @@ # under the License. # +import unittest2 as unittest import json from proton import Message, symbol from system_test import TestCase, Qdrouterd, Process, TIMEOUT @@ -203,3 +204,7 @@ def on_message(self, event): def run(self): Container(self).run() + + +if __name__ == '__main__': + unittest.main(main_module()) \ No newline at end of file diff --git a/tests/system_tests_management.py b/tests/system_tests_management.py index 0bd865dccc..f5e915dc3d 100644 --- a/tests/system_tests_management.py +++ b/tests/system_tests_management.py @@ -1,25 +1,26 @@ -## -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you under the Apache License, Version 2.0 (the -## "License"); you may not use this file except in compliance -## with the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, -## software distributed under the License is distributed on an -## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -## KIND, either express or implied. See the License for the -## specific language governing permissions and limitations -## under the License -## +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License +# """System tests for management of qdrouter""" -import unittest, system_test, re, os, json, sys +import unittest2 as unittest +import system_test, re, os, json, sys from qpid_dispatch.management.client import Node, ManagementError, Url, BadRequestStatus, NotImplementedStatus, NotFoundStatus from qpid_dispatch_internal.management.qdrouter import QdSchema from qpid_dispatch_internal.compat import dictify @@ -464,5 +465,6 @@ def test_get_schema(self): got = self.node.call(self.node.request(operation="GET-SCHEMA", identity="self")).body self.assertEquals(schema, got) + if __name__ == '__main__': unittest.main(system_test.main_module()) diff --git a/tests/system_tests_multi_tenancy.py b/tests/system_tests_multi_tenancy.py index 3e4a16dc90..a555f812cd 100644 --- a/tests/system_tests_multi_tenancy.py +++ b/tests/system_tests_multi_tenancy.py @@ -17,10 +17,9 @@ # under the License. # -import unittest, os, json -from subprocess import PIPE, STDOUT -from proton import Message, PENDING, ACCEPTED, REJECTED, RELEASED, SSLDomain, SSLUnavailable, Timeout -from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process +import unittest2 as unittest +from proton import Message, Timeout +from system_test import TestCase, Qdrouterd, main_module, TIMEOUT from proton.handlers import MessagingHandler from proton.reactor import Container, DynamicNodeProperties diff --git a/tests/system_tests_one_router.py b/tests/system_tests_one_router.py index 47cd3ef225..d6e833b08b 100644 --- a/tests/system_tests_one_router.py +++ b/tests/system_tests_one_router.py @@ -17,7 +17,7 @@ # under the License. # -import unittest +import unittest2 as unittest from proton import Condition, Message, Delivery, PENDING, ACCEPTED, REJECTED, Url, symbol from system_test import TestCase, Qdrouterd, main_module, TIMEOUT from proton.handlers import MessagingHandler, TransactionHandler @@ -1877,5 +1877,6 @@ def on_message(self, event): def run(self): Container(self).run() + if __name__ == '__main__': unittest.main(main_module()) diff --git a/tests/system_tests_policy.py b/tests/system_tests_policy.py index 120137dc96..8d9e81f156 100644 --- a/tests/system_tests_policy.py +++ b/tests/system_tests_policy.py @@ -17,8 +17,8 @@ # under the License. # -import unittest, json -import os +import unittest as unittest +import os, json from system_test import TestCase, Qdrouterd, main_module, Process, TIMEOUT, DIR from subprocess import PIPE, STDOUT from proton import ConnectionException @@ -301,5 +301,6 @@ def test_verify_n_senders(self): bs1.close() + if __name__ == '__main__': unittest.main(main_module()) diff --git a/tests/system_tests_protocol_family.py b/tests/system_tests_protocol_family.py index f5990fdce6..512061c9c4 100644 --- a/tests/system_tests_protocol_family.py +++ b/tests/system_tests_protocol_family.py @@ -17,8 +17,7 @@ # under the License. # -import unittest -from time import sleep +import unittest2 as unittest from proton import Message from system_test import TestCase, Qdrouterd, main_module from qpid_dispatch_internal.policy.policy_util import is_ipv6_enabled @@ -139,5 +138,6 @@ def test_simple_pre_settled(self): M1.stop() M2.stop() + if __name__ == '__main__': unittest.main(main_module()) \ No newline at end of file diff --git a/tests/system_tests_protocol_settings.py b/tests/system_tests_protocol_settings.py index 9cc05298ed..1b7aa33ae8 100644 --- a/tests/system_tests_protocol_settings.py +++ b/tests/system_tests_protocol_settings.py @@ -17,14 +17,18 @@ # under the License. # -import unittest -from proton import Message, Delivery, PENDING, ACCEPTED, REJECTED +import unittest2 as unittest from system_test import TestCase, Qdrouterd, main_module -from proton.handlers import MessagingHandler -from proton.reactor import Container, AtMostOnce, AtLeastOnce -from proton.utils import BlockingConnection, SyncRequestResponse -from qpid_dispatch.management.client import Node -from proton import ConnectionException +from proton.utils import BlockingConnection +import subprocess +X86_64_ARCH = "x86_64" +skip_test = True + +# Dont skip tests on 64 bit architectures. +p = subprocess.Popen("uname -m", shell=True, stdout=subprocess.PIPE) +if X86_64_ARCH in p.communicate()[0]: + skip_test = False + class MaxFrameMaxSessionFramesTest(TestCase): """System tests setting proton negotiated size max-frame-size and incoming-window""" @@ -223,6 +227,8 @@ def setUpClass(cls): def test_max_session_frames_default(self): # Set up a connection to get the Open and a receiver to get a Begin frame in the log + if skip_test: + return self.skipTest("Test skipped on non-64 bit architectures") bc = BlockingConnection(self.router.addresses[0]) bc.create_receiver("xxx") bc.close() @@ -259,6 +265,8 @@ def setUpClass(cls): def test_max_frame_max_session_zero(self): # Set up a connection to get the Open and a receiver to get a Begin frame in the log + if skip_test: + return self.skipTest("Test disabled on non-64 bit architectures") bc = BlockingConnection(self.router.addresses[0]) bc.create_receiver("xxx") bc.close() @@ -316,6 +324,8 @@ def router(name, client_server, connection): cls.routers[1].wait_router_connected('QDR.A') def test_connector_default(self): + if skip_test: + return self.skipTest("Test disabled on non-64 bit architectures") with open('../setUpClass/A.log', 'r') as router_log: log_lines = router_log.read().split("\n") open_lines = [s for s in log_lines if "<- @open" in s] diff --git a/tests/system_tests_qdmanage.py b/tests/system_tests_qdmanage.py index 38784aed2f..1ff538de3e 100644 --- a/tests/system_tests_qdmanage.py +++ b/tests/system_tests_qdmanage.py @@ -17,9 +17,9 @@ # under the License # -import json, unittest, os +import json, unittest2 as unittest, os -from system_test import TestCase, Process, Qdrouterd, main_module, TIMEOUT, DIR, wait_port +from system_test import TestCase, Process, Qdrouterd, main_module, TIMEOUT, DIR from subprocess import PIPE, STDOUT from qpid_dispatch_internal.compat import dictify from qpid_dispatch_internal.management.qdrouter import QdSchema diff --git a/tests/system_tests_qdstat.py b/tests/system_tests_qdstat.py index ca1d6b6f70..84000da030 100644 --- a/tests/system_tests_qdstat.py +++ b/tests/system_tests_qdstat.py @@ -23,6 +23,8 @@ import unittest from subprocess import PIPE from proton import Url, SSLDomain, SSLUnavailable, SASL +from system_test import main_module + class QdstatTest(system_test.TestCase): """Test qdstat tool output""" @@ -358,4 +360,4 @@ def test_skip(self): if __name__ == '__main__': - unittest.main(system_test.main_module()) + unittest.main(main_module()) diff --git a/tests/system_tests_sasl_plain.py b/tests/system_tests_sasl_plain.py index 05e591f18f..51e56d35d8 100644 --- a/tests/system_tests_sasl_plain.py +++ b/tests/system_tests_sasl_plain.py @@ -17,9 +17,9 @@ # under the License. # -import unittest, os, json -from subprocess import PIPE, Popen, STDOUT -from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process +import unittest2 as unittest, os +from subprocess import PIPE, Popen +from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT from qpid_dispatch.management.client import Node from proton import SASL @@ -540,7 +540,8 @@ def test_zzz_delete_create_ssl_profile(self): local_node.delete(type='connector', name='connectorToX') local_node.delete(type='sslProfile', name='client-ssl-profile') connections = local_node.query(type='org.apache.qpid.dispatch.connection').get_entities() - self.assertNotIn("QDR.X", [c.container for c in connections]) # Should not be present now + is_qdr_x = "QDR.X" in [c.container for c in connections] + self.assertFalse(is_qdr_x) # Should not be present now # re-create the ssl profile local_node.create({'type': 'sslProfile', diff --git a/tests/system_tests_topology.py b/tests/system_tests_topology.py index 5e5848379a..cd171aa45c 100644 --- a/tests/system_tests_topology.py +++ b/tests/system_tests_topology.py @@ -17,20 +17,14 @@ # under the License. # -import unittest, os, json -from subprocess import PIPE, STDOUT -from proton import Message, PENDING, ACCEPTED, REJECTED, RELEASED, SSLDomain, SSLUnavailable, Timeout -from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process + +import unittest2 as unittest +from proton import Message, Timeout +from system_test import TestCase, Qdrouterd, main_module from proton.handlers import MessagingHandler -from proton.reactor import Container, AtMostOnce, AtLeastOnce, DynamicNodeProperties, LinkOption, ApplicationEvent, EventInjector -from proton.utils import BlockingConnection -from qpid_dispatch.management.client import Node +from proton.reactor import Container import time -import datetime -import pdb - - # PROTON-828: try: @@ -39,8 +33,6 @@ from proton import PN_STATUS_MODIFIED as MODIFIED - - #------------------------------------------------ # Helper classes for all tests. #------------------------------------------------ @@ -603,7 +595,5 @@ def run(self): Container(self).run() - - if __name__ == '__main__': unittest.main(main_module()) diff --git a/tests/system_tests_two_routers.py b/tests/system_tests_two_routers.py index a718dd3cb8..7fae1316b1 100644 --- a/tests/system_tests_two_routers.py +++ b/tests/system_tests_two_routers.py @@ -17,12 +17,12 @@ # under the License. # -import unittest, os, json, logging -from subprocess import PIPE, STDOUT -from proton import Message, PENDING, ACCEPTED, REJECTED, RELEASED, Timeout -from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process +import unittest2 as unittest +import logging +from proton import Message, PENDING, ACCEPTED, REJECTED, Timeout +from system_test import TestCase, Qdrouterd, main_module, TIMEOUT from proton.handlers import MessagingHandler -from proton.reactor import Container, AtMostOnce, AtLeastOnce +from proton.reactor import Container # PROTON-828: try: @@ -1315,5 +1315,6 @@ def run(self): finally: logging.disable(logging.NOTSET) # Restore to normal + if __name__ == '__main__': unittest.main(main_module()) diff --git a/tests/system_tests_user_id.py b/tests/system_tests_user_id.py index e62f311747..f9058c6a39 100644 --- a/tests/system_tests_user_id.py +++ b/tests/system_tests_user_id.py @@ -19,10 +19,10 @@ import os -import unittest +import unittest2 as unittest from system_test import TestCase, Qdrouterd, DIR, main_module from qpid_dispatch.management.client import Node -from proton import SSLDomain, Message +from proton import SSLDomain class QdSSLUseridTest(TestCase): @@ -313,5 +313,6 @@ def test_ssl_user_id(self): node.close() + if __name__ == '__main__': unittest.main(main_module()) diff --git a/tests/system_tests_user_id_proxy.py b/tests/system_tests_user_id_proxy.py index 409aaf1a1a..09d2d40882 100644 --- a/tests/system_tests_user_id_proxy.py +++ b/tests/system_tests_user_id_proxy.py @@ -19,13 +19,13 @@ import os -import unittest +import unittest2 as unittest from system_test import TestCase, Qdrouterd, DIR, main_module -from qpid_dispatch.management.client import Node import proton -from proton import SSLDomain, Message, ProtonException, Delivery +from proton import SSLDomain, Delivery from proton.utils import BlockingConnection + class QdSSLUseridTest(TestCase): @staticmethod