summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/src/tests')
-rw-r--r--qpid/cpp/src/tests/CMakeLists.txt3
-rw-r--r--qpid/cpp/src/tests/Makefile.am4
-rw-r--r--qpid/cpp/src/tests/brokertest.py2
-rwxr-xr-xqpid/cpp/src/tests/interlink_tests.py157
-rwxr-xr-xqpid/cpp/src/tests/run_interlink_tests26
-rw-r--r--qpid/cpp/src/tests/test_env.sh.in2
6 files changed, 193 insertions, 1 deletions
diff --git a/qpid/cpp/src/tests/CMakeLists.txt b/qpid/cpp/src/tests/CMakeLists.txt
index 7a418993d5..f77863a146 100644
--- a/qpid/cpp/src/tests/CMakeLists.txt
+++ b/qpid/cpp/src/tests/CMakeLists.txt
@@ -324,6 +324,9 @@ endif (PYTHON_EXECUTABLE)
add_test (stop_broker ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/stop_broker${test_script_suffix})
if (PYTHON_EXECUTABLE)
add_test (ha_tests ${test_wrap} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ha_tests.py)
+ if (BUILD_AMQP)
+ add_test (interlink_tests ${test_wrap} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/interlink_tests.py)
+ endif (BUILD_AMQP)
if (BUILD_LEGACYSTORE)
add_test (ha_store_tests ${test_wrap} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ha_store_tests.py)
endif (BUILD_LEGACYSTORE)
diff --git a/qpid/cpp/src/tests/Makefile.am b/qpid/cpp/src/tests/Makefile.am
index 69ca01a934..2e55b24c3e 100644
--- a/qpid/cpp/src/tests/Makefile.am
+++ b/qpid/cpp/src/tests/Makefile.am
@@ -297,7 +297,7 @@ TESTS_ENVIRONMENT = \
system_tests = qpid-client-test quick_perftest quick_topictest run_header_test quick_txtest \
run_msg_group_tests
TESTS += start_broker $(system_tests) python_tests stop_broker \
- run_ha_tests run_federation_tests run_federation_sys_tests \
+ run_ha_tests run_interlink_tests run_federation_tests run_federation_sys_tests \
run_acl_tests run_cli_tests dynamic_log_level_test \
dynamic_log_hires_timestamp run_queue_flow_limit_tests ipv6_test
@@ -346,6 +346,8 @@ EXTRA_DIST += \
run_ha_tests \
ha_test.py \
ha_tests.py \
+ run_interlink_tests \
+ interlink_tests.py \
brokertest.py \
ha_store_tests.py \
test_env.ps1.in
diff --git a/qpid/cpp/src/tests/brokertest.py b/qpid/cpp/src/tests/brokertest.py
index 70c145a51b..af1edfee44 100644
--- a/qpid/cpp/src/tests/brokertest.py
+++ b/qpid/cpp/src/tests/brokertest.py
@@ -427,6 +427,8 @@ class BrokerTest(TestCase):
qpidd_exec = os.path.abspath(checkenv("QPIDD_EXEC"))
ha_lib = os.getenv("HA_LIB")
xml_lib = os.getenv("XML_LIB")
+ amqp_lib = os.getenv("AMQP_LIB")
+ amqpc_lib = os.getenv("AMQPC_LIB")
qpid_config_exec = os.getenv("QPID_CONFIG_EXEC")
qpid_route_exec = os.getenv("QPID_ROUTE_EXEC")
receiver_exec = os.getenv("RECEIVER_EXEC")
diff --git a/qpid/cpp/src/tests/interlink_tests.py b/qpid/cpp/src/tests/interlink_tests.py
new file mode 100755
index 0000000000..1e7262051a
--- /dev/null
+++ b/qpid/cpp/src/tests/interlink_tests.py
@@ -0,0 +1,157 @@
+#!/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, signal, sys, time, imp, re, subprocess, glob, random, logging, shutil, math, unittest, random
+import traceback
+from qpid.messaging import Message, SessionError, NotFound, ConnectionError, ReceiverError, Connection, Timeout, Disposition, REJECTED, Empty
+from qpid.datatypes import uuid4
+from brokertest import *
+from threading import Thread, Lock, Condition
+from logging import getLogger, WARN, ERROR, DEBUG, INFO
+from qpidtoollibs import BrokerAgent, BrokerObject
+from uuid import UUID
+
+class Domain(BrokerObject):
+ def __init__(self, broker, values):
+ BrokerObject.__init__(self, broker, values)
+
+class Config:
+ def __init__(self, broker, address="q;{create:always}", version="amqp1.0"):
+ self.url = broker.host_port()
+ self.address = address
+ self.version = version
+
+ def __str__(self):
+ return "url: %s, address: %s, version: %s" % (self.url, self.address, self.version)
+
+class AmqpBrokerTest(BrokerTest):
+ """
+ Tests using AMQP 1.0 support
+ """
+ def setUp(self):
+ BrokerTest.setUp(self)
+ os.putenv("QPID_LOAD_MODULE", BrokerTest.amqpc_lib)
+ self.broker = self.amqp_broker()
+ self.default_config = Config(self.broker)
+ self.agent = BrokerAgent(self.broker.connect())
+
+ def sender(self, config):
+ cmd = ["qpid-send",
+ "--broker", config.url,
+ "--address", config.address,
+ "--connection-options", "{protocol:%s}" % config.version,
+ "--content-stdin", "--send-eos=1"
+ ]
+ return self.popen(cmd, stdin=PIPE)
+
+ def receiver(self, config):
+ cmd = ["qpid-receive",
+ "--broker", config.url,
+ "--address", config.address,
+ "--connection-options", "{protocol:%r}" % config.version,
+ "--timeout=10"
+ ]
+ return self.popen(cmd, stdout=PIPE)
+
+ def send_and_receive(self, send_config=None, recv_config=None, count=1000, debug=False):
+ if debug:
+ print "sender config is %s" % (send_config or self.default_config)
+ print "receiver config is %s" % (recv_config or self.default_config)
+ sender = self.sender(send_config or self.default_config)
+ receiver = self.receiver(recv_config or self.default_config)
+
+ messages = ["message-%s" % (i+1) for i in range(count)]
+ for m in messages:
+ sender.stdin.write(m + "\n")
+ sender.stdin.flush()
+ sender.stdin.close()
+ if debug:
+ c = send_config or self.default_config
+ print "sent %s messages to %s sn %s" % (len(messages), c.address, c.url)
+
+ if debug:
+ c = recv_config or self.default_config
+ print "reading messages from %s sn %s" % (c.address, c.url)
+ for m in messages:
+ l = receiver.stdout.readline().rstrip()
+ if debug:
+ print l
+ assert m == l, (m, l)
+
+ sender.wait()
+ receiver.wait()
+
+ def test_simple(self):
+ self.send_and_receive()
+
+ def test_translate1(self):
+ self.send_and_receive(recv_config=Config(self.broker, version="amqp0-10"))
+
+ def test_translate2(self):
+ self.send_and_receive(send_config=Config(self.broker, version="amqp0-10"))
+
+ def test_domain(self):
+ brokerB = self.amqp_broker()
+ self.agent.create("domain", "BrokerB", {"url":brokerB.host_port()})
+ domains = self.agent._getAllBrokerObjects(Domain)
+ assert len(domains) == 1
+ assert domains[0].name == "BrokerB"
+
+ def test_incoming_link(self):
+ brokerB = self.amqp_broker()
+ agentB = BrokerAgent(brokerB.connect())
+ self.agent.create("queue", "q")
+ agentB.create("queue", "q")
+ self.agent.create("domain", "BrokerB", {"url":brokerB.host_port(), "sasl_mechanisms":"NONE"})
+ self.agent.create("incoming", "Link1", {"domain":"BrokerB","source":"q","target":"q"})
+ #send to brokerB, receive from brokerA
+ self.send_and_receive(send_config=Config(brokerB))
+
+ def test_outgoing_link(self):
+ brokerB = self.amqp_broker()
+ agentB = BrokerAgent(brokerB.connect())
+ self.agent.create("queue", "q")
+ agentB.create("queue", "q")
+ self.agent.create("domain", "BrokerB", {"url":brokerB.host_port(), "sasl_mechanisms":"NONE"})
+ self.agent.create("outgoing", "Link1", {"domain":"BrokerB","source":"q","target":"q"})
+ #send to brokerA, receive from brokerB
+ self.send_and_receive(recv_config=Config(brokerB))
+
+ def test_relay(self):
+ brokerB = self.amqp_broker()
+ agentB = BrokerAgent(brokerB.connect())
+ agentB.create("queue", "q")
+ self.agent.create("domain", "BrokerB", {"url":brokerB.host_port(), "sasl_mechanisms":"NONE"})
+ #send to q on broker B through brokerA
+ self.send_and_receive(send_config=Config(self.broker, address="q@BrokerB"), recv_config=Config(brokerB))
+
+ """ Create and return a broker with AMQP 1.0 support """
+ def amqp_broker(self):
+ assert BrokerTest.amqp_lib, "Cannot locate AMQP 1.0 plug-in"
+ args = ["--load-module", BrokerTest.amqp_lib,
+ "--max-negotiate-time=600000",
+ "--log-enable=trace+:Protocol",
+ "--log-enable=info+"]
+ return BrokerTest.broker(self, args)
+
+if __name__ == "__main__":
+ shutil.rmtree("brokertest.tmp", True)
+ os.execvp("qpid-python-test",
+ ["qpid-python-test", "-m", "interlink_tests"] + sys.argv[1:])
diff --git a/qpid/cpp/src/tests/run_interlink_tests b/qpid/cpp/src/tests/run_interlink_tests
new file mode 100755
index 0000000000..6c61bdd654
--- /dev/null
+++ b/qpid/cpp/src/tests/run_interlink_tests
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+#
+# 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.
+#
+
+test -e "$AMQP_LIB" || { echo "Skipping AMQP 1.0 based tests; AMQP 1.0 support not available."; exit 0; }
+
+srcdir=`dirname $0`
+$srcdir/interlink_tests.py
+
diff --git a/qpid/cpp/src/tests/test_env.sh.in b/qpid/cpp/src/tests/test_env.sh.in
index 0f8f834731..6940943b54 100644
--- a/qpid/cpp/src/tests/test_env.sh.in
+++ b/qpid/cpp/src/tests/test_env.sh.in
@@ -68,6 +68,8 @@ exportmodule SSL_LIB ssl.so
exportmodule WATCHDOG_LIB watchdog.so
exportmodule XML_LIB xml.so
exportmodule STORE_LIB legacystore.so
+exportmodule AMQP_LIB amqp.so
+exportmodule AMQPC_LIB amqpc.so
# Qpid options
export QPID_NO_MODULE_DIR=1 # Don't accidentally load installed modules