use of com.netflix.titus.grpc.protogen.JobDescriptor.JobSpecCase.SERVICE 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));
}
Aggregations