You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by dw...@apache.org on 2022/02/25 13:48:08 UTC
[flink] branch master updated: [FLINK-26354] -restoreMode should be --restoreMode and should have a shorthand
This is an automated email from the ASF dual-hosted git repository.
dwysakowicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new a34b448 [FLINK-26354] -restoreMode should be --restoreMode and should have a shorthand
a34b448 is described below
commit a34b448c8e8f0dc7705548c028dd463a2fb0ddc9
Author: Dawid Wysakowicz <dw...@apache.org>
AuthorDate: Fri Feb 25 09:05:40 2022 +0100
[FLINK-26354] -restoreMode should be --restoreMode and should have a shorthand
---
.../apache/flink/client/cli/CliFrontendParser.java | 1 +
.../flink/client/cli/CliFrontendRunTest.java | 59 +++++++++-------------
2 files changed, 24 insertions(+), 36 deletions(-)
diff --git a/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java b/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java
index ef202f6..d9b2370 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java
@@ -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: "
diff --git a/flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendRunTest.java b/flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendRunTest.java
index 2d10ad11..ea82cc9 100644
--- a/flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendRunTest.java
+++ b/flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendRunTest.java
@@ -133,50 +133,37 @@ public class CliFrontendRunTest extends CliFrontendTestBase {
@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);
@@ -186,7 +173,7 @@ public class CliFrontendRunTest extends CliFrontendTestBase {
SavepointRestoreSettings savepointSettings = executionOptions.getSavepointRestoreSettings();
assertTrue(savepointSettings.restoreSavepoint());
- assertEquals(RestoreMode.NO_CLAIM, savepointSettings.getRestoreMode());
+ assertEquals(expectedMode, savepointSettings.getRestoreMode());
assertEquals("expectedSavepointPath", savepointSettings.getRestorePath());
assertTrue(savepointSettings.allowNonRestoredState());
}