use of io.mantisrx.shaded.com.fasterxml.jackson.core.type.TypeReference 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 io.mantisrx.shaded.com.fasterxml.jackson.core.type.TypeReference 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));
}
use of io.mantisrx.shaded.com.fasterxml.jackson.core.type.TypeReference in project mantis by Netflix.
the class JobRouteTest method testJobClusterGetJobsCompact.
@Test(dependsOnMethods = { "testJobClusterGetJobDetail" })
public void testJobClusterGetJobsCompact() throws InterruptedException {
final CompletionStage<HttpResponse> responseFuture = http.singleRequest(HttpRequest.GET(jobAPIEndpoint("list?compact=true")));
try {
responseFuture.thenCompose(r -> processRespFut(r, Optional.of(200))).whenComplete((msg, t) -> {
String responseMessage = getResponseMessage(msg, t);
logger.info("got response {}", responseMessage);
List<CompactJobInfo> jobIdInfos = Collections.emptyList();
try {
jobIdInfos = Jackson.fromJSON(responseMessage, new TypeReference<List<CompactJobInfo>>() {
});
} catch (IOException e) {
logger.error("failed to get CompactJobInfos from json response {}", responseMessage, e);
fail("compactJobInfo deser failed");
}
logger.info("got jobIdInfos {}", jobIdInfos);
assertEquals(1, jobIdInfos.size());
CompactJobInfo jobInfo = jobIdInfos.get(0);
assertEquals("sine-function-1", jobInfo.getJobId());
assertEquals("nmahilani", jobInfo.getUser());
assertEquals(7, jobInfo.getLabels().size());
assertEquals(2, jobInfo.getNumStages());
assertEquals(2, jobInfo.getNumWorkers());
assertTrue(jobInfo.getState().equals(MantisJobState.Accepted) || jobInfo.getState().equals(MantisJobState.Launched));
assertEquals(2.0, jobInfo.getTotCPUs(), 0.0);
// TODO total memory is 400 for old master, 2048 for new master
// assertEquals(400.0, jobInfo.getTotMemory(), 0.0);
assertEquals(MantisJobDurationType.Perpetual, jobInfo.getType());
assertTrue(Collections.singletonMap("Started", 2).equals(jobInfo.getStatesSummary()) || Collections.singletonMap("StartInitiated", 2).equals(jobInfo.getStatesSummary()) || Collections.singletonMap("Launched", 2).equals(jobInfo.getStatesSummary()) || Collections.singletonMap("Accepted", 2).equals(jobInfo.getStatesSummary()));
}).toCompletableFuture().get(2, TimeUnit.SECONDS);
} catch (ExecutionException e) {
throw new RuntimeException(e);
} catch (TimeoutException e) {
throw new RuntimeException(e);
}
}
use of io.mantisrx.shaded.com.fasterxml.jackson.core.type.TypeReference in project mantis by Netflix.
the class JobRouteTest method testJobClusterGetJobsList.
@Test(dependsOnMethods = { "testJobClusterGetJobIds" })
public void testJobClusterGetJobsList() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final CompletionStage<HttpResponse> responseFuture = http.singleRequest(HttpRequest.GET(jobAPIEndpoint("list")));
responseFuture.thenCompose(r -> processRespFut(r, Optional.of(200))).whenComplete((msg, t) -> {
String responseMessage = getResponseMessage(msg, t);
logger.info("got response---> {}", responseMessage);
List<MantisJobMetadataView> jobInfos = Collections.emptyList();
try {
jobInfos = Jackson.fromJSON(responseMessage, new TypeReference<List<MantisJobMetadataView>>() {
});
} catch (IOException e) {
logger.error("failed to deser json {}", responseMessage, e);
fail("job list deser failed");
}
logger.info("jobInfos---> {}", jobInfos);
assertEquals(1, jobInfos.size());
MantisJobMetadataView mjm = jobInfos.get(0);
assertEquals(mjm.getJobMetadata().getJobId(), "sine-function-1");
assertEquals(mjm.getJobMetadata().getName(), "sine-function");
assertTrue(mjm.getStageMetadataList().size() > 0);
MantisStageMetadataWritable msm = mjm.getStageMetadataList().get(0);
assertEquals(1, msm.getNumWorkers());
assertTrue(mjm.getWorkerMetadataList().size() > 0);
MantisWorkerMetadataWritable mwm = mjm.getWorkerMetadataList().get(0);
assertEquals("sine-function-1", mwm.getJobId());
assertEquals(false, mwm.getCluster().isPresent());
latch.countDown();
});
assertTrue(latch.await(2, TimeUnit.SECONDS));
}
use of io.mantisrx.shaded.com.fasterxml.jackson.core.type.TypeReference in project mantis by Netflix.
the class JobClusterRouteTest method testJobClusterGetDetail.
@Test(dependsOnMethods = { "testJobClustersList" })
public void testJobClusterGetDetail() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final CompletionStage<HttpResponse> responseFuture = http.singleRequest(HttpRequest.GET(namedJobAPIEndpoint("list/sine-function")));
responseFuture.thenCompose(r -> processRespFut(r, 200)).whenComplete((msg, t) -> {
String responseMessage = getResponseMessage(msg, t);
logger.info("got response {}", responseMessage);
try {
List<MantisJobClusterMetadataView> jobClusters = Jackson.fromJSON(responseMessage, new TypeReference<List<MantisJobClusterMetadataView>>() {
});
assertEquals(1, jobClusters.size());
MantisJobClusterMetadataView jc = jobClusters.get(0);
assertEquals("sine-function", jc.getName());
// TODO fix Jars list
assertEquals(2, jc.getJars().size());
assertEquals(2, jc.getJars().get(0).getSchedulingInfo().getStages().size());
assertEquals(1, jc.getJars().get(0).getSchedulingInfo().getStages().get(1).getNumberOfInstances());
assertEquals(true, jc.getJars().get(0).getSchedulingInfo().getStages().get(1).getScalable());
assertEquals("sine-function", jc.getName());
} catch (Exception e) {
logger.error("failed to deser json {}", responseMessage, e);
fail("failed to deser json " + responseMessage);
}
latch.countDown();
});
assertTrue(latch.await(2, TimeUnit.SECONDS));
}
Aggregations