Search in sources :

Example 1 with Builder

use of org.apache.flink.runtime.taskexecutor.TaskSubmissionTestEnvironment.Builder in project flink by apache.

the class TaskExecutorTest method testTerminationOnFatalError.

@Test(timeout = 10000L)
public void testTerminationOnFatalError() throws Throwable {
    try (TaskSubmissionTestEnvironment env = new Builder(jobId).setConfiguration(configuration).build()) {
        String testExceptionMsg = "Test exception of fatal error.";
        env.getTaskExecutor().onFatalError(new Exception(testExceptionMsg));
        Throwable exception = env.getTestingFatalErrorHandler().getErrorFuture().get();
        env.getTestingFatalErrorHandler().clearError();
        assertThat(exception.getMessage(), startsWith(testExceptionMsg));
    }
}
Also used : TestingJobMasterGatewayBuilder(org.apache.flink.runtime.jobmaster.utils.TestingJobMasterGatewayBuilder) Builder(org.apache.flink.runtime.taskexecutor.TaskSubmissionTestEnvironment.Builder) TaskDeploymentDescriptorBuilder(org.apache.flink.runtime.deployment.TaskDeploymentDescriptorBuilder) NettyShuffleEnvironmentBuilder(org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) FlinkException(org.apache.flink.util.FlinkException) TaskSubmissionException(org.apache.flink.runtime.taskexecutor.exceptions.TaskSubmissionException) SlotNotFoundException(org.apache.flink.runtime.taskexecutor.slot.SlotNotFoundException) TriConsumerWithException(org.apache.flink.util.function.TriConsumerWithException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) RegistrationTimeoutException(org.apache.flink.runtime.taskexecutor.exceptions.RegistrationTimeoutException) CompletionException(java.util.concurrent.CompletionException) TaskManagerException(org.apache.flink.runtime.taskexecutor.exceptions.TaskManagerException) RecipientUnreachableException(org.apache.flink.runtime.rpc.exceptions.RecipientUnreachableException) Test(org.junit.Test)

Example 2 with Builder

use of org.apache.flink.runtime.taskexecutor.TaskSubmissionTestEnvironment.Builder in project flink by apache.

the class TaskExecutorTest method testLogNotFoundHandling.

@Test(timeout = 10000L)
public void testLogNotFoundHandling() throws Throwable {
    try (NetUtils.Port port = NetUtils.getAvailablePort()) {
        int dataPort = port.getPort();
        configuration.setInteger(NettyShuffleEnvironmentOptions.DATA_PORT, dataPort);
        configuration.setInteger(NettyShuffleEnvironmentOptions.NETWORK_REQUEST_BACKOFF_INITIAL, 100);
        configuration.setInteger(NettyShuffleEnvironmentOptions.NETWORK_REQUEST_BACKOFF_MAX, 200);
        configuration.setString(ConfigConstants.TASK_MANAGER_LOG_PATH_KEY, "/i/dont/exist");
        try (TaskSubmissionTestEnvironment env = new Builder(jobId).setConfiguration(configuration).setLocalCommunication(false).build()) {
            TaskExecutorGateway tmGateway = env.getTaskExecutorGateway();
            try {
                CompletableFuture<TransientBlobKey> logFuture = tmGateway.requestFileUploadByType(FileType.LOG, timeout);
                logFuture.get();
            } catch (Exception e) {
                assertThat(e.getMessage(), containsString("The file LOG does not exist on the TaskExecutor."));
            }
        }
    }
}
Also used : NetUtils(org.apache.flink.util.NetUtils) TransientBlobKey(org.apache.flink.runtime.blob.TransientBlobKey) TestingJobMasterGatewayBuilder(org.apache.flink.runtime.jobmaster.utils.TestingJobMasterGatewayBuilder) Builder(org.apache.flink.runtime.taskexecutor.TaskSubmissionTestEnvironment.Builder) TaskDeploymentDescriptorBuilder(org.apache.flink.runtime.deployment.TaskDeploymentDescriptorBuilder) NettyShuffleEnvironmentBuilder(org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder) FlinkException(org.apache.flink.util.FlinkException) TaskSubmissionException(org.apache.flink.runtime.taskexecutor.exceptions.TaskSubmissionException) SlotNotFoundException(org.apache.flink.runtime.taskexecutor.slot.SlotNotFoundException) TriConsumerWithException(org.apache.flink.util.function.TriConsumerWithException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) RegistrationTimeoutException(org.apache.flink.runtime.taskexecutor.exceptions.RegistrationTimeoutException) CompletionException(java.util.concurrent.CompletionException) TaskManagerException(org.apache.flink.runtime.taskexecutor.exceptions.TaskManagerException) RecipientUnreachableException(org.apache.flink.runtime.rpc.exceptions.RecipientUnreachableException) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)2 CompletionException (java.util.concurrent.CompletionException)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 TaskDeploymentDescriptorBuilder (org.apache.flink.runtime.deployment.TaskDeploymentDescriptorBuilder)2 NettyShuffleEnvironmentBuilder (org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder)2 TestingJobMasterGatewayBuilder (org.apache.flink.runtime.jobmaster.utils.TestingJobMasterGatewayBuilder)2 RecipientUnreachableException (org.apache.flink.runtime.rpc.exceptions.RecipientUnreachableException)2 Builder (org.apache.flink.runtime.taskexecutor.TaskSubmissionTestEnvironment.Builder)2 RegistrationTimeoutException (org.apache.flink.runtime.taskexecutor.exceptions.RegistrationTimeoutException)2 TaskManagerException (org.apache.flink.runtime.taskexecutor.exceptions.TaskManagerException)2 TaskSubmissionException (org.apache.flink.runtime.taskexecutor.exceptions.TaskSubmissionException)2 SlotNotFoundException (org.apache.flink.runtime.taskexecutor.slot.SlotNotFoundException)2 FlinkException (org.apache.flink.util.FlinkException)2 TriConsumerWithException (org.apache.flink.util.function.TriConsumerWithException)2 Test (org.junit.Test)2 TransientBlobKey (org.apache.flink.runtime.blob.TransientBlobKey)1 NetUtils (org.apache.flink.util.NetUtils)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1