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());
}
}
}
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());
}
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());
}
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;
}
}
Aggregations