tillrohrmann commented on a change in pull request #14999:
URL: https://github.com/apache/flink/pull/14999#discussion_r582984387
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/DefaultSchedulerTest.java
##########
@@ -968,6 +982,75 @@ public void testExceptionHistoryWithRestartableFailure() {
lessThanOrEqualTo(updateStateTriggeringJobFailureTimeframe.upperEndpoint()));
}
+ @Test(expected = IllegalStateException.class)
+ public void testRestoringModifiedJobFromSavepointFails() throws Exception {
+ // create savepoint data
+ final long savepointId = 42L;
+ final OperatorID operatorID = new OperatorID();
+ final File savepointFile =
+ TestUtils.createSavepointWithOperatorState(
+ TEMPORARY_FOLDER.newFile(), savepointId, operatorID);
+
+ // set savepoint settings which don't allow non restored state
+ final SavepointRestoreSettings savepointRestoreSettings =
+
SavepointRestoreSettings.forPath(savepointFile.getAbsolutePath(), false);
+
+ // create a new operator
+ final JobVertex jobVertex = new JobVertex("New operator");
+ jobVertex.setInvokableClass(NoOpInvokable.class);
+ final JobGraph jobGraphWithNewOperator =
+ TestUtils.createJobGraphFromJobVerticesWithCheckpointing(
+ savepointRestoreSettings, jobVertex);
+
+ // creating the DefaultScheduler should try to restore the
ExecutionGraph
+ SchedulerTestingUtils.newSchedulerBuilder(
+ jobGraphWithNewOperator,
+
ComponentMainThreadExecutorServiceAdapter.forMainThread())
+ .build();
+ }
+
+ @Test
+ public void
testRestoringModifiedJobFromSavepointWithAllowNonRestoredStateSucceeds()
+ throws Exception {
+ // create savepoint data
+ final long savepointId = 42L;
+ final OperatorID operatorID = new OperatorID();
+ final File savepointFile =
+ TestUtils.createSavepointWithOperatorState(
+ TEMPORARY_FOLDER.newFile(), savepointId, operatorID);
+
+ // allow for non restored state
+ final SavepointRestoreSettings savepointRestoreSettings =
+
SavepointRestoreSettings.forPath(savepointFile.getAbsolutePath(), true);
+
+ // create a new operator
+ final JobVertex jobVertex = new JobVertex("New operator");
+ jobVertex.setInvokableClass(NoOpInvokable.class);
+ final JobGraph jobGraphWithNewOperator =
+ TestUtils.createJobGraphFromJobVerticesWithCheckpointing(
+ savepointRestoreSettings, jobVertex);
+
+ final StandaloneCompletedCheckpointStore completedCheckpointStore =
+ new StandaloneCompletedCheckpointStore(1);
+ final CheckpointRecoveryFactory testingCheckpointRecoveryFactory =
+ useSameServicesForAllJobs(
+ completedCheckpointStore, new
StandaloneCheckpointIDCounter());
+
+ SchedulerTestingUtils.newSchedulerBuilder(
+ jobGraphWithNewOperator,
+
ComponentMainThreadExecutorServiceAdapter.forMainThread())
+ .setCheckpointRecoveryFactory(testingCheckpointRecoveryFactory)
+ .build();
+
+ // creating the DefaultScheduler should have read the savepoint
+ final CompletedCheckpoint savepointCheckpoint =
+ completedCheckpointStore.getLatestCheckpoint(false);
+
+ MatcherAssert.assertThat(savepointCheckpoint, notNullValue());
+
+ MatcherAssert.assertThat(savepointCheckpoint.getCheckpointID(),
is(savepointId));
Review comment:
Will change it.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]