Search in sources :

Example 11 with JobDefinition

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);
}
Also used : JobClusterDefinitionImpl(io.mantisrx.server.master.domain.JobClusterDefinitionImpl) TestKit(akka.testkit.javadsl.TestKit) JobDefinition(io.mantisrx.server.master.domain.JobDefinition) JobClusterManagerProto(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto) Test(org.junit.Test)

Example 12 with JobDefinition

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()));
}
Also used : JobManager(io.mantisrx.master.jobcluster.JobClusterActor.JobManager) JobInfo(io.mantisrx.master.jobcluster.JobClusterActor.JobInfo) JobManager(io.mantisrx.master.jobcluster.JobClusterActor.JobManager) JobId(io.mantisrx.server.master.domain.JobId) JobDefinition(io.mantisrx.server.master.domain.JobDefinition) Test(org.junit.Test)

Example 13 with JobDefinition

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());
}
Also used : Label(io.mantisrx.common.Label) ArrayList(java.util.ArrayList) JobDefinition(io.mantisrx.server.master.domain.JobDefinition) Test(org.junit.Test)

Example 14 with JobDefinition

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());
}
Also used : List(java.util.List) Lists(io.mantisrx.shaded.com.google.common.collect.Lists) Label(io.mantisrx.common.Label) JobDefinition(io.mantisrx.server.master.domain.JobDefinition) InvalidJobException(io.mantisrx.runtime.command.InvalidJobException) MantisJobDurationType(io.mantisrx.runtime.MantisJobDurationType) JobSla(io.mantisrx.runtime.JobSla) Test(org.junit.Test) Collectors(java.util.stream.Collectors) SystemLabels(io.mantisrx.master.jobcluster.LabelManager.SystemLabels) Assert.assertEquals(org.junit.Assert.assertEquals) ArrayList(java.util.ArrayList) Label(io.mantisrx.common.Label) JobDefinition(io.mantisrx.server.master.domain.JobDefinition) Test(org.junit.Test)

Example 15 with JobDefinition

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());
        }
    }
}
Also used : Label(io.mantisrx.common.Label) ArrayList(java.util.ArrayList) JobDefinition(io.mantisrx.server.master.domain.JobDefinition) Test(org.junit.Test)

Aggregations

JobDefinition (io.mantisrx.server.master.domain.JobDefinition)42 Test (org.junit.Test)31 InvalidJobException (io.mantisrx.runtime.command.InvalidJobException)25 JobClusterManagerProto (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto)18 TestKit (akka.testkit.javadsl.TestKit)17 JobId (io.mantisrx.server.master.domain.JobId)17 Label (io.mantisrx.common.Label)15 ActorRef (akka.actor.ActorRef)14 IJobClusterDefinition (io.mantisrx.server.master.domain.IJobClusterDefinition)14 SchedulingInfo (io.mantisrx.runtime.descriptor.SchedulingInfo)13 ArrayList (java.util.ArrayList)13 MantisJobStore (io.mantisrx.server.master.persistence.MantisJobStore)12 JobProto (io.mantisrx.master.jobcluster.proto.JobProto)11 MantisScheduler (io.mantisrx.server.master.scheduler.MantisScheduler)11 IOException (java.io.IOException)11 WorkerId (io.mantisrx.server.core.domain.WorkerId)10 GetJobDetailsResponse (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobDetailsResponse)9 JobClusterDefinitionImpl (io.mantisrx.server.master.domain.JobClusterDefinitionImpl)9 StageSchedulingInfo (io.mantisrx.runtime.descriptor.StageSchedulingInfo)8 MachineDefinition (io.mantisrx.runtime.MachineDefinition)7