Code review comment: Maybe we could further provide an utility for creating Execution like below:  ``` private CompletableFuture<Execution> createExecution( 		TaskManagerGateway taskManagerGateway, 		JobVertex... vertices) throws Exception {  		SimpleSlot slot = new SimpleSlot( 			new SingleSlotTestingSlotOwner(), 			new LocalTaskManagerLocation(), 			0, 			taskManagerGateway);  		ProgrammedSlotProvider slotProvider = new ProgrammedSlotProvider(1); 		slotProvider.addSlot(vertices[0].getID(), 0, CompletableFuture.completedFuture(slot));  		ExecutionGraph executionGraph = ExecutionGraphTestUtils.createSimpleTestGraph( 			new JobID(), 			slotProvider, 			new NoRestartStrategy(), 			vertices);  		executionGraph.start(TestingComponentMainThreadExecutorServiceAdapter.forMainThread());  		ExecutionJobVertex executionJobVertex = executionGraph.getJobVertex(vertices[0].getID()); 		ExecutionVertex executionVertex = executionJobVertex.getTaskVertices()[0]; 		Execution execution = executionVertex.getCurrentExecutionAttempt();  		CompletableFuture<Execution> allocationFuture = execution.allocateAndAssignSlotForExecution( 			slotProvider, 			false, 			LocationPreferenceConstraint.ALL, 			Collections.emptySet(), 			TestingUtils.infiniteTime());  		return allocationFuture; 	} ``` Then we could get Execution from future, and further get ExecutionVertex and ExecutionGraph from Execution. Then this helper could be reused for many existing tests.

Code under review:
private void testPartitionReleaseAfterFinished(Consumer<Execution> postFinishedExecutionAction) throws Exception {
		final Tuple2<JobID, Collection<ResultPartitionID>> releasedPartitions = Tuple2.of(null, null);
		final SimpleAckingTaskManagerGateway taskManagerGateway = new SimpleAckingTaskManagerGateway();
		taskManagerGateway.setReleasePartitionsConsumer(releasedPartitions::setFields);

		final SimpleSlot slot = new SimpleSlot(
			new SingleSlotTestingSlotOwner(),
			new LocalTaskManagerLocation(),
			0,
			taskManagerGateway);

		final JobVertex producerVertex = createNoOpJobVertex();
		final JobVertex consumerVertex = createNoOpJobVertex();
		consumerVertex.connectNewDataSetAsInput(producerVertex, DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING);

		final ProgrammedSlotProvider slotProvider = new ProgrammedSlotProvider(1);
		slotProvider.addSlot(producerVertex.getID(), 0, CompletableFuture.completedFuture(slot));

		ExecutionGraph executionGraph = ExecutionGraphTestUtils.createSimpleTestGraph(
			new JobID(),
			slotProvider,
			new NoRestartStrategy(),
			producerVertex,
			consumerVertex);

		executionGraph.start(TestingComponentMainThreadExecutorServiceAdapter.forMainThread());

		ExecutionJobVertex executionJobVertex = executionGraph.getJobVertex(producerVertex.getID());
		ExecutionVertex executionVertex = executionJobVertex.getTaskVertices()[0];

		final Execution execution = executionVertex.getCurrentExecutionAttempt();

		execution.allocateAndAssignSlotForExecution(
			slotProvider,
			false,
			LocationPreferenceConstraint.ALL,
			Collections.emptySet(),
			TestingUtils.infiniteTime());

		execution.deploy();
		execution.switchToRunning();

		
		
		
		execution.markFinished();
		postFinishedExecutionAction.accept(execution);

		assertEquals(executionGraph.getJobID(), releasedPartitions.f0);
		assertEquals(executionVertex.getProducedPartitions().size(), releasedPartitions.f1.size());
		for (ResultPartitionID partitionId : releasedPartitions.f1) {
			IntermediateResultPartition intermediateResultPartition = executionVertex
				.getProducedPartitions()
				.get(partitionId.getPartitionId());
			assertNotNull(intermediateResultPartition);
			assertEquals(execution.getAttemptId(), partitionId.getProducerId());
		}
	}

Line commented on: execution.deploy();

Revised code:
private void testPartitionReleaseAfterFinished(Consumer<Execution> postFinishedExecutionAction) throws Exception {
		final Tuple2<JobID, Collection<ResultPartitionID>> releasedPartitions = Tuple2.of(null, null);
		final SimpleAckingTaskManagerGateway taskManagerGateway = new SimpleAckingTaskManagerGateway();
		taskManagerGateway.setReleasePartitionsConsumer(releasedPartitions::setFields);

		final JobVertex producerVertex = createNoOpJobVertex();
		final JobVertex consumerVertex = createNoOpJobVertex();
		consumerVertex.connectNewDataSetAsInput(producerVertex, DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING);

		final SimpleSlot slot = new SimpleSlot(
			new SingleSlotTestingSlotOwner(),
			new LocalTaskManagerLocation(),
			0,
			taskManagerGateway);

		final ProgrammedSlotProvider slotProvider = new ProgrammedSlotProvider(1);
		slotProvider.addSlot(producerVertex.getID(), 0, CompletableFuture.completedFuture(slot));

		ExecutionGraph executionGraph = ExecutionGraphTestUtils.createSimpleTestGraph(
			new JobID(),
			slotProvider,
			new NoRestartStrategy(),
			producerVertex,
			consumerVertex);

		executionGraph.start(TestingComponentMainThreadExecutorServiceAdapter.forMainThread());

		ExecutionJobVertex executionJobVertex = executionGraph.getJobVertex(producerVertex.getID());
		ExecutionVertex executionVertex = executionJobVertex.getTaskVertices()[0];

		final Execution execution = executionVertex.getCurrentExecutionAttempt();

		execution.allocateResourcesForExecution(
			slotProvider,
			false,
			LocationPreferenceConstraint.ALL,
			Collections.emptySet(),
			TestingUtils.infiniteTime());

		execution.deploy();
		execution.switchToRunning();

		
		
		
		execution.markFinished();
		postFinishedExecutionAction.accept(execution);

		assertEquals(executionGraph.getJobID(), releasedPartitions.f0);
		assertEquals(executionVertex.getProducedPartitions().size(), releasedPartitions.f1.size());
		for (ResultPartitionID partitionId : releasedPartitions.f1) {
			
			IntermediateResultPartition intermediateResultPartition = executionVertex
				.getProducedPartitions()
				.get(partitionId.getPartitionId());
			assertNotNull(intermediateResultPartition);
			assertEquals(execution.getAttemptId(), partitionId.getProducerId());
		}
	}