use of com.netflix.titus.grpc.protogen.Job in project titus-control-plane by Netflix.
the class JobDirectQueryTest method testFindBatchJob.
private void testFindBatchJob(String jobId) {
Job job = client.findJob(JobId.newBuilder().setId(jobId).build());
assertThat(job.getId()).isEqualTo(jobId);
CellAssertions.assertCellInfo(job, EmbeddedTitusMaster.CELL_NAME);
}
use of com.netflix.titus.grpc.protogen.Job in project titus-control-plane by Netflix.
the class JobObserveTest method observeJobs.
@Test(timeout = LONG_TEST_TIMEOUT_MS)
public void observeJobs() throws InterruptedException {
TestStreamObserver<JobChangeNotification> subscriber = subscribe(ObserveJobsQuery.getDefaultInstance());
for (int i = 0; i < 2; i++) {
String jobId = jobsScenarioBuilder.scheduleAndReturnJob(oneTaskBatchJobDescriptor(), jobScenarioBuilder -> jobScenarioBuilder.template(startTasksInNewJob()).template(ScenarioTemplates.killJob())).getId();
JobChangeNotification event;
while (true) {
event = subscriber.takeNext(SHORT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
if (event.hasJobUpdate()) {
Job job = event.getJobUpdate().getJob();
assertThat(job.getId()).isEqualTo(jobId);
CellAssertions.assertCellInfo(job, EmbeddedTitusMaster.CELL_NAME);
if (job.getStatus().getState() == JobState.Finished) {
break;
}
}
}
}
subscriber.cancel();
}
use of com.netflix.titus.grpc.protogen.Job in project titus-control-plane by Netflix.
the class JobObserveTest method observeByJobDescriptor.
@Test(timeout = LONG_TEST_TIMEOUT_MS)
public void observeByJobDescriptor() throws InterruptedException {
startAll(batchJobDescriptors().getValue().toBuilder().withApplicationName("myApp").build(), batchJobDescriptors().getValue().toBuilder().withApplicationName("otherApp").withOwner(Owner.newBuilder().withTeamEmail("me@netflix.com").build()).build(), batchJobDescriptors().getValue().but(j -> j.getContainer().toBuilder().withImage(JobModel.newImage().withName("some/image").withTag("stable").build())), batchJobDescriptors().getValue().toBuilder().withAttributes(ImmutableMap.<String, String>builder().put("attr1", "value1").put("attr2", "value2").build()).build());
startAll(serviceJobDescriptors().getValue());
observeByJobDescriptor(jobsScenarioBuilder.takeJobId(0), ObserveJobsQuery.newBuilder().putFilteringCriteria("applicationName", "myApp").build(), job -> assertThat(job.getJobDescriptor().getApplicationName()).isEqualTo("myApp"));
observeByJobDescriptor(jobsScenarioBuilder.takeJobId(1), ObserveJobsQuery.newBuilder().putFilteringCriteria("owner", "me@netflix.com").build(), job -> assertThat(job.getJobDescriptor().getOwner().getTeamEmail()).isEqualTo("me@netflix.com"));
observeByJobDescriptor(jobsScenarioBuilder.takeJobId(2), ObserveJobsQuery.newBuilder().putFilteringCriteria("imageName", "some/image").putFilteringCriteria("imageTag", "stable").build(), job -> {
Image image = job.getJobDescriptor().getContainer().getImage();
assertThat(image.getName()).isEqualTo("some/image");
assertThat(image.getTag()).isEqualTo("stable");
});
observeByJobDescriptor(jobsScenarioBuilder.takeJobId(3), ObserveJobsQuery.newBuilder().putFilteringCriteria("attributes", "attr1,attr2:value2").putFilteringCriteria("attributes.op", "and").build(), job -> assertThat(job.getJobDescriptor().getAttributesMap()).containsKey("attr1").containsEntry("attr2", "value2"));
observeByJobDescriptor(jobsScenarioBuilder.takeJobId(4), ObserveJobsQuery.newBuilder().putFilteringCriteria("jobType", "service").build(), job -> assertThat(job.getJobDescriptor().getJobSpecCase()).isEqualTo(SERVICE));
}
use of com.netflix.titus.grpc.protogen.Job 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.grpc.protogen.Job 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());
}
Aggregations