diff options
author | Alan Conway <aconway@apache.org> | 2009-04-09 16:17:39 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2009-04-09 16:17:39 +0000 |
commit | 66842ae89dbba038937bb3a1da641c24c7a1dcd1 (patch) | |
tree | bd128598d364e0804ec858fa2097a559908e894e /cpp/src | |
parent | 1d83d8d68ff636ddb2cae02629563558174d621a (diff) | |
download | qpid-python-66842ae89dbba038937bb3a1da641c24c7a1dcd1.tar.gz |
Add durability option to the cpp failover_soak test.
From Mick Goulish: https://issues.apache.org/jira/browse/QPID-1796,
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@763722 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/tests/declare_queues.cpp | 10 | ||||
-rw-r--r-- | cpp/src/tests/failover_soak.cpp | 40 | ||||
-rw-r--r-- | cpp/src/tests/replaying_sender.cpp | 20 | ||||
-rwxr-xr-x | cpp/src/tests/run_failover_soak | 3 |
4 files changed, 54 insertions, 19 deletions
diff --git a/cpp/src/tests/declare_queues.cpp b/cpp/src/tests/declare_queues.cpp index 7f61bde12a..d17a72b940 100644 --- a/cpp/src/tests/declare_queues.cpp +++ b/cpp/src/tests/declare_queues.cpp @@ -33,14 +33,15 @@ using namespace std; int main(int argc, char ** argv) { ConnectionSettings settings; - if ( argc != 3 ) + if ( argc != 4 ) { - cerr << "Usage: declare_queues host port\n"; + cerr << "Usage: declare_queues host port durability\n"; return 1; } settings.host = argv[1]; settings.port = atoi(argv[2]); + int durability = atoi(argv[3]); FailoverManager connection(settings); try { @@ -48,7 +49,10 @@ int main(int argc, char ** argv) while (!complete) { Session session = connection.connect().newSession(); try { - session.queueDeclare(arg::queue="message_queue"); + if ( durability ) + session.queueDeclare(arg::queue="message_queue", arg::durable=true); + else + session.queueDeclare(arg::queue="message_queue"); complete = true; } catch (const qpid::TransportFailure&) {} } diff --git a/cpp/src/tests/failover_soak.cpp b/cpp/src/tests/failover_soak.cpp index 5636268c95..18d693e5ec 100644 --- a/cpp/src/tests/failover_soak.cpp +++ b/cpp/src/tests/failover_soak.cpp @@ -370,7 +370,8 @@ void startNewBroker ( brokerVector & brokers, char const * moduleOrDir, string const clusterName, - int verbosity ) + int verbosity, + int durable ) { static int brokerId = 0; stringstream path, prefix; @@ -394,6 +395,9 @@ startNewBroker ( brokerVector & brokers, // Module path specified, load only that module. argv.push_back(string("--load-module=")+moduleOrDir); argv.push_back("--no-module-dir"); + if ( durable ) { + std::cerr << "failover_soak warning: durable arg hass no effect. Use \"dir\" option of \"moduleOrDir\".\n"; + } } else { // Module directory specified, load all modules in dir. @@ -483,7 +487,8 @@ pid_t runDeclareQueuesClient ( brokerVector brokers, char const * host, char const * path, - int verbosity + int verbosity, + int durable ) { string name("declareQueues"); @@ -502,6 +507,10 @@ runDeclareQueuesClient ( brokerVector brokers, argv.push_back ( "declareQueues" ); argv.push_back ( host ); argv.push_back ( portSs.str().c_str() ); + if ( durable ) + argv.push_back ( "1" ); + else + argv.push_back ( "0" ); argv.push_back ( 0 ); pid_t pid = fork(); @@ -572,7 +581,8 @@ startSendingClient ( brokerVector brokers, char const * senderPath, char const * nMessages, char const * reportFrequency, - int verbosity + int verbosity, + int durability ) { string name("sender"); @@ -596,6 +606,10 @@ startSendingClient ( brokerVector brokers, argv.push_back ( nMessages ); argv.push_back ( reportFrequency ); argv.push_back ( verbosityStr ); + if ( durability ) + argv.push_back ( "1" ); + else + argv.push_back ( "0" ); argv.push_back ( 0 ); pid_t pid = fork(); @@ -623,14 +637,18 @@ startSendingClient ( brokerVector brokers, #define ERROR_KILLING_BROKER 8 +// If you want durability, use the "dir" option of "moduleOrDir" . + + int main ( int argc, char const ** argv ) { - if ( argc != 8 ) { + if ( argc != 9 ) { cerr << "Usage: " << argv[0] - << "moduleOrDir declareQueuesPath senderPath receiverPath nMessages reportFrequency verbosity" + << "moduleOrDir declareQueuesPath senderPath receiverPath nMessages reportFrequency verbosity durable" << endl; + cerr << "\tverbosity is an integer, durable is 0 or 1\n"; return BAD_ARGS; } signal ( SIGCHLD, childExit ); @@ -643,6 +661,7 @@ main ( int argc, char const ** argv ) char const * nMessages = argv[i++]; char const * reportFrequency = argv[i++]; int verbosity = atoi(argv[i++]); + int durable = atoi(argv[i++]); char const * host = "127.0.0.1"; int maxBrokers = 50; @@ -665,7 +684,8 @@ main ( int argc, char const ** argv ) startNewBroker ( brokers, moduleOrDir, clusterName, - verbosity ); + verbosity, + durable ); } @@ -675,7 +695,7 @@ main ( int argc, char const ** argv ) // Run the declareQueues child. int childStatus; pid_t dqClientPid = - runDeclareQueuesClient ( brokers, host, declareQueuesPath, verbosity ); + runDeclareQueuesClient ( brokers, host, declareQueuesPath, verbosity, durable ); if ( -1 == dqClientPid ) { cerr << "END_OF_TEST ERROR_START_DECLARE_1\n"; return CANT_FORK_DQ; @@ -711,7 +731,8 @@ main ( int argc, char const ** argv ) senderPath, nMessages, reportFrequency, - verbosity ); + verbosity, + durable ); if ( -1 == sendingClientPid ) { cerr << "END_OF_TEST ERROR_START_SENDER\n"; return CANT_FORK_SENDER; @@ -757,7 +778,8 @@ main ( int argc, char const ** argv ) startNewBroker ( brokers, moduleOrDir, clusterName, - verbosity ); + verbosity, + durable ); if ( verbosity > 1 ) printBrokers ( brokers ); diff --git a/cpp/src/tests/replaying_sender.cpp b/cpp/src/tests/replaying_sender.cpp index ea2a13bd54..3ee69eec14 100644 --- a/cpp/src/tests/replaying_sender.cpp +++ b/cpp/src/tests/replaying_sender.cpp @@ -40,9 +40,10 @@ class Sender : public FailoverManager::Command public: Sender(const std::string& queue, uint count, uint reportFreq); void execute(AsyncSession& session, bool isRetry); - uint getSent(); + uint getSent(); - int verbosity; + void setVerbosity ( int v ) { verbosity = v; } + void setPersistence ( int p ) { persistence = p; } private: MessageReplayTracker sender; @@ -51,9 +52,11 @@ class Sender : public FailoverManager::Command const uint reportFrequency; Message message; + int verbosity; + int persistence; }; -Sender::Sender(const std::string& queue, uint count_, uint reportFreq ) : sender(10), count(count_), sent(0), reportFrequency(reportFreq) +Sender::Sender(const std::string& queue, uint count_, uint reportFreq ) : sender(10), count(count_), sent(0), reportFrequency(reportFreq), verbosity(0), persistence(0) { message.getDeliveryProperties().setRoutingKey(queue); } @@ -69,6 +72,9 @@ void Sender::execute(AsyncSession& session, bool isRetry) message_data << ++sent; message.setData(message_data.str()); message.getHeaders().setInt("sn", sent); + if ( persistence ) + message.getDeliveryProperties().setDeliveryMode(PERSISTENT); + sender.send(message); if (count > reportFrequency && !(sent % reportFrequency)) { if ( verbosity > 0 ) @@ -91,9 +97,9 @@ int main(int argc, char ** argv) { ConnectionSettings settings; - if ( argc != 6 ) + if ( argc != 7 ) { - std::cerr << "Usage: replaying_sender host port n_messages report_frequency verbosity\n"; + std::cerr << "Usage: replaying_sender host port n_messages report_frequency verbosity persistence\n"; return 1; } @@ -102,10 +108,12 @@ int main(int argc, char ** argv) int n_messages = atoi(argv[3]); int reportFrequency = atoi(argv[4]); int verbosity = atoi(argv[5]); + int persistence = atoi(argv[6]); FailoverManager connection(settings); Sender sender("message_queue", n_messages, reportFrequency ); - sender.verbosity = verbosity; + sender.setVerbosity ( verbosity ); + sender.setPersistence ( persistence ); try { connection.execute ( sender ); if ( verbosity > 0 ) diff --git a/cpp/src/tests/run_failover_soak b/cpp/src/tests/run_failover_soak index ec8534e0b8..cf9646ac58 100755 --- a/cpp/src/tests/run_failover_soak +++ b/cpp/src/tests/run_failover_soak @@ -49,6 +49,7 @@ MODULES=../.libs MESSAGES=${MESSAGES:-300000} REPORT_FREQUENCY=${REPORT_FREQUENCY:-`expr $MESSAGES / 20`} VERBOSITY=${VERBOSITY:-1} +DURABILITY=${DURABILITY:-0} -exec ./failover_soak $MODULES ./declare_queues ./replaying_sender ./resuming_receiver $MESSAGES $REPORT_FREQUENCY $VERBOSITY +exec ./failover_soak $MODULES ./declare_queues ./replaying_sender ./resuming_receiver $MESSAGES $REPORT_FREQUENCY $VERBOSITY $DURABILITY |