Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-26354] -restoreMode should be --restoreMode and should have a shorthand #18918

Merged
merged 1 commit into from Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -134,6 +134,7 @@ public class CliFrontendParser {

public static final Option SAVEPOINT_RESTORE_MODE =
new Option(
"rm",
"restoreMode",
true,
"Defines how should we restore from the given savepoint. Supported options: "
Expand Down
Expand Up @@ -133,50 +133,37 @@ public void testRun() throws Exception {

@Test
public void testClaimRestoreModeParsing() throws Exception {
// test configure savepoint with claim mode
String[] parameters = {
"-s", "expectedSavepointPath", "-n", "-restoreMode", "claim", getTestJarPath()
};

CommandLine commandLine =
CliFrontendParser.parse(CliFrontendParser.RUN_OPTIONS, parameters, true);
ProgramOptions programOptions = ProgramOptions.create(commandLine);
ExecutionConfigAccessor executionOptions =
ExecutionConfigAccessor.fromProgramOptions(programOptions, Collections.emptyList());

SavepointRestoreSettings savepointSettings = executionOptions.getSavepointRestoreSettings();
assertTrue(savepointSettings.restoreSavepoint());
assertEquals(RestoreMode.CLAIM, savepointSettings.getRestoreMode());
assertEquals("expectedSavepointPath", savepointSettings.getRestorePath());
assertTrue(savepointSettings.allowNonRestoredState());
testRestoreMode("-rm", "claim", RestoreMode.CLAIM);
}

@Test
public void testLegacyRestoreModeParsing() throws Exception {
// test configure savepoint with claim mode
String[] parameters = {
"-s", "expectedSavepointPath", "-n", "-restoreMode", "legacy", getTestJarPath()
};
testRestoreMode("-rm", "legacy", RestoreMode.LEGACY);
}

CommandLine commandLine =
CliFrontendParser.parse(CliFrontendParser.RUN_OPTIONS, parameters, true);
ProgramOptions programOptions = ProgramOptions.create(commandLine);
ExecutionConfigAccessor executionOptions =
ExecutionConfigAccessor.fromProgramOptions(programOptions, Collections.emptyList());
@Test
public void testNoClaimRestoreModeParsing() throws Exception {
testRestoreMode("-rm", "no_claim", RestoreMode.NO_CLAIM);
}

SavepointRestoreSettings savepointSettings = executionOptions.getSavepointRestoreSettings();
assertTrue(savepointSettings.restoreSavepoint());
assertEquals(RestoreMode.LEGACY, savepointSettings.getRestoreMode());
assertEquals("expectedSavepointPath", savepointSettings.getRestorePath());
assertTrue(savepointSettings.allowNonRestoredState());
@Test
public void testClaimRestoreModeParsingLongOption() throws Exception {
testRestoreMode("--restoreMode", "claim", RestoreMode.CLAIM);
}

@Test
public void testNoClaimRestoreModeParsing() throws Exception {
// test configure savepoint with claim mode
String[] parameters = {
"-s", "expectedSavepointPath", "-n", "-restoreMode", "no_claim", getTestJarPath()
};
public void testLegacyRestoreModeParsingLongOption() throws Exception {
testRestoreMode("--restoreMode", "legacy", RestoreMode.LEGACY);
}

@Test
public void testNoClaimRestoreModeParsingLongOption() throws Exception {
testRestoreMode("--restoreMode", "no_claim", RestoreMode.NO_CLAIM);
}

private void testRestoreMode(String flag, String arg, RestoreMode expectedMode)
throws Exception {
String[] parameters = {"-s", "expectedSavepointPath", "-n", flag, arg, getTestJarPath()};

CommandLine commandLine =
CliFrontendParser.parse(CliFrontendParser.RUN_OPTIONS, parameters, true);
Expand All @@ -186,7 +173,7 @@ public void testNoClaimRestoreModeParsing() throws Exception {

SavepointRestoreSettings savepointSettings = executionOptions.getSavepointRestoreSettings();
assertTrue(savepointSettings.restoreSavepoint());
assertEquals(RestoreMode.NO_CLAIM, savepointSettings.getRestoreMode());
assertEquals(expectedMode, savepointSettings.getRestoreMode());
assertEquals("expectedSavepointPath", savepointSettings.getRestorePath());
assertTrue(savepointSettings.allowNonRestoredState());
}
Expand Down