nicoweidner commented on a change in pull request #17472: URL: https://github.com/apache/flink/pull/17472#discussion_r731087092
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/async/CompletedOperationCacheTest.java ########## @@ -107,4 +109,53 @@ public void testCanGetOperationResultAfterClosing() throws Exception { assertThat(result.right(), is(equalTo(TEST_OPERATION_RESULT.get()))); } + + @Test + public void testCacheTimeout() throws Exception { + final Duration timeout = RestOptions.ASYNC_OPERATION_STORE_DURATION.defaultValue(); + + completedOperationCache = new CompletedOperationCache<>(timeout, manualTicker); + completedOperationCache.registerOngoingOperation(TEST_OPERATION_KEY, TEST_OPERATION_RESULT); + + // sanity check that the operation can be retrieved before the timeout + assertThat( + completedOperationCache.get(TEST_OPERATION_KEY).right(), + is(equalTo(TEST_OPERATION_RESULT.get()))); + + manualTicker.advanceTime(timeout.multipliedBy(2).getSeconds(), TimeUnit.SECONDS); + + try { + completedOperationCache.get(TEST_OPERATION_KEY); + fail("Timeout should have removed cache entry."); + } catch (UnknownOperationKeyException expected) { + } + } + + @Test + public void testCacheTimeoutCanBeDisabled() throws Exception { + completedOperationCache = + new CompletedOperationCache<>(Duration.ofSeconds(0), manualTicker); + completedOperationCache.registerOngoingOperation(TEST_OPERATION_KEY, TEST_OPERATION_RESULT); + + manualTicker.advanceTime(365, TimeUnit.DAYS); + + assertThat( + completedOperationCache.get(TEST_OPERATION_KEY).right(), + is(equalTo(TEST_OPERATION_RESULT.get()))); + } + + @Test + public void testCacheTimeoutCanBeConfigured() throws Exception { + final Duration baseTImeout = RestOptions.ASYNC_OPERATION_STORE_DURATION.defaultValue(); Review comment: ```suggestion final Duration baseTimeout = RestOptions.ASYNC_OPERATION_STORE_DURATION.defaultValue(); ``` -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org