Refine search
@Test public void testNonExistingJobRetrieval() throws Exception { final JobID jobID = new JobID(); try { client.requestJobResult(jobID).get(); fail(); } catch (Exception exception) { Optional<Throwable> expectedCause = ExceptionUtils.findThrowable(exception, candidate -> candidate.getMessage() != null && candidate.getMessage().contains("Could not find Flink job")); if (!expectedCause.isPresent()) { throw exception; } } }
@Test public void testGetAccumulators() throws Exception { TestAccumulatorHandler accumulatorHandler = new TestAccumulatorHandler(); try (TestRestServerEndpoint restServerEndpoint = createRestServerEndpoint(accumulatorHandler)){ RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort()); try { JobID id = new JobID(); { Map<String, OptionalFailure<Object>> accumulators = restClusterClient.getAccumulators(id); assertNotNull(accumulators); assertEquals(1, accumulators.size()); assertEquals(true, accumulators.containsKey("testKey")); assertEquals("testValue", accumulators.get("testKey").get().toString()); } } finally { restClusterClient.shutdown(); } } }
@Test public void testClusterClientSavepoint() throws Exception { Configuration config = new Configuration(); config.setString(JobManagerOptions.ADDRESS, "localhost"); JobID jobID = new JobID(); String savepointDirectory = "/test/directory"; String savepointPath = "/test/path"; TestSavepointActorGateway gateway = new TestSavepointActorGateway(jobID, savepointDirectory, savepointPath); TestClusterClient clusterClient = new TestClusterClient(config, gateway); try { CompletableFuture<String> pathFuture = clusterClient.triggerSavepoint(jobID, savepointDirectory); Assert.assertTrue(gateway.messageArrived); Assert.assertEquals(savepointPath, pathFuture.get()); } finally { clusterClient.shutdown(); } }
@Test public void testModifyJob() throws Exception { final JobID jobId = new JobID(); final int parallelism = 42; String[] args = {jobId.toString(), "-p", String.valueOf(parallelism)}; Tuple2<JobID, Integer> jobIdParallelism = callModify(args); assertThat(jobIdParallelism.f0, Matchers.is(jobId)); assertThat(jobIdParallelism.f1, Matchers.is(parallelism)); }
@Test public void testClusterClientCancelWithSavepoint() throws Exception { Configuration config = new Configuration(); config.setString(JobManagerOptions.ADDRESS, "localhost"); JobID jobID = new JobID(); String savepointDirectory = "/test/directory"; String savepointPath = "/test/path"; TestCancelWithSavepointActorGateway gateway = new TestCancelWithSavepointActorGateway(jobID, savepointDirectory, savepointPath); TestClusterClient clusterClient = new TestClusterClient(config, gateway); try { String path = clusterClient.cancelWithSavepoint(jobID, savepointDirectory); Assert.assertTrue(gateway.messageArrived); Assert.assertEquals(savepointPath, path); } finally { clusterClient.shutdown(); } }
@Test public void testFailingCheckpointStreamOperator() throws Exception { final long checkpointId = 42L; Whitebox.setInternalState(streamTask, "cancelables", new CloseableRegistry()); Whitebox.setInternalState(streamTask, "configuration", new StreamConfig(new Configuration())); Whitebox.setInternalState(streamTask, "checkpointStorage", new MemoryBackendCheckpointStorage(new JobID(), null, null, Integer.MAX_VALUE)); fail("Expected test exception here."); } catch (Exception e) { assertEquals(testException, e.getCause());
@Test public void testStop() throws Exception { // test stop properly JobID jid = new JobID(); String jidString = jid.toString(); String[] parameters = { jidString }; final ClusterClient<String> clusterClient = createClusterClient(null); MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient); testFrontend.stop(parameters); Mockito.verify(clusterClient, times(1)).stop(any(JobID.class)); }
@Test public void testAsyncCheckpointingConcurrentCloseAfterAcknowledge() throws Exception { final long checkpointId = 42L; new JobID(1L, 2L), new ExecutionAttemptID(1L, 2L), mock(TaskLocalStateStoreImpl.class), when(operatorChain.getAllOperators()).thenReturn(streamOperators); CheckpointStorage checkpointStorage = new MemoryBackendCheckpointStorage(new JobID(), null, null, Integer.MAX_VALUE); assertEquals(StateObjectCollection.singleton(managedKeyedStateHandle), subtaskState.getManagedKeyedState()); assertEquals(StateObjectCollection.singleton(rawKeyedStateHandle), subtaskState.getRawKeyedState()); assertEquals(StateObjectCollection.singleton(managedOperatorStateHandle), subtaskState.getManagedOperatorState()); assertEquals(StateObjectCollection.singleton(rawOperatorStateHandle), subtaskState.getRawOperatorState());
@Test public void testTriggerSavepoint() throws Exception { final String targetSavepointDirectory = "/tmp"; JobID id = new JobID(); assertEquals(savepointLocationDefaultDir, savepointPath); assertEquals(savepointLocationRequestedDir, savepointPath); restClusterClient.triggerSavepoint(new JobID(), null).get(); fail("Expected exception not thrown."); } catch (final ExecutionException e) {
@Test public void testCancel() throws Exception { // test cancel properly JobID jid = new JobID(); String[] parameters = { jid.toString() }; final ClusterClient<String> clusterClient = createClusterClient(); MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient); testFrontend.cancel(parameters); Mockito.verify(clusterClient, times(1)).cancel(any(JobID.class)); }
@Test @Ignore public void testWrongJobIdAndWrongQueryableStateName() throws Exception { assertEquals(JobStatus.RUNNING, jobStatusFuture.get(deadline.timeLeft().toMillis(), TimeUnit.MILLISECONDS)); final JobID wrongJobId = new JobID();
/** * Tests that we can set and retrieve the {@link KvStateLocationOracle}. */ @Test public void testKvStateLocationOracle() { final JobID jobId1 = new JobID(); final TestingKvStateLocationOracle kvStateLocationOracle1 = new TestingKvStateLocationOracle(); kvStateClientProxy.updateKvStateLocationOracle(jobId1, kvStateLocationOracle1); final JobID jobId2 = new JobID(); final TestingKvStateLocationOracle kvStateLocationOracle2 = new TestingKvStateLocationOracle(); kvStateClientProxy.updateKvStateLocationOracle(jobId2, kvStateLocationOracle2); assertThat(kvStateClientProxy.getKvStateLocationOracle(new JobID()), nullValue()); assertThat(kvStateClientProxy.getKvStateLocationOracle(jobId1), equalTo(kvStateLocationOracle1)); assertThat(kvStateClientProxy.getKvStateLocationOracle(jobId2), equalTo(kvStateLocationOracle2)); kvStateClientProxy.updateKvStateLocationOracle(jobId1, null); assertThat(kvStateClientProxy.getKvStateLocationOracle(jobId1), nullValue()); }
@Test public void testStopWorker() throws Exception { new Context() {{ new SlotRequest(new JobID(), new AllocationID(), resourceProfile1, taskHost)); return null; }); assertEquals(1, numberRegisteredSlots);
/** * Tests that {@link KvStateLocationOracle} registered under {@link HighAvailabilityServices#DEFAULT_JOB_ID} * will be used for all requests. */ @Test public void testLegacyCodePathPreference() { final TestingKvStateLocationOracle kvStateLocationOracle = new TestingKvStateLocationOracle(); kvStateClientProxy.updateKvStateLocationOracle(HighAvailabilityServices.DEFAULT_JOB_ID, kvStateLocationOracle); final JobID jobId = new JobID(); kvStateClientProxy.updateKvStateLocationOracle(jobId, new TestingKvStateLocationOracle()); assertThat(kvStateClientProxy.getKvStateLocationOracle(jobId), equalTo(kvStateLocationOracle)); }
@Test public void testConcurrentAsyncCheckpointCannotFailFinishedStreamTask() throws Exception { final Configuration taskConfiguration = new Configuration(); new JobID(), "Test Job", new SerializedValue<>(new ExecutionConfig()), assertEquals(ExecutionState.FINISHED, task.getExecutionState());
/** * Tests that a CLI call with a custom savepoint directory target is * forwarded correctly to the cluster client. */ @Test public void testTriggerSavepointCustomTarget() throws Exception { replaceStdOutAndStdErr(); JobID jobId = new JobID(); String savepointDirectory = "customTargetDirectory"; final ClusterClient<String> clusterClient = createClusterClient(savepointDirectory); try { MockedCliFrontend frontend = new MockedCliFrontend(clusterClient); String[] parameters = { jobId.toString(), savepointDirectory }; frontend.savepoint(parameters); verify(clusterClient, times(1)) .triggerSavepoint(eq(jobId), eq(savepointDirectory)); assertTrue(buffer.toString().contains(savepointDirectory)); } finally { clusterClient.shutdown(); restoreStdOutAndStdErr(); } }
@Test public void testExecutionGraphGeneration() throws Exception { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); final JobID jobId = new JobID(); final String jobName = "Semi-Rebalance Test Job"; final Configuration cfg = new Configuration(); JobVertex sinkVertex = jobVertices.get(2); assertEquals(2, sourceVertex.getParallelism()); assertEquals(4, mapVertex.getParallelism()); assertEquals(2, sinkVertex.getParallelism());