Skip to content

Commit

Permalink
[FLINK-26353] Add short option for savepoint format type
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidwys committed Mar 2, 2022
1 parent 595d546 commit 6d4189e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public class CliFrontendParser {

static final Option SAVEPOINT_FORMAT_OPTION =
new Option(
"t",
"type",
true,
"Describes the binary format in which a savepoint should be taken. Supported"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,18 @@ public void testTriggerSavepointCustomTarget() throws Exception {
}
}

/**
* Tests that a CLI call with a custom savepoint directory target is forwarded correctly to the
* cluster client.
*/
@Test
public void testTriggerSavepointCustomFormat() throws Exception {
public void testTriggerSavepointCustomFormatShortOption() throws Exception {
testTriggerSavepointCustomFormat("-t", SavepointFormatType.NATIVE);
}

@Test
public void testTriggerSavepointCustomFormatLongOption() throws Exception {
testTriggerSavepointCustomFormat("--type", SavepointFormatType.NATIVE);
}

private void testTriggerSavepointCustomFormat(String flag, SavepointFormatType formatType)
throws Exception {
replaceStdOutAndStdErr();

JobID jobId = new JobID();
Expand All @@ -200,13 +206,12 @@ public void testTriggerSavepointCustomFormat() throws Exception {
MockedCliFrontend frontend = new MockedCliFrontend(clusterClient);

String[] parameters = {
jobId.toString(), savepointDirectory, "-type", SavepointFormatType.NATIVE.toString()
jobId.toString(), savepointDirectory, flag, formatType.toString()
};
frontend.savepoint(parameters);

verify(clusterClient, times(1))
.triggerSavepoint(
eq(jobId), eq(savepointDirectory), eq(SavepointFormatType.NATIVE));
.triggerSavepoint(eq(jobId), eq(savepointDirectory), eq(formatType));

assertTrue(buffer.toString().contains(savepointDirectory));
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,21 @@ public void testStopWithExplicitSavepointDir() throws Exception {
}

@Test
public void testStopWithExplicitSavepointType() throws Exception {
public void testStopWithExplicitSavepointTypeShortOption() throws Exception {
testStopWithExplicitSavepointType("-t", SavepointFormatType.NATIVE);
}

@Test
public void testStopWithExplicitSavepointTypeLongOption() throws Exception {
testStopWithExplicitSavepointType("--type", SavepointFormatType.NATIVE);
}

private void testStopWithExplicitSavepointType(String flag, SavepointFormatType expectedFormat)
throws Exception {
JobID jid = new JobID();

String[] parameters = {
"-p", "test-target-dir", jid.toString(), "-type", SavepointFormatType.NATIVE.toString()
"-p", "test-target-dir", jid.toString(), flag, expectedFormat.toString()
};
OneShotLatch stopWithSavepointLatch = new OneShotLatch();
TestingClusterClient<String> clusterClient = new TestingClusterClient<>();
Expand All @@ -133,6 +143,7 @@ public void testStopWithExplicitSavepointType() throws Exception {
assertThat(jobID, is(jid));
assertThat(advanceToEndOfEventTime, is(false));
assertThat(savepointDirectory, is("test-target-dir"));
assertThat(formatType, is(expectedFormat));
stopWithSavepointLatch.trigger();
return CompletableFuture.completedFuture(savepointDirectory);
});
Expand Down

0 comments on commit 6d4189e

Please sign in to comment.