use of org.apache.flink.runtime.instance.ActorGateway in project flink by apache.
the class CliFrontendSavepointTest method testDisposeClassNotFoundException.
/**
* Tests that a disposal failure due a ClassNotFoundException triggers a
* note about the JAR option.
*/
@Test
public void testDisposeClassNotFoundException() throws Exception {
replaceStdOutAndStdErr();
try {
Future<Object> classNotFoundFailure = Futures.<Object>successful(new DisposeSavepointFailure(new ClassNotFoundException("Test exception")));
ActorGateway jobManager = mock(ActorGateway.class);
when(jobManager.ask(any(DisposeSavepoint.class), any(FiniteDuration.class))).thenReturn(classNotFoundFailure);
CliFrontend frontend = new MockCliFrontend(CliFrontendTestUtils.getConfigDir(), jobManager);
String[] parameters = { "-d", "any-path" };
int returnCode = frontend.savepoint(parameters);
assertTrue(returnCode != 0);
String out = buffer.toString();
assertTrue(out.contains("Please provide the program jar with which you have created " + "the savepoint via -j <JAR> for disposal"));
} finally {
restoreStdOutAndStdErr();
}
}
use of org.apache.flink.runtime.instance.ActorGateway in project flink by apache.
the class CliFrontendSavepointTest method testTriggerSavepointFailureUnknownResponse.
@Test
public void testTriggerSavepointFailureUnknownResponse() throws Exception {
replaceStdOutAndStdErr();
try {
JobID jobId = new JobID();
ActorGateway jobManager = mock(ActorGateway.class);
Promise<Object> triggerResponse = new scala.concurrent.impl.Promise.DefaultPromise<>();
when(jobManager.ask(Mockito.eq(new TriggerSavepoint(jobId, Option.<String>empty())), any(FiniteDuration.class))).thenReturn(triggerResponse.future());
triggerResponse.success("UNKNOWN RESPONSE");
CliFrontend frontend = new MockCliFrontend(CliFrontendTestUtils.getConfigDir(), jobManager);
String[] parameters = { jobId.toString() };
int returnCode = frontend.savepoint(parameters);
assertTrue(returnCode != 0);
verify(jobManager, times(1)).ask(Mockito.eq(new TriggerSavepoint(jobId, Option.<String>empty())), any(FiniteDuration.class));
String errMsg = buffer.toString();
assertTrue(errMsg.contains("IllegalStateException"));
assertTrue(errMsg.contains("Unknown JobManager response"));
} finally {
restoreStdOutAndStdErr();
}
}
use of org.apache.flink.runtime.instance.ActorGateway in project flink by apache.
the class CliFrontendSavepointTest method testDisposeWithJar.
/**
* Tests disposal with a JAR file.
*/
@Test
public void testDisposeWithJar() throws Exception {
replaceStdOutAndStdErr();
try {
ActorGateway jobManager = mock(ActorGateway.class);
when(jobManager.ask(any(DisposeSavepoint.class), any(FiniteDuration.class))).thenReturn(Futures.successful(JobManagerMessages.getDisposeSavepointSuccess()));
CliFrontend frontend = new MockCliFrontend(CliFrontendTestUtils.getConfigDir(), jobManager);
// Fake JAR file
File f = tmp.newFile();
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(f));
out.close();
String[] parameters = { "-d", "any-path", "-j", f.getAbsolutePath() };
int returnCode = frontend.savepoint(parameters);
assertEquals(0, returnCode);
} finally {
restoreStdOutAndStdErr();
}
}
use of org.apache.flink.runtime.instance.ActorGateway in project flink by apache.
the class CliFrontendSavepointTest method testDisposeSavepointFailureUnknownResponse.
@Test
public void testDisposeSavepointFailureUnknownResponse() throws Exception {
replaceStdOutAndStdErr();
try {
String savepointPath = "expectedSavepointPath";
ActorGateway jobManager = mock(ActorGateway.class);
Promise<Object> triggerResponse = new scala.concurrent.impl.Promise.DefaultPromise<>();
when(jobManager.ask(Mockito.eq(new DisposeSavepoint(savepointPath)), any(FiniteDuration.class))).thenReturn(triggerResponse.future());
triggerResponse.success("UNKNOWN RESPONSE");
CliFrontend frontend = new MockCliFrontend(CliFrontendTestUtils.getConfigDir(), jobManager);
String[] parameters = { "-d", savepointPath };
int returnCode = frontend.savepoint(parameters);
assertTrue(returnCode != 0);
verify(jobManager, times(1)).ask(Mockito.eq(new DisposeSavepoint(savepointPath)), any(FiniteDuration.class));
String errMsg = buffer.toString();
assertTrue(errMsg.contains("IllegalStateException"));
assertTrue(errMsg.contains("Unknown JobManager response"));
} finally {
restoreStdOutAndStdErr();
}
replaceStdOutAndStdErr();
}
use of org.apache.flink.runtime.instance.ActorGateway in project flink by apache.
the class CliFrontendSavepointTest method testTriggerSavepointCustomTarget.
/**
* Tests that a CLI call with a custom savepoint directory target is
* forwarded correctly to the JM.
*/
@Test
public void testTriggerSavepointCustomTarget() throws Exception {
replaceStdOutAndStdErr();
try {
JobID jobId = new JobID();
Option<String> customTarget = Option.apply("customTargetDirectory");
ActorGateway jobManager = mock(ActorGateway.class);
Promise<Object> triggerResponse = new scala.concurrent.impl.Promise.DefaultPromise<>();
when(jobManager.ask(Mockito.eq(new TriggerSavepoint(jobId, customTarget)), any(FiniteDuration.class))).thenReturn(triggerResponse.future());
String savepointPath = "expectedSavepointPath";
triggerResponse.success(new TriggerSavepointSuccess(jobId, -1, savepointPath, -1));
CliFrontend frontend = new MockCliFrontend(CliFrontendTestUtils.getConfigDir(), jobManager);
String[] parameters = { jobId.toString(), customTarget.get() };
int returnCode = frontend.savepoint(parameters);
assertEquals(0, returnCode);
verify(jobManager, times(1)).ask(Mockito.eq(new TriggerSavepoint(jobId, customTarget)), any(FiniteDuration.class));
assertTrue(buffer.toString().contains("expectedSavepointPath"));
} finally {
restoreStdOutAndStdErr();
}
}
Aggregations