Skip to content

Commit f929ebd

Browse files
committed
Improve message of assertion failure
1 parent 43c4200 commit f929ebd

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/test/java/com/rabbitmq/client/amqp/impl/ClusterTest.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import static com.rabbitmq.client.amqp.ConnectionSettings.Affinity.Operation.CONSUME;
2121
import static com.rabbitmq.client.amqp.ConnectionSettings.Affinity.Operation.PUBLISH;
22+
import static com.rabbitmq.client.amqp.Management.QueueType.QUORUM;
2223
import static com.rabbitmq.client.amqp.impl.Assertions.assertThat;
2324
import static com.rabbitmq.client.amqp.impl.ExceptionUtils.noRunningStreamMemberOnNode;
2425
import static com.rabbitmq.client.amqp.impl.TestUtils.name;
@@ -111,7 +112,7 @@ void connectionsShouldBeMemberLocalReplicatedQueues(Management.QueueType type) {
111112
@Test
112113
void connectionShouldRecoverToNewQuorumQueueLeaderAfterItHasMoved() {
113114
try {
114-
management.queue(q).type(Management.QueueType.QUORUM).declare();
115+
management.queue(q).type(QUORUM).declare();
115116
Management.QueueInfo info = queueInfo();
116117
String initialLeader = info.leader();
117118

@@ -139,7 +140,7 @@ void connectionShouldRecoverToNewQuorumQueueLeaderAfterItHasMoved() {
139140
@Test
140141
void publishToMovingQq() {
141142
try {
142-
management.queue(q).type(Management.QueueType.QUORUM).declare();
143+
management.queue(q).type(QUORUM).declare();
143144

144145
AmqpConnection publishConnection = connection(b -> b.affinity().queue(q).operation(PUBLISH));
145146
assertThat(publishConnection).hasNodename(queueInfo().leader());
@@ -183,7 +184,7 @@ void publishToMovingQq() {
183184
@Test
184185
void consumeFromMovingQq() {
185186
try {
186-
management.queue(q).type(Management.QueueType.QUORUM).declare();
187+
management.queue(q).type(QUORUM).declare();
187188

188189
AmqpConnection consumeConnection = connection(b -> b.affinity().queue(q).operation(CONSUME));
189190
assertThat(consumeConnection).isOnFollower(queueInfo());
@@ -240,7 +241,7 @@ void consumeFromMovingQq() {
240241
@Test
241242
void publishConsumeQuorumQueueWhenLeaderChanges() {
242243
try {
243-
management.queue(q).type(Management.QueueType.QUORUM).declare();
244+
management.queue(q).type(QUORUM).declare();
244245

245246
AmqpConnection consumeConnection = connection(b -> b.affinity().queue(q).operation(CONSUME));
246247
assertThat(consumeConnection).isOnFollower(queueInfo());
@@ -298,8 +299,8 @@ void publishConsumeQuorumQueueWhenLeaderChanges() {
298299
}
299300

300301
@Test
301-
void consumeFromQuorumQueueWhenLeaderIsPaused() {
302-
management.queue(q).type(Management.QueueType.QUORUM).declare();
302+
void consumeFromQuorumQueueWhenLeaderIsPaused() throws InterruptedException {
303+
management.queue(q).type(QUORUM).declare();
303304
Management.QueueInfo queueInfo = queueInfo();
304305
String initialLeader = queueInfo.leader();
305306
boolean nodePaused = false;
@@ -350,7 +351,14 @@ void consumeFromQuorumQueueWhenLeaderIsPaused() {
350351
assertThat(messageIds).containsExactlyInAnyOrder(1L, 2L);
351352
consumeSync.reset();
352353

353-
waitAtMost(() -> initialFollowers.contains(mgmt.queueInfo(q).leader()));
354+
waitAtMost(
355+
() -> initialFollowers.contains(mgmt.queueInfo(q).leader()),
356+
() ->
357+
"Current leader is not in initial followers, initial followers "
358+
+ initialFollowers
359+
+ ", "
360+
+ "queue info "
361+
+ mgmt.queueInfo(q));
354362
assertThat(initialFollowers).contains(mgmt.queueInfo(q).leader());
355363

356364
Cli.unpauseNode(initialLeader);

0 commit comments

Comments
 (0)