diff options
author | Carl C. Trieloff <cctrieloff@apache.org> | 2009-07-08 20:02:36 +0000 |
---|---|---|
committer | Carl C. Trieloff <cctrieloff@apache.org> | 2009-07-08 20:02:36 +0000 |
commit | 16fa5efeecd8a6ae4288342899372235ce688890 (patch) | |
tree | b61bc939e3ceb1ffe12e325a287fffd67310fb5e /cpp/src/tests/QueueTest.cpp | |
parent | 15a5da23e5a68edea6cd0056a63d988d5046bf8a (diff) | |
download | qpid-python-16fa5efeecd8a6ae4288342899372235ce688890.tar.gz |
simulate this:
1. start two nodes
2. create cluster durable queue and add some messages
3. kill one node (trigger force-persistent behaviour)
4. stop and recover remaining node
5. add another node
6. kill that new node again
make sure that an attempt to re-enqueue a message does not happen which will
result in the last man standing exiting with an error.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@792286 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/QueueTest.cpp')
-rw-r--r-- | cpp/src/tests/QueueTest.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/cpp/src/tests/QueueTest.cpp b/cpp/src/tests/QueueTest.cpp index 1d4ba968e5..abeb0fb80e 100644 --- a/cpp/src/tests/QueueTest.cpp +++ b/cpp/src/tests/QueueTest.cpp @@ -646,6 +646,48 @@ QPID_AUTO_TEST_CASE(testMultiQueueLastNode){ BOOST_CHECK_EQUAL(testStore.enqCnt, 8u); } +QPID_AUTO_TEST_CASE(testLastNodeRecoverAndFail){ +/* +simulate this: + 1. start two nodes + 2. create cluster durable queue and add some messages + 3. kill one node (trigger force-persistent behaviour) + 4. stop and recover remaining node + 5. add another node + 6. kill that new node again +make sure that an attempt to re-enqueue a message does not happen which will +result in the last man standing exiting with an error. + +we need to make sure that recover is safe, i.e. messages are +not requeued to the store. +*/ + TestMessageStoreOC testStore; + client::QueueOptions args; + // set queue mode + args.setPersistLastNode(); + + Queue::shared_ptr queue1(new Queue("my-queue", true, &testStore)); + intrusive_ptr<Message> received; + queue1->configure(args); + + // check requeue 1 + intrusive_ptr<Message> msg1 = create_message("e", "C"); + intrusive_ptr<Message> msg2 = create_message("e", "D"); + + queue1->recover(msg1); + + queue1->setLastNodeFailure(); + BOOST_CHECK_EQUAL(testStore.enqCnt, 0u); + + queue1->clearLastNodeFailure(); + BOOST_CHECK_EQUAL(testStore.enqCnt, 0u); + + queue1->deliver(msg2); + BOOST_CHECK_EQUAL(testStore.enqCnt, 0u); + queue1->setLastNodeFailure(); + BOOST_CHECK_EQUAL(testStore.enqCnt, 1u); + +} QPID_AUTO_TEST_SUITE_END() |