From 7c771eec9869c897b4b41caf1aa4e5978242c13d Mon Sep 17 00:00:00 2001 From: "Carl C. Trieloff" Date: Wed, 8 Jul 2009 18:58:27 +0000 Subject: fix for regression in patch & test to prevent regression again Simulate this: 1. start 2 nodes 2. create cluster durable lvq 3. send a transient message to the queue 4. kill one of the nodes (to trigger force persistent behaviour)... 5. then restart it (to turn off force persistent behaviour) 6. send another transient message with same lvq key as in 3 7. kill the second node again (retrigger force persistent) 8. stop and recover the first node git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@792259 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/QueueTest.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'cpp/src/tests/QueueTest.cpp') diff --git a/cpp/src/tests/QueueTest.cpp b/cpp/src/tests/QueueTest.cpp index 5aad3da7dd..1d4ba968e5 100644 --- a/cpp/src/tests/QueueTest.cpp +++ b/cpp/src/tests/QueueTest.cpp @@ -488,6 +488,53 @@ QPID_AUTO_TEST_CASE(testLVQMultiQueue){ } +QPID_AUTO_TEST_CASE(testLVQRecover){ + +/* simulate this + 1. start 2 nodes + 2. create cluster durable lvq + 3. send a transient message to the queue + 4. kill one of the nodes (to trigger force persistent behaviour)... + 5. then restart it (to turn off force persistent behaviour) + 6. send another transient message with same lvq key as in 3 + 7. kill the second node again (retrigger force persistent) + 8. stop and recover the first node +*/ + TestMessageStoreOC testStore; + client::QueueOptions args; + // set queue mode + args.setOrdering(client::LVQ); + args.setPersistLastNode(); + + Queue::shared_ptr queue1(new Queue("my-queue", true, &testStore)); + intrusive_ptr received; + queue1->configure(args); + + intrusive_ptr msg1 = create_message("e", "A"); + intrusive_ptr msg2 = create_message("e", "A"); + // 2 + string key; + args.getLVQKey(key); + BOOST_CHECK_EQUAL(key, "qpid.LVQ_key"); + + msg1->getProperties()->getApplicationHeaders().setString(key,"a"); + msg2->getProperties()->getApplicationHeaders().setString(key,"a"); + // 3 + queue1->deliver(msg1); + // 4 + queue1->setLastNodeFailure(); + BOOST_CHECK_EQUAL(testStore.enqCnt, 1u); + // 5 + queue1->clearLastNodeFailure(); + BOOST_CHECK_EQUAL(testStore.enqCnt, 1u); + // 6 + queue1->deliver(msg2); + BOOST_CHECK_EQUAL(testStore.enqCnt, 1u); + queue1->setLastNodeFailure(); + BOOST_CHECK_EQUAL(testStore.enqCnt, 2u); + BOOST_CHECK_EQUAL(testStore.deqCnt, 1u); +} + void addMessagesToQueue(uint count, Queue& queue, uint oddTtl = 200, uint evenTtl = 0) { for (uint i = 0; i < count; i++) { @@ -594,6 +641,9 @@ QPID_AUTO_TEST_CASE(testMultiQueueLastNode){ queue2->setLastNodeFailure(); BOOST_CHECK_EQUAL(testStore.enqCnt, 8u); + queue2->clearLastNodeFailure(); + queue2->setLastNodeFailure(); + BOOST_CHECK_EQUAL(testStore.enqCnt, 8u); } -- cgit v1.2.1