Skip to content

Commit 4a82c4f

Browse files
committed
Use concurrent hash set in test
Test fails sometimes on CI.
1 parent bad26e3 commit 4a82c4f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/test/java/com/rabbitmq/perf/TopologyTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,15 +603,15 @@ public void sequenceMoreQueuesThanProducers() throws Exception {
603603

604604
// once all producers have published messages (producerCount routing keys in the set),
605605
// we open the latch so MulticastSet.run can end
606-
Set<String> routingKeys = new HashSet<>();
606+
Set<String> routingKeys = ConcurrentHashMap.newKeySet(producerCount);
607607
CountDownLatch latchPublishing = new CountDownLatch(1);
608608
doAnswer(invocation -> {
609609
routingKeys.add(invocation.getArgument(1));
610610
if (routingKeys.size() == producerCount) {
611611
latchPublishing.countDown();
612612
}
613613
return null;
614-
}).when(ch).basicPublish(eq("direct"), routingKeyCaptor.capture(),
614+
}).when(ch).basicPublish(eq("direct"), anyString(),
615615
anyBoolean(), eq(false),
616616
any(), any(byte[].class));
617617

@@ -627,9 +627,9 @@ public void sequenceMoreQueuesThanProducers() throws Exception {
627627
.queueBind(startsWith(queuePrefix), eq("direct"), startsWith(queuePrefix));
628628
verify(ch, never()).basicConsume(anyString(), anyBoolean(), anyMap(), any());
629629

630-
assertThat(routingKeyCaptor.getAllValues().stream().distinct().toArray())
630+
assertThat(routingKeys)
631631
.hasSize(10)
632-
.contains(range(1, 11).mapToObj(i -> queuePrefix + i).toArray());
632+
.containsAll(range(1, 11).mapToObj(i -> queuePrefix + i).collect(toList()));
633633
}
634634

635635
// --queue-pattern 'perf-test-%d' --queue-pattern-from 1 --queue-pattern-to 10 --producers 15 --consumers 30

0 commit comments

Comments
 (0)