diff options
| author | Keith Wall <kwall@apache.org> | 2015-02-10 16:15:08 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2015-02-10 16:15:08 +0000 |
| commit | 085486ebe5ff21133b9caf1c31625ac6ea356568 (patch) | |
| tree | 7acbe9ca99a345dca71f9f80cd3e29ea4e3710f0 /qpid/cpp/src/tests | |
| parent | 60c62c03ca404e98e4fbd1abf4a5ebf50763d604 (diff) | |
| parent | e2e6d542b8cde9e702d1c3b63376e9d8380ba1c7 (diff) | |
| download | qpid-python-085486ebe5ff21133b9caf1c31625ac6ea356568.tar.gz | |
merge from trunk
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/QPID-6262-JavaBrokerNIO@1658748 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests')
| -rw-r--r-- | qpid/cpp/src/tests/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | qpid/cpp/src/tests/TimerTest.cpp | 2 | ||||
| -rwxr-xr-x | qpid/cpp/src/tests/idle_timeout_tests.py | 95 |
3 files changed, 97 insertions, 1 deletions
diff --git a/qpid/cpp/src/tests/CMakeLists.txt b/qpid/cpp/src/tests/CMakeLists.txt index 08a8c69d69..c914c50e33 100644 --- a/qpid/cpp/src/tests/CMakeLists.txt +++ b/qpid/cpp/src/tests/CMakeLists.txt @@ -364,6 +364,7 @@ add_test (ha_tests ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/ha_tests.py) add_test (qpidd_qmfv2_tests ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/qpidd_qmfv2_tests.py) if (BUILD_AMQP) add_test (interlink_tests ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/interlink_tests.py) + add_test (idle_timeout_tests ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/idle_timeout_tests.py) endif (BUILD_AMQP) add_test (swig_python_tests ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/swig_python_tests${test_script_suffix}) add_test (ipv6_test ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/ipv6_test${test_script_suffix}) diff --git a/qpid/cpp/src/tests/TimerTest.cpp b/qpid/cpp/src/tests/TimerTest.cpp index e9ca3fcdf6..d28eeeffc1 100644 --- a/qpid/cpp/src/tests/TimerTest.cpp +++ b/qpid/cpp/src/tests/TimerTest.cpp @@ -82,7 +82,7 @@ class TestTask : public TimerTask uint64_t difference = _abs64(expected - actual); #elif defined(_WIN32) uint64_t difference = labs(expected - actual); -#elif defined(__SUNPRO_CC) +#elif defined(__SUNPRO_CC) || defined (__IBMCPP__) uint64_t difference = llabs(expected - actual); #else uint64_t difference = abs(expected - actual); diff --git a/qpid/cpp/src/tests/idle_timeout_tests.py b/qpid/cpp/src/tests/idle_timeout_tests.py new file mode 100755 index 0000000000..c3cc00746b --- /dev/null +++ b/qpid/cpp/src/tests/idle_timeout_tests.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python + +# 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. +# + +import os +import shutil +import signal +import sys + +from brokertest import * + +class AmqpIdleTimeoutTest(BrokerTest): + """ + Test AMQP 1.0 idle-timeout support + """ + def setUp(self): + BrokerTest.setUp(self) + if not BrokerTest.amqp_lib: + raise Skipped("AMQP 1.0 library not found") + if qm != qpid_messaging: + raise Skipped("AMQP 1.0 client not found") + self._broker = self.broker() + + def test_client_timeout(self): + """Ensure that the client disconnects should the broker stop + responding. + """ + conn = self._broker.connect(native=False, timeout=None, + protocol="amqp1.0", heartbeat=1) + self.assertTrue(conn.isOpen()) + # should disconnect within 2 seconds of broker stop + deadline = time.time() + 8 + os.kill(self._broker.pid, signal.SIGSTOP) + while time.time() < deadline: + if not conn.isOpen(): + break; + self.assertTrue(not conn.isOpen()) + os.kill(self._broker.pid, signal.SIGCONT) + + + def test_broker_timeout(self): + """By default, the broker will adopt the same timeout as the client + (mimics the 0-10 timeout behavior). Verify the broker disconnects + unresponsive clients. + """ + + count = len(self._broker.agent.getAllConnections()) + + # Create a new connection to the broker: + receiver_cmd = ["qpid-receive", + "--broker", self._broker.host_port(), + "--address=amq.fanout", + "--connection-options={protocol:amqp1.0, heartbeat:1}", + "--forever"] + receiver = self.popen(receiver_cmd, stdout=PIPE, stderr=PIPE, + expect=EXPECT_UNKNOWN) + start = time.time() + deadline = time.time() + 10 + while time.time() < deadline: + if count < len(self._broker.agent.getAllConnections()): + break; + self.assertTrue(count < len(self._broker.agent.getAllConnections())) + + # now 'hang' the client, the broker should disconnect + start = time.time() + receiver.send_signal(signal.SIGSTOP) + deadline = time.time() + 10 + while time.time() < deadline: + if count == len(self._broker.agent.getAllConnections()): + break; + self.assertEqual(count, len(self._broker.agent.getAllConnections())) + receiver.send_signal(signal.SIGCONT) + receiver.teardown() + + +if __name__ == "__main__": + shutil.rmtree("brokertest.tmp", True) + os.execvp("qpid-python-test", + ["qpid-python-test", "-m", "idle_timeout_tests"] + sys.argv[1:]) |
