use of akka.http.javadsl.model.HttpResponse in project mantis by Netflix.
the class JobRouteTest method setupJobCluster.
@Test(dependsOnMethods = { "cleanupExistingJobs" })
public void setupJobCluster() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final CompletionStage<HttpResponse> responseFuture = http.singleRequest(HttpRequest.POST(jobClusterAPIEndpoint("create")).withMethod(HttpMethods.POST).withEntity(HttpEntities.create(ContentTypes.APPLICATION_JSON, JobClusterPayloads.JOB_CLUSTER_CREATE)));
responseFuture.thenCompose(r -> processRespFut(r, Optional.of(200))).whenComplete((r, t) -> {
String responseMessage = getResponseMessage(r, t);
logger.info("got response {}", responseMessage);
assertEquals("sine-function created", responseMessage);
latch.countDown();
});
assertTrue(latch.await(2, TimeUnit.SECONDS));
}
use of akka.http.javadsl.model.HttpResponse in project mantis by Netflix.
the class AgentClustersRouteTest method testGetActiveAgentClusters.
@Test(dependsOnMethods = { "testGetAutoScalePolicy" })
public void testGetActiveAgentClusters() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final CompletionStage<HttpResponse> responseFuture = http.singleRequest(HttpRequest.GET(SERVER_ENDPOINT));
responseFuture.thenCompose(r -> processRespFut(r, 200)).whenComplete((msg, t) -> {
String responseMessage = getResponseMessage(msg, t);
logger.info("got response {}", responseMessage);
assertEquals(AgentClusterPayloads.SET_ACTIVE, responseMessage);
latch.countDown();
});
assertTrue(latch.await(1, TimeUnit.SECONDS));
}
use of akka.http.javadsl.model.HttpResponse in project mantis by Netflix.
the class AgentClustersRouteTest method testGetAutoScalePolicy.
@Test(dependsOnMethods = { "testGetJobsOnAgentClusters" })
public void testGetAutoScalePolicy() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final CompletionStage<HttpResponse> responseFuture = http.singleRequest(HttpRequest.GET(SERVER_ENDPOINT + "/autoScalePolicy"));
responseFuture.thenCompose(r -> processRespFut(r, 200)).whenComplete((msg, t) -> {
String responseMessage = getResponseMessage(msg, t);
logger.info("got response {}", responseMessage);
try {
Map<String, AgentClusterOperations.AgentClusterAutoScaleRule> agentClusterAutoScaleRule = mapper.readValue(responseMessage, new TypeReference<Map<String, AgentClusterOperations.AgentClusterAutoScaleRule>>() {
});
agentClusterAutoScaleRule.values().forEach(autoScaleRule -> {
assertEquals("test", autoScaleRule.getName());
assertEquals(300, autoScaleRule.getCooldownSecs());
assertEquals(1, autoScaleRule.getMinIdle());
assertEquals(10, autoScaleRule.getMaxIdle());
assertEquals(1, autoScaleRule.getMinSize());
assertEquals(100, autoScaleRule.getMaxSize());
});
} catch (IOException e) {
logger.error("caught error", e);
fail("failed to deserialize response");
}
latch.countDown();
});
assertTrue(latch.await(1, TimeUnit.SECONDS));
}
use of akka.http.javadsl.model.HttpResponse in project mantis by Netflix.
the class JobRouteTest method testJobClusterDelete.
@Test(dependsOnMethods = { "testJobClusterDisable" })
public void testJobClusterDelete() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final CompletionStage<HttpResponse> responseFuture = http.singleRequest(HttpRequest.POST(jobClusterAPIEndpoint("delete")).withEntity(HttpEntities.create(ContentTypes.APPLICATION_JSON, JobClusterPayloads.JOB_CLUSTER_DELETE)));
responseFuture.thenCompose(r -> processRespFut(r, Optional.of(200))).whenComplete((msg, t) -> {
String responseMessage = getResponseMessage(msg, t);
logger.info("got response {}", responseMessage);
assertEquals("sine-function deleted", responseMessage);
latch.countDown();
});
assertTrue(latch.await(1, TimeUnit.SECONDS));
}
use of akka.http.javadsl.model.HttpResponse in project mantis by Netflix.
the class JobRouteTest method testJobClusterGetJobIds.
@Test(dependsOnMethods = { "testJobSubmit" })
public void testJobClusterGetJobIds() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final CompletionStage<HttpResponse> responseFuture = http.singleRequest(HttpRequest.GET(jobClusterAPIEndpoint("listJobIds/sine-function?jobState=Active")));
responseFuture.thenCompose(r -> processRespFut(r, Optional.of(200))).whenComplete((msg, t) -> {
try {
String responseMessage = getResponseMessage(msg, t);
logger.info("got response {}", responseMessage);
List<JobClusterProtoAdapter.JobIdInfo> jobIdInfos = Jackson.fromJSON(responseMessage, new TypeReference<List<JobClusterProtoAdapter.JobIdInfo>>() {
});
logger.info("jobInfos---> {}", jobIdInfos);
assertEquals(1, jobIdInfos.size());
JobClusterProtoAdapter.JobIdInfo jobIdInfo = jobIdInfos.get(0);
assertEquals("sine-function-1", jobIdInfo.getJobId());
// assertEquals("0.1.39 2018-03-13 09:40:53", jobIdInfo.getVersion());
assertEquals("", jobIdInfo.getTerminatedAt());
assertEquals("nmahilani", jobIdInfo.getUser());
assertTrue(jobIdInfo.getState().equals(MantisJobState.Accepted) || jobIdInfo.getState().equals(MantisJobState.Launched));
} catch (Exception e) {
fail("unexpected error " + e.getMessage());
}
latch.countDown();
});
assertTrue(latch.await(2, TimeUnit.SECONDS));
}
Aggregations