Skip to content

Commit bbf0aae

Browse files
committed
Improve resilience of tests
Those often fail in CI.
1 parent 73f7f35 commit bbf0aae

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/test/java/com/rabbitmq/client/test/functional/ConnectionRecovery.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,12 @@ public void shutdownCompleted(ShutdownSignalException cause) {
160160
});
161161
// note: we do not want to expose RecoveryCanBeginListener so this
162162
// test does not use it
163+
final CountDownLatch recoveryCanBeginLatch = new CountDownLatch(1);
163164
((AutorecoveringConnection)connection).getDelegate().addRecoveryCanBeginListener(new RecoveryCanBeginListener() {
164165
@Override
165166
public void recoveryCanBegin(ShutdownSignalException cause) {
166167
events.add("recovery start hook 1");
168+
recoveryCanBeginLatch.countDown();
167169
}
168170
});
169171
((AutorecoveringConnection)connection).addRecoveryListener(new RecoveryListener() {
@@ -177,6 +179,7 @@ public void handleRecovery(Recoverable recoverable) {
177179
assertTrue(connection.isOpen());
178180
assertEquals("shutdown hook 1", events.get(0));
179181
assertEquals("shutdown hook 2", events.get(1));
182+
recoveryCanBeginLatch.await(5, TimeUnit.SECONDS);
180183
assertEquals("recovery start hook 1", events.get(2));
181184
connection.close();
182185
wait(latch);

src/test/java/com/rabbitmq/client/test/functional/DeadLetterExchange.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ private void sleep(long millis) {
583583
publication time + TTL + latency */
584584
private void checkPromptArrival(QueueingConsumer c,
585585
int count, long latency) throws Exception {
586-
long epsilon = TTL / 15;
586+
long epsilon = TTL / 10;
587587
for (int i = 0; i < count; i++) {
588588
Delivery d = c.nextDelivery(TTL + TTL + latency + epsilon);
589589
assertNotNull("message #" + i + " did not expire", d);

0 commit comments

Comments
 (0)