use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class JobSanitizeTest method testSuppressedInternalError.
/**
* Verifies that non-NOT_FOUND errors are suppressed and the original job descriptor is not modified.
*/
@Test(timeout = TEST_TIMEOUT_MS)
public void testSuppressedInternalError() {
when(registryClient.getImageDigest(anyString(), anyString())).thenReturn(Mono.error(TitusRegistryException.internalError(repo, tag, HttpStatus.INTERNAL_SERVER_ERROR)));
final com.netflix.titus.grpc.protogen.JobDescriptor jobDescriptor = toGrpcJobDescriptor(batchJobDescriptors().map(jd -> jd.but(d -> d.getContainer().toBuilder().withImage(Image.newBuilder().withName(repo).withTag(tag).build()))).getValue());
String jobId = client.createJob(jobDescriptor).getId();
Job resultJobDescriptor = client.findJob(JobId.newBuilder().setId(jobId).build());
logger.info("Got back result {}", resultJobDescriptor);
assertTrue(resultJobDescriptor.getJobDescriptor().getContainer().getImage().getDigest().isEmpty());
}
use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class JobSanitizeTest method testJobDigestResolution.
/**
* Verifies that a digest value is properly added to a job descriptor that is using tag.
*/
@Test(timeout = TEST_TIMEOUT_MS)
public void testJobDigestResolution() {
when(registryClient.getImageDigest(anyString(), anyString())).thenReturn(Mono.just(digest));
com.netflix.titus.grpc.protogen.JobDescriptor jobDescriptor = toGrpcJobDescriptor(batchJobDescriptors().map(jd -> jd.but(d -> d.getContainer().toBuilder().withImage(Image.newBuilder().withName(repo).withTag(tag).build()))).getValue());
String jobId = client.createJob(jobDescriptor).getId();
Job resultJobDescriptor = client.findJob(JobId.newBuilder().setId(jobId).build());
assertEquals(digest, resultJobDescriptor.getJobDescriptor().getContainer().getImage().getDigest());
}
use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class JobSubmitAndControlBasicTest method testSubmitBatchJobWithEfsMount.
/**
* Verify batch job submit with the expected state transitions. Verify agent receives proper EFS mount data.
*/
@Test(timeout = 30_000)
public void testSubmitBatchJobWithEfsMount() {
EfsMount efsMount1 = ContainersGenerator.efsMounts().getValue().toBuilder().withMountPoint("/data/logs").build();
EfsMount efsMount2 = ContainersGenerator.efsMounts().skip(1).getValue().toBuilder().withMountPoint("/data").build();
List<EfsMount> efsMounts = asList(efsMount1, efsMount2);
List<EfsMount> expectedOrder = asList(efsMount2, efsMount1);
JobDescriptor<BatchJobExt> jobWithEfs = ONE_TASK_BATCH_JOB.but(jd -> jd.getContainer().but(c -> c.getContainerResources().toBuilder().withEfsMounts(efsMounts)));
jobsScenarioBuilder.schedule(jobWithEfs, jobScenarioBuilder -> jobScenarioBuilder.template(ScenarioTemplates.startTasksInNewJob()).assertEachPod(podWithEfsMounts(expectedOrder), "Container not assigned the expected EFS mount").allTasks(ScenarioTemplates.completeTask()).template(ScenarioTemplates.jobFinished()).expectJobEventStreamCompletes());
}
use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class JobsScenarioBuilder method schedule.
public JobsScenarioBuilder schedule(JobDescriptor<?> jobDescriptor, int times, Function<JobScenarioBuilder, JobScenarioBuilder> jobScenario) throws Exception {
String sequence = jobDescriptor.getJobGroupInfo().getSequence();
for (int i = 0; i < times; i++) {
int finalI = i;
JobDescriptor effective = sequence.isEmpty() ? jobDescriptor : jobDescriptor.but(jd -> jd.getJobGroupInfo().toBuilder().withSequence(sequence + '_' + finalI));
schedule(effective, jobScenario);
}
return this;
}
use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class MoveTaskTest method testMoveWithStoreUpdateFailure.
@Test
public void testMoveWithStoreUpdateFailure() {
JobDescriptor<ServiceJobExt> jobDescriptor = oneTaskServiceJobDescriptor();
String targetJobId = startNewJob(jobDescriptor).getJobId();
JobScenarioBuilder sourceJobBuilder = startNewJob(jobDescriptor);
String sourceJobId = sourceJobBuilder.getJobId();
try {
sourceJobBuilder.advance().breakStore().allTasks(tasks -> assertThat(tasks).hasSize(1)).moveTask(0, 0, sourceJobId, targetJobId);
} catch (Exception e) {
assertThat(ExceptionExt.toMessageChain(e)).contains("Store is broken");
}
jobsScenarioBuilder.getJobScenario(0).allTasks(tasks -> assertThat(tasks).hasSize(1));
jobsScenarioBuilder.getJobScenario(1).allTasks(tasks -> assertThat(tasks).hasSize(1));
}
Aggregations