Search in sources :

Example 61 with ActorGateway

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();
    }
}
Also used : DisposeSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.DisposeSavepoint) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) FiniteDuration(scala.concurrent.duration.FiniteDuration) DisposeSavepointFailure(org.apache.flink.runtime.messages.JobManagerMessages.DisposeSavepointFailure) TriggerSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.TriggerSavepoint) DisposeSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.DisposeSavepoint) Test(org.junit.Test)

Example 62 with ActorGateway

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();
    }
}
Also used : FiniteDuration(scala.concurrent.duration.FiniteDuration) TriggerSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.TriggerSavepoint) DisposeSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.DisposeSavepoint) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) TriggerSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.TriggerSavepoint) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 63 with ActorGateway

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();
    }
}
Also used : DisposeSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.DisposeSavepoint) ZipOutputStream(java.util.zip.ZipOutputStream) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) FileOutputStream(java.io.FileOutputStream) FiniteDuration(scala.concurrent.duration.FiniteDuration) File(java.io.File) TriggerSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.TriggerSavepoint) DisposeSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.DisposeSavepoint) Test(org.junit.Test)

Example 64 with ActorGateway

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();
}
Also used : FiniteDuration(scala.concurrent.duration.FiniteDuration) TriggerSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.TriggerSavepoint) DisposeSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.DisposeSavepoint) DisposeSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.DisposeSavepoint) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) Test(org.junit.Test)

Example 65 with ActorGateway

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();
    }
}
Also used : FiniteDuration(scala.concurrent.duration.FiniteDuration) TriggerSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.TriggerSavepoint) DisposeSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.DisposeSavepoint) TriggerSavepointSuccess(org.apache.flink.runtime.messages.JobManagerMessages.TriggerSavepointSuccess) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) TriggerSavepoint(org.apache.flink.runtime.messages.JobManagerMessages.TriggerSavepoint) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Aggregations

ActorGateway (org.apache.flink.runtime.instance.ActorGateway)102 Test (org.junit.Test)81 Configuration (org.apache.flink.configuration.Configuration)44 AkkaActorGateway (org.apache.flink.runtime.instance.AkkaActorGateway)41 FiniteDuration (scala.concurrent.duration.FiniteDuration)37 JobID (org.apache.flink.api.common.JobID)36 JavaTestKit (akka.testkit.JavaTestKit)34 ActorRef (akka.actor.ActorRef)30 IOException (java.io.IOException)26 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)25 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)22 JobManagerMessages (org.apache.flink.runtime.messages.JobManagerMessages)22 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)20 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)17 TaskManagerServicesConfiguration (org.apache.flink.runtime.taskexecutor.TaskManagerServicesConfiguration)16 SubmitJob (org.apache.flink.runtime.messages.JobManagerMessages.SubmitJob)15 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)14 TaskDeploymentDescriptor (org.apache.flink.runtime.deployment.TaskDeploymentDescriptor)14 TriggerSavepoint (org.apache.flink.runtime.messages.JobManagerMessages.TriggerSavepoint)13 SubmitTask (org.apache.flink.runtime.messages.TaskMessages.SubmitTask)13