flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/ExecutionGraphCacheTest.java
/**
	 * Tests that an AccessExecutionGraph is invalidated after its TTL expired.
	 */
Tests that an AccessExecutionGraph is invalidated after its TTL expired.
Tests that an AccessExecutionGraph is invalidated after its TTL expired .
@Test
	public void testExecutionGraphEntryInvalidation() throws Exception {
		final Time timeout = Time.milliseconds(100L);
		final Time timeToLive = Time.milliseconds(1L);
		final JobID jobId = new JobID();
		final AccessExecutionGraph accessExecutionGraph = mock(AccessExecutionGraph.class);
		final JobManagerGateway jobManagerGateway = mock(JobManagerGateway.class);
		when(jobManagerGateway.requestJob(eq(jobId), any(Time.class))).thenReturn(CompletableFuture.completedFuture(accessExecutionGraph));
		try (ExecutionGraphCache executionGraphCache = new ExecutionGraphCache(timeout, timeToLive)) {
			CompletableFuture<AccessExecutionGraph> executionGraphFuture = executionGraphCache.getExecutionGraph(jobId, jobManagerGateway);
			assertEquals(accessExecutionGraph, executionGraphFuture.get());
			Thread.sleep(timeToLive.toMilliseconds());
			CompletableFuture<AccessExecutionGraph> executionGraphFuture2 = executionGraphCache.getExecutionGraph(jobId, jobManagerGateway);
			assertEquals(accessExecutionGraph, executionGraphFuture2.get());
			verify(jobManagerGateway, times(2)).requestJob(eq(jobId), any(Time.class));
		}
	}
@ Test public void testExecutionGraphEntryInvalidation ( ) throws Exception { final Time timeout = Time . milliseconds ( 100L ) ; final Time timeToLive = Time . milliseconds ( 1L ) ; final JobID jobId = new JobID ( ) ; final AccessExecutionGraph accessExecutionGraph = mock ( AccessExecutionGraph . class ) ; final JobManagerGateway jobManagerGateway = mock ( JobManagerGateway . class ) ; when ( jobManagerGateway . requestJob ( eq ( jobId ) , any ( Time . class ) ) ) . thenReturn ( CompletableFuture . completedFuture ( accessExecutionGraph ) ) ; try ( ExecutionGraphCache executionGraphCache = new ExecutionGraphCache ( timeout , timeToLive ) ) { CompletableFuture < AccessExecutionGraph > executionGraphFuture = executionGraphCache . getExecutionGraph ( jobId , jobManagerGateway ) ; assertEquals ( accessExecutionGraph , executionGraphFuture . get ( ) ) ; Thread . sleep ( timeToLive . toMilliseconds ( ) ) ; CompletableFuture < AccessExecutionGraph > executionGraphFuture2 = executionGraphCache . getExecutionGraph ( jobId , jobManagerGateway ) ; assertEquals ( accessExecutionGraph , executionGraphFuture2 . get ( ) ) ; verify ( jobManagerGateway , times ( 2 ) ) . requestJob ( eq ( jobId ) , any ( Time . class ) ) ; } }
Tests that an AccessExecutionGraph is invalidated after its TTL expired.
Tests that an AccessExecutionGraph is invalidated after its TTL expired .
// sleep for the TTL