|
13 | 13 |
|
14 | 14 | package com.rabbitmq.stream.impl;
|
15 | 15 |
|
| 16 | +import static com.rabbitmq.stream.impl.TestUtils.waitAtMost; |
16 | 17 | import static org.assertj.core.api.Assertions.assertThat;
|
17 | 18 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
18 | 19 | import static org.mockito.ArgumentMatchers.any;
|
@@ -143,8 +144,9 @@ void tearDown() throws Exception {
|
143 | 144 | "0,1000,7",
|
144 | 145 | })
|
145 | 146 | void confirmTimeoutTaskShouldFailMessagesAfterTimeout(
|
146 |
| - long confirmTimeoutMs, long waitTime, int subEntrySize) throws Exception { |
| 147 | + long confirmTimeoutMs, long waitTimeMs, int subEntrySize) throws Exception { |
147 | 148 | Duration confirmTimeout = Duration.ofMillis(confirmTimeoutMs);
|
| 149 | + Duration waitTime = Duration.ofMillis(waitTimeMs); |
148 | 150 | clock.refresh();
|
149 | 151 | int messageCount = 500;
|
150 | 152 | int confirmedPart = messageCount / 10;
|
@@ -189,13 +191,14 @@ void confirmTimeoutTaskShouldFailMessagesAfterTimeout(
|
189 | 191 |
|
190 | 192 | executorService.scheduleAtFixedRate(() -> clock.refresh(), 100, 100, TimeUnit.MILLISECONDS);
|
191 | 193 |
|
192 |
| - Thread.sleep(waitTime); |
| 194 | + Thread.sleep(waitTime.toMillis()); |
193 | 195 | assertThat(confirmedCount.get()).isEqualTo(expectedConfirmed);
|
194 | 196 | if (confirmTimeout.isZero()) {
|
195 | 197 | assertThat(erroredCount.get()).isZero();
|
196 | 198 | assertThat(responseCodes).isEmpty();
|
197 | 199 | } else {
|
198 |
| - assertThat(erroredCount.get()).isEqualTo(messageCount - expectedConfirmed); |
| 200 | + waitAtMost( |
| 201 | + waitTime.multipliedBy(2), () -> erroredCount.get() == (messageCount - expectedConfirmed)); |
199 | 202 | assertThat(responseCodes).hasSize(1).contains(Constants.CODE_PUBLISH_CONFIRM_TIMEOUT);
|
200 | 203 | }
|
201 | 204 | }
|
|
0 commit comments