Skip to content

Commit

Permalink
[FLINK-21954][tests] Harden JobMasterTest.testRestoringFromSavepoint …
Browse files Browse the repository at this point in the history
…and .testRequestNextInputSplitWithGlobalFailover

The test instability has been introduced by FLINK-21602 because the ExecutionGraph
is now created asynchronously. This commit fixes the test instabilities in JobMasterTest
by waiting for a task submission before asserting on the state.
  • Loading branch information
tillrohrmann committed Apr 8, 2021
1 parent 0fc03e4 commit a26a5f0
Showing 1 changed file with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,24 @@ public void testRestoringFromSavepoint() throws Exception {
// restore from the savepoint
jobMaster.start();

final OneShotLatch taskSubmitLatch = new OneShotLatch();

registerSlotsAtJobMaster(
1,
jobMaster.getSelfGateway(JobMasterGateway.class),
jobGraph.getJobID(),
new TestingTaskExecutorGatewayBuilder().createTestingTaskExecutorGateway(),
new TestingTaskExecutorGatewayBuilder()
.setSubmitTaskConsumer(
(taskDeploymentDescriptor, jobMasterId) -> {
taskSubmitLatch.trigger();
return CompletableFuture.completedFuture(Acknowledge.get());
})
.createTestingTaskExecutorGateway(),
new LocalUnresolvedTaskManagerLocation());

// wait until a task has submitted because this guarantees that the ExecutionGraph has
// been created
taskSubmitLatch.await();
final CompletedCheckpoint savepointCheckpoint =
completedCheckpointStore.getLatestCheckpoint(false);

Expand Down Expand Up @@ -1018,13 +1029,16 @@ private void waitUntilAllExecutionsAreScheduledOrDeployed(
final Deadline deadline = Deadline.fromNow(duration);

CommonTestUtils.waitUntilCondition(
() ->
getExecutions(jobMasterGateway).stream()
.allMatch(
execution ->
execution.getState() == ExecutionState.SCHEDULED
|| execution.getState()
== ExecutionState.DEPLOYING),
() -> {
final Collection<AccessExecution> executions = getExecutions(jobMasterGateway);
return !executions.isEmpty()
&& executions.stream()
.allMatch(
execution ->
execution.getState() == ExecutionState.SCHEDULED
|| execution.getState()
== ExecutionState.DEPLOYING);
},
deadline);
}

Expand Down

0 comments on commit a26a5f0

Please sign in to comment.