/** * Test deployment to non-existing queue & ensure that the system logs a WARN message * for the user. (Users had unexpected behavior of Flink on YARN because they mistyped the * target queue. With an error message, we can help users identifying the issue) */ @Test public void testNonexistingQueueWARNmessage() throws IOException { LOG.info("Starting testNonexistingQueueWARNmessage()"); addTestAppender(AbstractYarnClusterDescriptor.class, Level.WARN); try { runWithArgs(new String[]{"-j", flinkUberjar.getAbsolutePath(), "-t", flinkLibFolder.getAbsolutePath(), "-t", flinkShadedHadoopDir.getAbsolutePath(), "-n", "1", "-jm", "768m", "-tm", "1024m", "-qu", "doesntExist"}, "to unknown queue: doesntExist", null, RunTypes.YARN_SESSION, 1); } catch (Exception e) { assertTrue(ExceptionUtils.findThrowableWithMessage(e, "to unknown queue: doesntExist").isPresent()); } checkForLogString("The specified queue 'doesntExist' does not exist. Available queues"); LOG.info("Finished testNonexistingQueueWARNmessage()"); }
/** * Tests that cancel with savepoint without a properly configured savepoint * directory, will fail with a meaningful exception message. */ @Test public void testCancelWithSavepointWithoutConfiguredSavepointDirectory() throws Exception { setUpWithCheckpointInterval(10L); try { clusterClient.cancelWithSavepoint(jobGraph.getJobID(), null); } catch (Exception e) { if (!ExceptionUtils.findThrowableWithMessage(e, "savepoint directory").isPresent()) { throw e; } } }
/** * Tests that the send operation is not being retried when receiving a NOT_FOUND return code. */ @Test public void testSendIsNotRetriableIfHttpNotFound() throws Exception { final String exceptionMessage = "test exception"; final PingRestHandler pingRestHandler = new PingRestHandler( FutureUtils.completedExceptionally(new RestHandlerException(exceptionMessage, HttpResponseStatus.NOT_FOUND))); try (final TestRestServerEndpoint restServerEndpoint = createRestServerEndpoint(pingRestHandler)) { RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort()); try { restClusterClient.sendRequest(PingRestHandlerHeaders.INSTANCE).get(); fail("The rest request should have failed."); } catch (Exception e) { assertThat(ExceptionUtils.findThrowableWithMessage(e, exceptionMessage).isPresent(), is(true)); } finally { restClusterClient.shutdown(); } } }
@Test public void testDisposeSavepointFailure() throws Exception { replaceStdOutAndStdErr(); String savepointPath = "expectedSavepointPath"; Exception testException = new Exception("expectedTestException"); DisposeSavepointClusterClient clusterClient = new DisposeSavepointClusterClient((String path) -> FutureUtils.completedExceptionally(testException), getConfiguration()); try { CliFrontend frontend = new MockedCliFrontend(clusterClient); String[] parameters = { "-d", savepointPath }; try { frontend.savepoint(parameters); fail("Savepoint should have failed."); } catch (Exception e) { assertTrue(ExceptionUtils.findThrowableWithMessage(e, testException.getMessage()).isPresent()); } } finally { clusterClient.shutdown(); restoreStdOutAndStdErr(); } }
@Test public void testDisposeClassNotFoundException() throws Exception { final Configuration configuration = new Configuration(); final Time timeout = Time.milliseconds(1000L); final String savepointPath = "foobar"; final ActorGateway jobManagerGateway = new TestDisposeWithClassNotFoundExceptionActorGateway(); final TestClusterClient clusterClient = new TestClusterClient(configuration, jobManagerGateway); CompletableFuture<Acknowledge> acknowledgeCompletableFuture = clusterClient.disposeSavepoint(savepointPath); try { acknowledgeCompletableFuture.get(); fail("Dispose operation should have failed."); } catch (ExecutionException e) { assertTrue(ExceptionUtils.findThrowableWithMessage( e, "Savepoint disposal failed, because of a " + "missing class. This is most likely caused by a custom state " + "instance, which cannot be disposed without the user code class " + "loader. Please provide the program jar with which you have created " + "the savepoint via -j <JAR> for disposal.").isPresent()); } finally { clusterClient.shutdown(); } }
@Test public void testUnknownJobId() throws Exception { // test unknown job Id JobID jid = new JobID(); String[] parameters = { jid.toString() }; String expectedMessage = "Test exception"; FlinkException testException = new FlinkException(expectedMessage); final ClusterClient<String> clusterClient = createClusterClient(testException); MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient); try { testFrontend.stop(parameters); fail("Should have failed."); } catch (FlinkException e) { assertTrue(ExceptionUtils.findThrowableWithMessage(e, expectedMessage).isPresent()); } }
@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.shutdown(); restoreStdOutAndStdErr(); } }
@Test public void testProgramWithAutoParallelism() throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(ExecutionConfig.PARALLELISM_AUTO_MAX); env.getConfig().disableSysoutLogging(); DataSet<Integer> result = env .createInput(new ParallelismDependentInputFormat()) .rebalance() .mapPartition(new ParallelismDependentMapPartition()); List<Integer> resultCollection = new ArrayList<>(); result.output(new LocalCollectionOutputFormat<>(resultCollection)); try { env.execute(); assertEquals(PARALLELISM, resultCollection.size()); } catch (Exception ex) { assertTrue( ExceptionUtils.findThrowableWithMessage(ex, ExecutionGraphBuilder.PARALLELISM_AUTO_MAX_ERROR_MESSAGE).isPresent()); } }
fail("Expected an exception"); } catch (ExecutionException ee) { assertThat(ExceptionUtils.findThrowableWithMessage(ee, exceptionMessage).isPresent(), is(true));
@Test public void testTriggerSavepointForNonExistingJob() throws Exception { // Config final int numTaskManagers = 1; final int numSlotsPerTaskManager = 1; final Configuration config = new Configuration(); config.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir.toURI().toString()); final MiniClusterWithClientResource cluster = new MiniClusterWithClientResource( new MiniClusterResourceConfiguration.Builder() .setConfiguration(config) .setNumberTaskManagers(numTaskManagers) .setNumberSlotsPerTaskManager(numSlotsPerTaskManager) .build()); cluster.before(); final ClusterClient<?> client = cluster.getClusterClient(); final JobID jobID = new JobID(); try { client.triggerSavepoint(jobID, null).get(); fail(); } catch (ExecutionException e) { assertTrue(ExceptionUtils.findThrowable(e, FlinkJobNotFoundException.class).isPresent()); assertTrue(ExceptionUtils.findThrowableWithMessage(e, jobID.toString()).isPresent()); } finally { cluster.after(); } }
} catch (ExecutionException e) { assertTrue(ExceptionUtils.findThrowable(e, IllegalStateException.class).isPresent()); assertTrue(ExceptionUtils.findThrowableWithMessage(e, graph.getJobID().toString()).isPresent()); assertTrue(ExceptionUtils.findThrowableWithMessage(e, "is not a streaming job").isPresent()); } finally { cluster.after();
private MiniClusterWithClientResource trySetUpCluster() throws Exception { try { Configuration config = new Configuration(); config.setString(TRANSPORT_TYPE, "epoll"); MiniClusterWithClientResource cluster = new MiniClusterWithClientResource( new MiniClusterResourceConfiguration.Builder() .setConfiguration(config) .setNumberTaskManagers(NUM_TASK_MANAGERS) .setNumberSlotsPerTaskManager(1) .build()); cluster.before(); return cluster; } catch (UnsatisfiedLinkError ex) { // If we failed to init netty because we are not on Linux platform, abort the test. if (findThrowableWithMessage(ex, "Only supported on Linux").isPresent()) { throw new AssumptionViolatedException("This test is only supported on linux"); } throw ex; } } }