|
17 | 17 | */ |
18 | 18 | package org.apache.hadoop.hbase.regionserver.wal; |
19 | 19 |
|
| 20 | +import static org.awaitility.Awaitility.await; |
20 | 21 | import static org.hamcrest.MatcherAssert.assertThat; |
21 | 22 | import static org.hamcrest.Matchers.greaterThan; |
22 | 23 | import static org.junit.jupiter.api.Assertions.assertEquals; |
|
25 | 26 | import static org.junit.jupiter.api.Assertions.assertTrue; |
26 | 27 |
|
27 | 28 | import java.io.IOException; |
| 29 | +import java.time.Duration; |
28 | 30 | import java.util.concurrent.Executors; |
29 | 31 | import java.util.concurrent.ScheduledExecutorService; |
30 | 32 | import java.util.concurrent.atomic.AtomicBoolean; |
@@ -304,8 +306,13 @@ public void testLogRolling() throws Exception { |
304 | 306 | log.rollWriter(); |
305 | 307 |
|
306 | 308 | // should have deleted all the rolled wal files |
307 | | - TEST_UTIL.waitFor(5000, () -> AbstractFSWALProvider.getNumRolledLogFiles(log) == 0); |
308 | | - assertEquals(0, AbstractFSWALProvider.getLogFileSize(log)); |
| 309 | + await().atMost(Duration.ofSeconds(15)).untilAsserted(() -> { |
| 310 | + // we call archive log in a background thread but remove the log from wal file map in |
| 311 | + // foreground, which means it is possible that when numRolledLogFiles reaches zero, the log |
| 312 | + // file size is still greater than zero, so here we need to wait for them both. |
| 313 | + assertEquals(0, AbstractFSWALProvider.getNumRolledLogFiles(log)); |
| 314 | + assertEquals(0, AbstractFSWALProvider.getLogFileSize(log)); |
| 315 | + }); |
309 | 316 | } |
310 | 317 |
|
311 | 318 | protected String getName() { |
|
0 commit comments