Search in sources :

Example 16 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 17 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)

Example 18 with JobDefinition

use of io.mantisrx.server.master.domain.JobDefinition in project mantis by Netflix.

the class LabelManagerTest method doNotinsertResubmitLabelIfAlreadyExistsTest.

@Test
public void doNotinsertResubmitLabelIfAlreadyExistsTest() throws InvalidJobException {
    List<Label> labels = new ArrayList<>();
    labels.add(new Label(MANTIS_IS_RESUBMIT_LABEL.label, "true"));
    JobDefinition jobDefinition = generateJobDefinition("DoNotinsertResubmitLabelIfAlreadyExistsTest", labels, "art.zip", "1.0");
    JobDefinition updatedJobDefn = LabelManager.insertAutoResubmitLabel(jobDefinition);
    assertEquals(1, updatedJobDefn.getLabels().size());
    Label label = updatedJobDefn.getLabels().get(0);
    assertEquals(MANTIS_IS_RESUBMIT_LABEL.label, label.getName());
}
Also used : Label(io.mantisrx.common.Label) ArrayList(java.util.ArrayList) JobDefinition(io.mantisrx.server.master.domain.JobDefinition) Test(org.junit.Test)

Example 19 with JobDefinition

use of io.mantisrx.server.master.domain.JobDefinition in project mantis by Netflix.

the class LabelManagerTest method replaceArtifactLabelTest.

@Test
public void replaceArtifactLabelTest() throws InvalidJobException {
    String artifactName = "art1.zip";
    List<Label> labels = new ArrayList<>();
    labels.add(new Label(MANTIS_ARTIFACT_LABEL.label, "art0.zip"));
    JobDefinition jobDefinition = generateJobDefinition("replaceArtifactLabelTest", labels, artifactName, "1.0");
    JobDefinition updatedJobDefn = LabelManager.insertSystemLabels(jobDefinition, false);
    assertEquals(2, updatedJobDefn.getLabels().size());
    labels = updatedJobDefn.getLabels().stream().filter(label -> label.getName().equals(MANTIS_ARTIFACT_LABEL.label)).collect(Collectors.toList());
    Label label = labels.get(0);
    assertEquals(MANTIS_ARTIFACT_LABEL.label, label.getName());
    assertEquals(artifactName, 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 20 with JobDefinition

use of io.mantisrx.server.master.domain.JobDefinition in project mantis by Netflix.

the class TestHelpers method createFakeScheduleRequest.

public static ScheduleRequest createFakeScheduleRequest(final WorkerId workerId, final int stageNum, final int numStages, final MachineDefinition machineDefinition) {
    try {
        JobDefinition jobDefinition = new JobDefinition.Builder().withArtifactName("jar").withSchedulingInfo(new SchedulingInfo(Collections.singletonMap(0, StageSchedulingInfo.builder().numberOfInstances(1).machineDefinition(machineDefinition).hardConstraints(Collections.emptyList()).softConstraints(Collections.emptyList()).build()))).withJobSla(new JobSla(0, 0, null, MantisJobDurationType.Perpetual, null)).build();
        IMantisJobMetadata mantisJobMetadata = new MantisJobMetadataImpl.Builder().withJobId(JobId.fromId(workerId.getJobId()).get()).withJobDefinition(jobDefinition).build();
        return new ScheduleRequest(workerId, stageNum, numStages, new JobMetadata(mantisJobMetadata.getJobId().getId(), mantisJobMetadata.getJobJarUrl(), mantisJobMetadata.getTotalStages(), mantisJobMetadata.getUser(), mantisJobMetadata.getSchedulingInfo(), mantisJobMetadata.getParameters(), mantisJobMetadata.getSubscriptionTimeoutSecs(), mantisJobMetadata.getMinRuntimeSecs()), mantisJobMetadata.getSla().get().getDurationType(), machineDefinition, Collections.emptyList(), Collections.emptyList(), 0, Optional.empty());
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : JobMetadata(io.mantisrx.server.core.domain.JobMetadata) IMantisJobMetadata(io.mantisrx.master.jobcluster.job.IMantisJobMetadata) StageSchedulingInfo(io.mantisrx.runtime.descriptor.StageSchedulingInfo) SchedulingInfo(io.mantisrx.runtime.descriptor.SchedulingInfo) ScheduleRequest(io.mantisrx.server.master.scheduler.ScheduleRequest) IMantisJobMetadata(io.mantisrx.master.jobcluster.job.IMantisJobMetadata) JobSla(io.mantisrx.runtime.JobSla) MantisJobMetadataImpl(io.mantisrx.master.jobcluster.job.MantisJobMetadataImpl) JobDefinition(io.mantisrx.server.master.domain.JobDefinition)

Aggregations

JobDefinition (io.mantisrx.server.master.domain.JobDefinition)43 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