XComp commented on code in PR #20919:
URL: https://github.com/apache/flink/pull/20919#discussion_r1038089930
##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/functions/table/fullcache/inputformat/InputFormatCacheLoaderTest.java:
##########
@@ -131,15 +133,19 @@ void testExceptionDuringReload() throws Exception {
}
@Test
- void testCloseAndInterruptDuringReload() throws Exception {
- AtomicInteger sleepCounter = new AtomicInteger(0);
- int totalSleepCount = TestCacheLoader.DATA.size() + 1; // equals to
number of all rows
+ void testInterruptDuringReload() throws Exception {
+ CountDownLatch recordsProcessingLatch = new CountDownLatch(1);
Runnable reloadAction =
- ThrowingRunnable.unchecked(
- () -> {
- sleepCounter.incrementAndGet();
- Thread.sleep(1000);
- });
+ () -> {
+ try {
+ // wait should be interrupted if everything works ok
+ if (!recordsProcessingLatch.await(5,
TimeUnit.SECONDS)) {
+ throw new RuntimeException("timeout");
+ }
Review Comment:
```suggestion
assertThatThrownBy(recordsProcessingLatch::await)
.as("wait should be interrupted if everything
works ok")
.isInstanceOf(InterruptedException.class);
Thread.currentThread().interrupt(); // restore
interrupted status
```
I guess, we could get rid of the 5 seconds here. Waiting forever enables us
to generate the thread dump at the end which gives more insights into what went
wrong during the test execution.
nit: I played around with the assertj API a bit more and utilized the
comment as a assertion message. WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]