diff options
| author | Alan Conway <aconway@apache.org> | 2007-07-24 19:39:27 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2007-07-24 19:39:27 +0000 |
| commit | c2efe8deabde635f07e78d438fc529ca67d34133 (patch) | |
| tree | 5a72156552781e1044dbecfb7ae41b71be51a6c7 /qpid/cpp/src/tests | |
| parent | f6ce4582d32b38dee7139dd286a7abcc4f8695cc (diff) | |
| download | qpid-python-c2efe8deabde635f07e78d438fc529ca67d34133.tar.gz | |
* Summary:
- Wiring (declare/delete/bind) is replicated via AIS.
- TestOptions includes all logging options.
- Logger automatically parses env vars so logging can be enabled
for any program linked with libqpidcommon e.g. by setting QPID_TRACE=1.
* src/qpid/cluster/SessionManager.cpp: Handle frames from cluster
- Forward to BrokerAdapter for execution.
- Suppress responses in proxy.
* src/tests/TestOptions.h (Options): Logging options, --help option.
* src/qpid/client/ClientConnection.cpp: Removed log initialization.
Logs are initialized either in TestOptions or automatically from env vars,
e.g. QPID_TRACE,
* src/qpid/QpidError.h (class QpidError): Initialize Exception in
constructor so messages can be logged.
* src/qpid/framing/ChannelAdapter.h: Made send() virtual.
* src/tests/Cluster_child.cpp: UUID corrected.
* src/qpid/broker/Broker.cpp: Pass chains to updater by ref.
* src/qpid/Options.cpp (parse): Fix log settings from environment.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@559171 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests')
| -rw-r--r-- | qpid/cpp/src/tests/Cluster.h | 4 | ||||
| -rw-r--r-- | qpid/cpp/src/tests/Cluster_child.cpp | 5 | ||||
| -rw-r--r-- | qpid/cpp/src/tests/TestOptions.h | 26 | ||||
| -rw-r--r-- | qpid/cpp/src/tests/cluster_client.cpp | 19 | ||||
| -rwxr-xr-x | qpid/cpp/src/tests/start_cluster | 8 | ||||
| -rwxr-xr-x | qpid/cpp/src/tests/stop_cluster | 4 |
6 files changed, 45 insertions, 21 deletions
diff --git a/qpid/cpp/src/tests/Cluster.h b/qpid/cpp/src/tests/Cluster.h index c2909e0c1b..e896fccafe 100644 --- a/qpid/cpp/src/tests/Cluster.h +++ b/qpid/cpp/src/tests/Cluster.h @@ -64,9 +64,9 @@ class TestHandler : public Handler<T&>, public vector<T> Mutex::ScopedLock l(lock); BOOST_MESSAGE(getpid()<<" TestHandler::waitFor("<<n<<") "<<this->size()); AbsTime deadline(now(), 2*TIME_SEC); - while (vector<T>::size() < n && lock.wait(deadline)) + while (this->size() < n && lock.wait(deadline)) ; - return vector<T>::size() >= n; + return this->size() >= n; } }; diff --git a/qpid/cpp/src/tests/Cluster_child.cpp b/qpid/cpp/src/tests/Cluster_child.cpp index 9c119e5238..c509dc1950 100644 --- a/qpid/cpp/src/tests/Cluster_child.cpp +++ b/qpid/cpp/src/tests/Cluster_child.cpp @@ -32,15 +32,14 @@ static const ProtocolVersion VER; /** Chlid part of Cluster::clusterTwo test */ void clusterTwo() { - TestCluster cluster("clusterTwo", "amqp::2"); + TestCluster cluster("clusterTwo", "amqp:child:2"); BOOST_REQUIRE(cluster.received.waitFor(1)); // Frame from parent. BOOST_CHECK(cluster.received[0].isIncoming); BOOST_CHECK_TYPEID_EQUAL(ChannelPingBody, *cluster.received[0].frame.getBody()); BOOST_CHECK_EQUAL(2u, cluster.size()); // Me and parent AMQFrame frame(VER, 1, new ChannelOkBody(VER)); - Uuid id(true); - SessionFrame sf(id, frame, false); + SessionFrame sf(cluster.received[0].uuid, frame, false); cluster.handle(sf); BOOST_REQUIRE(cluster.received.waitFor(2)); BOOST_CHECK(!cluster.received[1].isIncoming); diff --git a/qpid/cpp/src/tests/TestOptions.h b/qpid/cpp/src/tests/TestOptions.h index ee3af0873a..5b3c0958f5 100644 --- a/qpid/cpp/src/tests/TestOptions.h +++ b/qpid/cpp/src/tests/TestOptions.h @@ -22,13 +22,18 @@ */ #include "qpid/Options.h" +#include "qpid/log/Options.h" #include "qpid/Url.h" +#include "qpid/log/Logger.h" + +#include <iostream> +#include <exception> namespace qpid { struct TestOptions : public qpid::Options { - TestOptions() : Options("Test Options"), host("localhost"), port(TcpAddress::DEFAULT_PORT), clientid("cpp"), trace(false), help(false) + TestOptions() : Options("Test Options"), host("localhost"), port(TcpAddress::DEFAULT_PORT), clientid("cpp"), help(false) { addOptions() ("host,h", optValue(host, "HOST"), "Broker host to connect to") @@ -39,10 +44,26 @@ struct TestOptions : public qpid::Options ("clientname,n", optValue(clientid, "ID"), "unique client identifier") ("username", optValue(username, "USER"), "user name for broker log in.") ("password", optValue(password, "USER"), "password for broker log in.") - ("trace,t", optValue(trace), "Turn on debug tracing.") ("help", optValue(help), "print this usage statement"); + add(log); } + /** As well as parsing, print help & exit if required */ + void parse(int argc, char** argv) { + try { + qpid::Options::parse(argc, argv); + } catch (const std::exception& e) { + std::cout << e.what() << std::endl << *this << std::endl; + exit(1); + } + if (help) { + std::cout << *this << std::endl; + exit(0); + } + trace = log.trace; + qpid::log::Logger::instance().configure(log, argv[0]); + } + std::string host; uint16_t port; std::string virtualhost; @@ -51,6 +72,7 @@ struct TestOptions : public qpid::Options std::string password; bool trace; bool help; + log::Options log; }; } diff --git a/qpid/cpp/src/tests/cluster_client.cpp b/qpid/cpp/src/tests/cluster_client.cpp index 421a33a40a..7620faa9fa 100644 --- a/qpid/cpp/src/tests/cluster_client.cpp +++ b/qpid/cpp/src/tests/cluster_client.cpp @@ -52,6 +52,7 @@ struct ClusterConnections : public vector<shared_ptr<Connection> > { }; BOOST_AUTO_TEST_CASE(testWiringReplication) { + // Declare on one broker, use on others. ClusterConnections cluster; BOOST_REQUIRE(cluster.size() > 1); @@ -63,13 +64,17 @@ BOOST_AUTO_TEST_CASE(testWiringReplication) { broker0.declareExchange(fooEx); broker0.declareQueue(fooQ); broker0.bind(fooEx, fooQ, "FooKey"); - - Channel broker1; - cluster[1]->openChannel(broker1); - broker1.publish(Message("hello"), fooEx, "FooKey"); - Message m; - BOOST_REQUIRE(broker1.get(m, fooQ)); - BOOST_REQUIRE_EQUAL(m.getData(), "hello"); + broker0.close(); + + for (size_t i = 1; i < cluster.size(); ++i) { + Channel ch; + cluster[i]->openChannel(ch); + ch.publish(Message("hello"), fooEx, "FooKey"); + Message m; + BOOST_REQUIRE(ch.get(m, fooQ)); + BOOST_REQUIRE_EQUAL(m.getData(), "hello"); + ch.close(); + } } diff --git a/qpid/cpp/src/tests/start_cluster b/qpid/cpp/src/tests/start_cluster index c2806bb225..8f44854978 100755 --- a/qpid/cpp/src/tests/start_cluster +++ b/qpid/cpp/src/tests/start_cluster @@ -6,14 +6,14 @@ test -f cluster.ports && { echo "cluster.ports file already exists" ; exit 1; } test -z "$*" && { echo "Usage: $0 cluster-size [options]"; exit 1; } +rm -f cluster*.log cluster.ports SIZE=$1 shift OPTS=$* - +CLUSTER=`whoami` # Cluster name=user name, avoid clashes. for (( i=0; i<SIZE; ++i )); do - PORT=`../qpidd -dp0 --log.output=broker$i.log $OPTS` || exit 1 - PORTS="$PORT $PORTS" + PORT=`../qpidd -dp0 --log.output=cluster$i.log --cluster $CLUSTER $OPTS` || exit 1 + echo $PORT >> cluster.ports done -echo $PORTS > cluster.ports diff --git a/qpid/cpp/src/tests/stop_cluster b/qpid/cpp/src/tests/stop_cluster index f5db5a4488..6afcb527e5 100755 --- a/qpid/cpp/src/tests/stop_cluster +++ b/qpid/cpp/src/tests/stop_cluster @@ -6,11 +6,9 @@ PORTS=`cat cluster.ports` for PORT in $PORTS ; do ../qpidd -qp $PORT || ERROR="$ERROR $PORT" done +rm -f cluster.ports if [ -n "$ERROR" ]; then echo "Errors stopping brokers on ports: $ERROR" - echo $ERROR > cluster.ports exit 1 -else - rm cluster.ports fi |
