use of org.apache.flink.client.cli.util.MockedCliFrontend in project flink by apache.
the class CliFrontendStopWithSavepointTest method testStopWithMaxWMAndExplicitSavepointDir.
@Test
public void testStopWithMaxWMAndExplicitSavepointDir() throws Exception {
JobID jid = new JobID();
String[] parameters = { "-d", "-p", "test-target-dir", jid.toString() };
OneShotLatch stopWithSavepointLatch = new OneShotLatch();
TestingClusterClient<String> clusterClient = new TestingClusterClient<>();
clusterClient.setStopWithSavepointFunction((jobID, advanceToEndOfEventTime, savepointDirectory, formatType) -> {
assertThat(jobID, is(jid));
assertThat(advanceToEndOfEventTime, is(true));
assertThat(savepointDirectory, is("test-target-dir"));
stopWithSavepointLatch.trigger();
return CompletableFuture.completedFuture(savepointDirectory);
});
MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
testFrontend.stop(parameters);
stopWithSavepointLatch.await();
}
use of org.apache.flink.client.cli.util.MockedCliFrontend in project flink by apache.
the class CliFrontendStopWithSavepointTest method testStopWithOnlyJobId.
@Test
public void testStopWithOnlyJobId() throws Exception {
// test stop properly
JobID jid = new JobID();
String jidString = jid.toString();
String[] parameters = { jidString };
OneShotLatch stopWithSavepointLatch = new OneShotLatch();
TestingClusterClient<String> clusterClient = new TestingClusterClient<>();
clusterClient.setStopWithSavepointFunction((jobID, advanceToEndOfEventTime, savepointDirectory, formatType) -> {
assertThat(jobID, is(jid));
assertThat(advanceToEndOfEventTime, is(false));
assertNull(savepointDirectory);
stopWithSavepointLatch.trigger();
return CompletableFuture.completedFuture(savepointDirectory);
});
MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
testFrontend.stop(parameters);
stopWithSavepointLatch.await();
}
use of org.apache.flink.client.cli.util.MockedCliFrontend in project flink by apache.
the class CliFrontendStopWithSavepointTest method testWrongSavepointDirOrder.
@Test(expected = CliArgsException.class)
public void testWrongSavepointDirOrder() throws Exception {
JobID jid = new JobID();
String[] parameters = { "-s", "-d", "test-target-dir", jid.toString() };
MockedCliFrontend testFrontend = new MockedCliFrontend(new TestingClusterClient());
testFrontend.stop(parameters);
}
use of org.apache.flink.client.cli.util.MockedCliFrontend in project flink by apache.
the class CliFrontendSavepointTest method testTriggerSavepointFailure.
@Test
public void testTriggerSavepointFailure() throws Exception {
replaceStdOutAndStdErr();
JobID jobId = new JobID();
String expectedTestException = "expectedTestException";
Exception testException = new Exception(expectedTestException);
final ClusterClient<String> clusterClient = createFailingClusterClient(testException);
try {
MockedCliFrontend frontend = new MockedCliFrontend(clusterClient);
String[] parameters = { jobId.toString() };
try {
frontend.savepoint(parameters);
fail("Savepoint should have failed.");
} catch (FlinkException e) {
assertTrue(ExceptionUtils.findThrowableWithMessage(e, expectedTestException).isPresent());
}
} finally {
clusterClient.close();
restoreStdOutAndStdErr();
}
}
use of org.apache.flink.client.cli.util.MockedCliFrontend in project flink by apache.
the class CliFrontendSavepointTest method testTriggerSavepointFailureIllegalJobID.
@Test
public void testTriggerSavepointFailureIllegalJobID() throws Exception {
replaceStdOutAndStdErr();
try {
CliFrontend frontend = new MockedCliFrontend(new RestClusterClient<>(getConfiguration(), StandaloneClusterId.getInstance()));
String[] parameters = { "invalid job id" };
try {
frontend.savepoint(parameters);
fail("Should have failed.");
} catch (CliArgsException e) {
assertThat(e.getMessage(), Matchers.containsString("Cannot parse JobID"));
}
} finally {
restoreStdOutAndStdErr();
}
}
Aggregations