Skip to content

Commit 8e587c4

Browse files
committed
Add polling assertion
Test fails sometimes on CI.
1 parent 66aac59 commit 8e587c4

File tree

6 files changed

+16
-18
lines changed

6 files changed

+16
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
/**
2-
* Classes for AMQP 1.0 support.
3-
*/
4-
package com.rabbitmq.stream.amqp;
1+
/** Classes for AMQP 1.0 support. */
2+
package com.rabbitmq.stream.amqp;
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/**
22
* Implementation-specific, non-public interfaces and classes of the RabbitMQ Stream Java Client.
33
*/
4-
package com.rabbitmq.stream.impl;
4+
package com.rabbitmq.stream.impl;
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
/**
2-
* Main API for RabbitMQ Stream Java Client.
3-
*/
4-
package com.rabbitmq.stream;
1+
/** Main API for RabbitMQ Stream Java Client. */
2+
package com.rabbitmq.stream;
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
/**
2-
* Performance tool for RabbitMQ Stream.
3-
*/
4-
package com.rabbitmq.stream.perf;
1+
/** Performance tool for RabbitMQ Stream. */
2+
package com.rabbitmq.stream.perf;
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* SASL API for the RabbitMQ Stream Java Client.
33
*
4-
* @see <a href="https://en.wikipedia.org/wiki/Simple_Authentication_and_Security_Layer">SASL on Wikipedia</a>
4+
* @see <a href="https://en.wikipedia.org/wiki/Simple_Authentication_and_Security_Layer">SASL on
5+
* Wikipedia</a>
56
*/
6-
package com.rabbitmq.stream.sasl;
7+
package com.rabbitmq.stream.sasl;

src/test/java/com/rabbitmq/stream/impl/StreamProducerUnitTest.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
1414
package com.rabbitmq.stream.impl;
1515

16+
import static com.rabbitmq.stream.impl.TestUtils.waitAtMost;
1617
import static org.assertj.core.api.Assertions.assertThat;
1718
import static org.assertj.core.api.Assertions.assertThatThrownBy;
1819
import static org.mockito.ArgumentMatchers.any;
@@ -143,8 +144,9 @@ void tearDown() throws Exception {
143144
"0,1000,7",
144145
})
145146
void confirmTimeoutTaskShouldFailMessagesAfterTimeout(
146-
long confirmTimeoutMs, long waitTime, int subEntrySize) throws Exception {
147+
long confirmTimeoutMs, long waitTimeMs, int subEntrySize) throws Exception {
147148
Duration confirmTimeout = Duration.ofMillis(confirmTimeoutMs);
149+
Duration waitTime = Duration.ofMillis(waitTimeMs);
148150
clock.refresh();
149151
int messageCount = 500;
150152
int confirmedPart = messageCount / 10;
@@ -189,13 +191,14 @@ void confirmTimeoutTaskShouldFailMessagesAfterTimeout(
189191

190192
executorService.scheduleAtFixedRate(() -> clock.refresh(), 100, 100, TimeUnit.MILLISECONDS);
191193

192-
Thread.sleep(waitTime);
194+
Thread.sleep(waitTime.toMillis());
193195
assertThat(confirmedCount.get()).isEqualTo(expectedConfirmed);
194196
if (confirmTimeout.isZero()) {
195197
assertThat(erroredCount.get()).isZero();
196198
assertThat(responseCodes).isEmpty();
197199
} else {
198-
assertThat(erroredCount.get()).isEqualTo(messageCount - expectedConfirmed);
200+
waitAtMost(
201+
waitTime.multipliedBy(2), () -> erroredCount.get() == (messageCount - expectedConfirmed));
199202
assertThat(responseCodes).hasSize(1).contains(Constants.CODE_PUBLISH_CONFIRM_TIMEOUT);
200203
}
201204
}

0 commit comments

Comments
 (0)