Skip to content

Commit d70ad19

Browse files
committed
make HATests pass when there is just a single node
1 parent bf834dd commit d70ad19

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

test/src/com/rabbitmq/client/test/server/MessageRecovery.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515

1616
package com.rabbitmq.client.test.server;
1717

18+
import com.rabbitmq.client.AMQP;
19+
import com.rabbitmq.client.Channel;
1820
import com.rabbitmq.client.MessageProperties;
1921
import com.rabbitmq.client.test.ConfirmBase;
2022

23+
import java.io.IOException;
24+
2125
public class MessageRecovery extends ConfirmBase
2226
{
2327

2428
private final static String Q = "recovery-test";
29+
private final static String Q2 = "recovery-test-ha-check";
2530

2631
public void testMessageRecovery()
2732
throws Exception
@@ -33,11 +38,28 @@ public void testMessageRecovery()
3338
"nop".getBytes());
3439
waitForConfirms();
3540

41+
channel.queueDeclare(Q2, false, false, false, null);
42+
3643
restart();
3744

38-
// When testing in HA mode the message will be collected from a promoted
39-
// slave and wil have its redelivered flag set.
40-
assertDelivered(Q, 1, HATests.HA_TESTS_RUNNING);
45+
// When testing in HA mode the message will be collected from
46+
// a promoted slave and will have its redelivered flag
47+
// set. But that only happens if there actually *is* a
48+
// slave. We test that by passively declaring, and
49+
// subsequently deletign, the secondary, non-durable queue,
50+
// which only succeeds if the queue survived the restart,
51+
// which in turn implies that it must have been a HA queue
52+
// with slave(s).
53+
boolean expectDelivered = false;
54+
try {
55+
channel.queueDeclarePassive(Q2);
56+
channel.queueDelete(Q2);
57+
expectDelivered = true;
58+
} catch (IOException e) {
59+
checkShutdownSignal(AMQP.NOT_FOUND, e);
60+
openChannel();
61+
}
62+
assertDelivered(Q, 1, expectDelivered);
4163
channel.queueDelete(Q);
4264
}
4365

0 commit comments

Comments
 (0)