use of org.apache.flink.runtime.rest.util.TestRestServerEndpoint in project flink by apache.
the class RestClusterClientTest method testSendCoordinationRequest.
@Test
public void testSendCoordinationRequest() throws Exception {
final TestClientCoordinationHandler handler = new TestClientCoordinationHandler();
try (TestRestServerEndpoint restServerEndpoint = createRestServerEndpoint(handler)) {
RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort());
String payload = "testing payload";
TestCoordinationRequest<String> request = new TestCoordinationRequest<>(payload);
try {
CompletableFuture<CoordinationResponse> future = restClusterClient.sendCoordinationRequest(jobId, new OperatorID(), request);
TestCoordinationResponse response = (TestCoordinationResponse) future.get();
assertEquals(payload, response.payload);
} finally {
restClusterClient.close();
}
}
}
use of org.apache.flink.runtime.rest.util.TestRestServerEndpoint in project flink by apache.
the class RestClusterClientTest method testNotShowSuspendedJobStatus.
/**
* The SUSPENDED job status should never be returned by the client thus client retries until it
* either receives a different job status or the cluster is not reachable.
*/
@Test
public void testNotShowSuspendedJobStatus() throws Exception {
final List<JobDetailsInfo> jobDetails = new ArrayList<>();
jobDetails.add(buildJobDetail(JobStatus.SUSPENDED));
jobDetails.add(buildJobDetail(JobStatus.RUNNING));
final TestJobStatusHandler jobStatusHandler = new TestJobStatusHandler(jobDetails.iterator());
try (TestRestServerEndpoint restServerEndpoint = createRestServerEndpoint(jobStatusHandler)) {
final RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort());
try {
final CompletableFuture<JobStatus> future = restClusterClient.getJobStatus(jobId);
assertEquals(JobStatus.RUNNING, future.get());
} finally {
restClusterClient.close();
}
}
}
use of org.apache.flink.runtime.rest.util.TestRestServerEndpoint in project flink by apache.
the class RestClusterClientTest method testListJobs.
@Test
public void testListJobs() throws Exception {
try (TestRestServerEndpoint restServerEndpoint = createRestServerEndpoint(new TestListJobsHandler())) {
RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort());
try {
CompletableFuture<Collection<JobStatusMessage>> jobDetailsFuture = restClusterClient.listJobs();
Collection<JobStatusMessage> jobDetails = jobDetailsFuture.get();
Iterator<JobStatusMessage> jobDetailsIterator = jobDetails.iterator();
JobStatusMessage job1 = jobDetailsIterator.next();
JobStatusMessage job2 = jobDetailsIterator.next();
Assert.assertNotEquals("The job status should not be equal.", job1.getJobState(), job2.getJobState());
} finally {
restClusterClient.close();
}
}
}
use of org.apache.flink.runtime.rest.util.TestRestServerEndpoint in project flink by apache.
the class RestClusterClientTest method testDisposeSavepoint.
@Test
public void testDisposeSavepoint() throws Exception {
final String savepointPath = "foobar";
final String exceptionMessage = "Test exception.";
final FlinkException testException = new FlinkException(exceptionMessage);
final TestSavepointDisposalHandlers testSavepointDisposalHandlers = new TestSavepointDisposalHandlers(savepointPath);
final TestSavepointDisposalHandlers.TestSavepointDisposalTriggerHandler testSavepointDisposalTriggerHandler = testSavepointDisposalHandlers.new TestSavepointDisposalTriggerHandler();
final TestSavepointDisposalHandlers.TestSavepointDisposalStatusHandler testSavepointDisposalStatusHandler = testSavepointDisposalHandlers.new TestSavepointDisposalStatusHandler(OptionalFailure.of(AsynchronousOperationInfo.complete()), OptionalFailure.of(AsynchronousOperationInfo.completeExceptional(new SerializedThrowable(testException))), OptionalFailure.ofFailure(testException));
try (TestRestServerEndpoint restServerEndpoint = createRestServerEndpoint(testSavepointDisposalStatusHandler, testSavepointDisposalTriggerHandler)) {
RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort());
try {
{
final CompletableFuture<Acknowledge> disposeSavepointFuture = restClusterClient.disposeSavepoint(savepointPath);
assertThat(disposeSavepointFuture.get(), is(Acknowledge.get()));
}
{
final CompletableFuture<Acknowledge> disposeSavepointFuture = restClusterClient.disposeSavepoint(savepointPath);
try {
disposeSavepointFuture.get();
fail("Expected an exception");
} catch (ExecutionException ee) {
assertThat(ExceptionUtils.findThrowableWithMessage(ee, exceptionMessage).isPresent(), is(true));
}
}
{
try {
restClusterClient.disposeSavepoint(savepointPath).get();
fail("Expected an exception.");
} catch (ExecutionException ee) {
assertThat(ExceptionUtils.findThrowable(ee, RestClientException.class).isPresent(), is(true));
}
}
} finally {
restClusterClient.close();
}
}
}
use of org.apache.flink.runtime.rest.util.TestRestServerEndpoint in project flink by apache.
the class RestClusterClientTest method testJobSubmitCancel.
@Test
public void testJobSubmitCancel() throws Exception {
TestJobSubmitHandler submitHandler = new TestJobSubmitHandler();
TestJobCancellationHandler terminationHandler = new TestJobCancellationHandler();
try (TestRestServerEndpoint restServerEndpoint = createRestServerEndpoint(submitHandler, terminationHandler)) {
try (RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort())) {
Assert.assertFalse(submitHandler.jobSubmitted);
restClusterClient.submitJob(jobGraph).get();
Assert.assertTrue(submitHandler.jobSubmitted);
Assert.assertFalse(terminationHandler.jobCanceled);
restClusterClient.cancel(jobId).get();
Assert.assertTrue(terminationHandler.jobCanceled);
}
}
}
Aggregations