Search in sources :

Example 1 with Image

use of com.netflix.titus.grpc.protogen.Image in project titus-control-plane by Netflix.

the class JobSubmitAndControlNegativeTest method testJobWithInvalidNameAndTag.

@Test(timeout = TEST_TIMEOUT_MS)
public void testJobWithInvalidNameAndTag() {
    Image badImage = Image.newBuilder().setName("????????").setTag("############").build();
    submitBadJob(client, BATCH_JOB_DESCR_BUILDER.setContainer(BATCH_JOB_DESCR_BUILDER.getContainer().toBuilder().setImage(badImage)).build(), "container.image.name", "container.image.noValidImageDigestOrTag");
}
Also used : Image(com.netflix.titus.grpc.protogen.Image) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Example 2 with Image

use of com.netflix.titus.grpc.protogen.Image in project titus-control-plane by Netflix.

the class ProtobufMessageObjectMapperTest method testMessageSerialization.

@Test
public void testMessageSerialization() throws Exception {
    Image image = getImage();
    ObjectMapper objectMapper = getObjectMapper();
    String jsonString = objectMapper.writeValueAsString(image);
    String expectedJsonString = JsonFormat.printer().includingDefaultValueFields().print(image);
    Assertions.assertThat(jsonString).isEqualTo(expectedJsonString);
}
Also used : Image(com.netflix.titus.grpc.protogen.Image) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 3 with Image

use of com.netflix.titus.grpc.protogen.Image in project titus-control-plane by Netflix.

the class ProtobufMessageObjectMapperTest method testMessageDeserialization.

@Test
public void testMessageDeserialization() throws Exception {
    Image expectedImage = getImage();
    String jsonString = JsonFormat.printer().includingDefaultValueFields().print(expectedImage);
    ObjectMapper objectMapper = getObjectMapper();
    Image image = objectMapper.readValue(jsonString, Image.class);
    Assertions.assertThat(image).isEqualTo(expectedImage);
}
Also used : Image(com.netflix.titus.grpc.protogen.Image) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 4 with Image

use of com.netflix.titus.grpc.protogen.Image 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));
}
Also used : Arrays(java.util.Arrays) JobDescriptorGenerator.serviceJobDescriptors(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.serviceJobDescriptors) JobModel(com.netflix.titus.api.jobmanager.model.job.JobModel) ObserveJobsQuery(com.netflix.titus.grpc.protogen.ObserveJobsQuery) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Job(com.netflix.titus.grpc.protogen.Job) ScenarioTemplates(com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates) ScenarioTemplates.startTasksInNewJob(com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates.startTasksInNewJob) Image(com.netflix.titus.grpc.protogen.Image) ScenarioTemplates.killJob(com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates.killJob) JobState(com.netflix.titus.grpc.protogen.JobStatus.JobState) TestStreamObserver(com.netflix.titus.testkit.grpc.TestStreamObserver) Owner(com.netflix.titus.api.jobmanager.model.job.Owner) SERVICE(com.netflix.titus.grpc.protogen.JobDescriptor.JobSpecCase.SERVICE) Assert.fail(org.junit.Assert.fail) Before(org.junit.Before) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) TaskState(com.netflix.titus.grpc.protogen.TaskStatus.TaskState) EmbeddedTitusCells(com.netflix.titus.testkit.embedded.cell.EmbeddedTitusCells) ImmutableMap(com.google.common.collect.ImmutableMap) Task(com.netflix.titus.grpc.protogen.Task) JobDescriptorGenerator.oneTaskBatchJobDescriptor(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.oneTaskBatchJobDescriptor) CellAssertions(com.netflix.titus.master.integration.v3.job.CellAssertions) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) RuleChain(org.junit.rules.RuleChain) TitusStackResource(com.netflix.titus.testkit.junit.master.TitusStackResource) Rule(org.junit.Rule) JobDescriptorGenerator.batchJobDescriptors(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.batchJobDescriptors) EmbeddedTitusMaster(com.netflix.titus.testkit.embedded.cell.master.EmbeddedTitusMaster) JobsScenarioBuilder(com.netflix.titus.master.integration.v3.scenario.JobsScenarioBuilder) JobManagementServiceStub(com.netflix.titus.grpc.protogen.JobManagementServiceGrpc.JobManagementServiceStub) JobChangeNotification(com.netflix.titus.grpc.protogen.JobChangeNotification) Image(com.netflix.titus.grpc.protogen.Image) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Aggregations

Image (com.netflix.titus.grpc.protogen.Image)4 Test (org.junit.Test)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 BaseIntegrationTest (com.netflix.titus.master.integration.BaseIntegrationTest)2 IntegrationTest (com.netflix.titus.testkit.junit.category.IntegrationTest)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)1 JobModel (com.netflix.titus.api.jobmanager.model.job.JobModel)1 Owner (com.netflix.titus.api.jobmanager.model.job.Owner)1 Job (com.netflix.titus.grpc.protogen.Job)1 JobChangeNotification (com.netflix.titus.grpc.protogen.JobChangeNotification)1 SERVICE (com.netflix.titus.grpc.protogen.JobDescriptor.JobSpecCase.SERVICE)1 JobManagementServiceStub (com.netflix.titus.grpc.protogen.JobManagementServiceGrpc.JobManagementServiceStub)1 JobState (com.netflix.titus.grpc.protogen.JobStatus.JobState)1 ObserveJobsQuery (com.netflix.titus.grpc.protogen.ObserveJobsQuery)1 Task (com.netflix.titus.grpc.protogen.Task)1 TaskState (com.netflix.titus.grpc.protogen.TaskStatus.TaskState)1 CellAssertions (com.netflix.titus.master.integration.v3.job.CellAssertions)1 JobsScenarioBuilder (com.netflix.titus.master.integration.v3.scenario.JobsScenarioBuilder)1 ScenarioTemplates (com.netflix.titus.master.integration.v3.scenario.ScenarioTemplates)1