use of io.mantisrx.server.master.domain.JobDefinition in project mantis by Netflix.
the class JobClusterManagerTest method testListJobs.
@Test
public void testListJobs() throws InvalidJobException {
TestKit probe = new TestKit(system);
// create cluster 1
String clusterName = "testListJobs";
JobClusterDefinitionImpl fakeJobCluster = createFakeJobClusterDefn(clusterName, Lists.newArrayList());
jobClusterManagerActor.tell(new JobClusterManagerProto.CreateJobClusterRequest(fakeJobCluster, "user"), probe.getRef());
JobClusterManagerProto.CreateJobClusterResponse resp = probe.expectMsgClass(JobClusterManagerProto.CreateJobClusterResponse.class);
assertEquals(SUCCESS_CREATED, resp.responseCode);
// submit job to this cluster
JobDefinition jobDefn = createJob(clusterName);
jobClusterManagerActor.tell(new JobClusterManagerProto.SubmitJobRequest(clusterName, "me", Optional.ofNullable(jobDefn)), probe.getRef());
JobClusterManagerProto.SubmitJobResponse submitResp = probe.expectMsgClass(JobClusterManagerProto.SubmitJobResponse.class);
assertEquals(SUCCESS, submitResp.responseCode);
// create cluster 2
String clusterName2 = "testListJobs2";
fakeJobCluster = createFakeJobClusterDefn(clusterName2, Lists.newArrayList());
jobClusterManagerActor.tell(new JobClusterManagerProto.CreateJobClusterRequest(fakeJobCluster, "user"), probe.getRef());
resp = probe.expectMsgClass(JobClusterManagerProto.CreateJobClusterResponse.class);
assertEquals(SUCCESS_CREATED, resp.responseCode);
// submit job to this cluster
jobDefn = createJob(clusterName2);
jobClusterManagerActor.tell(new JobClusterManagerProto.SubmitJobRequest(clusterName2, "me", Optional.ofNullable(jobDefn)), probe.getRef());
submitResp = probe.expectMsgClass(JobClusterManagerProto.SubmitJobResponse.class);
assertEquals(SUCCESS, submitResp.responseCode);
jobClusterManagerActor.tell(new JobClusterManagerProto.ListJobsRequest(), probe.getRef());
JobClusterManagerProto.ListJobsResponse listResp = probe.expectMsgClass(JobClusterManagerProto.ListJobsResponse.class);
System.out.println("Got " + listResp.getJobList().size());
boolean foundJob1 = false;
boolean foundJob2 = false;
for (MantisJobMetadataView v : listResp.getJobList()) {
System.out.println("Job -> " + v.getJobMetadata().getJobId());
String jId = v.getJobMetadata().getJobId();
if (jId.equals("testListJobs-1")) {
foundJob1 = true;
} else if (jId.equals("testListJobs2-1")) {
foundJob2 = true;
}
}
assertTrue(listResp.getJobList().size() >= 2);
assertTrue(foundJob1 && foundJob2);
}
use of io.mantisrx.server.master.domain.JobDefinition in project mantis by Netflix.
the class JobManagerTest method terminatingToActiveIsIgnored.
@Test
public void terminatingToActiveIsIgnored() {
JobClusterActor.JobManager jm = new JobManager("name", context, scheduler, publisher, jobStore);
JobId jId1 = new JobId("name", 1);
JobDefinition jdMock = mock(JobDefinition.class);
JobInfo jInfo1 = new JobInfo(jId1, jdMock, 0, null, JobState.Accepted, "nj");
jm.markJobAccepted(jInfo1);
assertEquals(1, jm.acceptedJobsCount());
Optional<JobInfo> jInfo1Op = jm.getJobInfoForNonTerminalJob(jId1);
assertTrue(jInfo1Op.isPresent());
assertTrue(jm.markJobTerminating(jInfo1Op.get(), JobState.Terminating_abnormal));
jInfo1Op = jm.getJobInfoForNonTerminalJob(jId1);
assertTrue(jInfo1Op.isPresent());
assertFalse(jm.markJobStarted(jInfo1Op.get()));
}
use of io.mantisrx.server.master.domain.JobDefinition in project mantis by Netflix.
the class LabelManagerTest method replaceVersionLabelTest.
@Test
public void replaceVersionLabelTest() throws InvalidJobException {
String artifactName = "art1.zip";
String v0 = "1.0";
String v1 = "2.0";
List<Label> labels = new ArrayList<>();
labels.add(new Label(MANTIS_VERSION_LABEL.label, v0));
JobDefinition jobDefinition = generateJobDefinition("replaceVersionLabelTest", labels, artifactName, "2.0");
JobDefinition updatedJobDefn = LabelManager.insertSystemLabels(jobDefinition, false);
assertEquals(2, updatedJobDefn.getLabels().size());
labels = updatedJobDefn.getLabels().stream().filter(label -> label.getName().equals(MANTIS_VERSION_LABEL.label)).collect(Collectors.toList());
Label label = labels.get(0);
assertEquals(MANTIS_VERSION_LABEL.label, label.getName());
assertEquals(v1, label.getValue());
}
use of io.mantisrx.server.master.domain.JobDefinition in project mantis by Netflix.
the class LabelManagerTest method insertVersionLabelTest.
@Test
public void insertVersionLabelTest() throws InvalidJobException {
String artifactName = "art.zip";
JobDefinition jobDefinition = generateJobDefinition("insertVersionLabelTest", new ArrayList<>(), artifactName, "1.0");
JobDefinition updatedJobDefn = LabelManager.insertSystemLabels(jobDefinition, false);
assertEquals(2, updatedJobDefn.getLabels().size());
List<Label> labels = updatedJobDefn.getLabels().stream().filter(label -> label.getName().equals(MANTIS_VERSION_LABEL.label)).collect(Collectors.toList());
Label label = labels.get(0);
assertEquals(MANTIS_VERSION_LABEL.label, label.getName());
assertEquals("1.0", label.getValue());
}
use of io.mantisrx.server.master.domain.JobDefinition in project mantis by Netflix.
the class LabelManagerTest method systemLabelTest.
@Test
public void systemLabelTest() throws InvalidJobException {
String artifactName = "art1.zip";
List<Label> labels = new ArrayList<>();
labels.add(new Label(MANTIS_ARTIFACT_LABEL.label, "art0.zip"));
JobDefinition jobDefinition = generateJobDefinition("systemLabelTest", labels, artifactName, "1.0");
JobDefinition updatedJobDefn = LabelManager.insertSystemLabels(jobDefinition, true);
assertEquals(3, updatedJobDefn.getLabels().size());
for (Label l : updatedJobDefn.getLabels()) {
if (l.getName().equals(MANTIS_ARTIFACT_LABEL.label)) {
assertEquals(artifactName, l.getValue());
} else if (l.getName().equals(MANTIS_IS_RESUBMIT_LABEL.label)) {
assertEquals("true", l.getValue());
} else {
assertEquals("1.0", l.getValue());
}
}
}
Aggregations