Search in sources :

Example 1 with PlatformSidecar

use of com.netflix.titus.api.jobmanager.model.job.PlatformSidecar in project titus-control-plane by Netflix.

the class CassandraJobStoreTest method createServiceJobWithPlatformSidecarsObject.

/**
 * createServiceJobWithPlatformSidecarsObject is an extra strenuous test for the CassandraJobStore
 * suite, as it exercises all the things needed to ensure that the complex arguments field
 * is properly serialized correctly.
 */
private Job<ServiceJobExt> createServiceJobWithPlatformSidecarsObject() {
    Struct.Builder args = Struct.newBuilder();
    args.putFields("foo", Value.newBuilder().setStringValue("bar").build());
    args.putFields("baz", Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build());
    args.putFields("num", Value.newBuilder().setNumberValue(42.0).build());
    PlatformSidecar ps1 = PlatformSidecar.newBuilder().withName("testSidecar").withChannel("testChannel").withArguments("{\"foo\":true,\"bar\":3.0}").build();
    List<PlatformSidecar> platformSidecars = Collections.singletonList(ps1);
    JobDescriptor<ServiceJobExt> jobDescriptor = JobDescriptorGenerator.oneTaskServiceJobDescriptor().but(jd -> jd.toBuilder().withPlatformSidecars(platformSidecars).build());
    return JobGenerator.serviceJobs(jobDescriptor).getValue();
}
Also used : PlatformSidecar(com.netflix.titus.api.jobmanager.model.job.PlatformSidecar) ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) Struct(com.google.protobuf.Struct)

Example 2 with PlatformSidecar

use of com.netflix.titus.api.jobmanager.model.job.PlatformSidecar in project titus-control-plane by Netflix.

the class JobModelSanitizationTest method testJobWithInvalidPlatformSidecar.

@Test
public void testJobWithInvalidPlatformSidecar() {
    PlatformSidecar badPS = PlatformSidecar.newBuilder().withName("BAD_NAME").withChannel("BAD_CHANNEL").build();
    JobDescriptor<BatchJobExt> badJobDescriptor = oneTaskBatchJobDescriptor().but(jd -> jd.toBuilder().withPlatformSidecars(Collections.singletonList(badPS)).build());
    Set<ValidationError> violations = entitySanitizer.validate(badJobDescriptor);
    assertThat(violations).hasSize(2);
}
Also used : PlatformSidecar(com.netflix.titus.api.jobmanager.model.job.PlatformSidecar) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Test(org.junit.Test)

Example 3 with PlatformSidecar

use of com.netflix.titus.api.jobmanager.model.job.PlatformSidecar in project titus-control-plane by Netflix.

the class V1SpecPodFactoryTest method podHasSidecarAnnotations.

@Test
public void podHasSidecarAnnotations() {
    Job<BatchJobExt> job = JobGenerator.oneBatchJob();
    BatchJobTask task = JobGenerator.oneBatchTask();
    String json_args = "{\"foo\":true,\"bar\":3.0}";
    List<PlatformSidecar> platformSidecars = Arrays.asList(new PlatformSidecar("mysidecar", "stable", json_args));
    job = job.toBuilder().withJobDescriptor(job.getJobDescriptor().toBuilder().withPlatformSidecars(platformSidecars).build()).build();
    when(podAffinityFactory.buildV1Affinity(job, task)).thenReturn(Pair.of(new V1Affinity(), new HashMap<>()));
    V1Pod pod = podFactory.buildV1Pod(job, task);
    Map<String, String> annotations = pod.getMetadata().getAnnotations();
    String expectedSidecarAnnotation = "mysidecar" + KubeConstants.PLATFORM_SIDECAR_SUFFIX;
    assertThat(annotations.get(expectedSidecarAnnotation)).isEqualTo("true");
    String expectedChannelAnnotation = "mysidecar" + KubeConstants.PLATFORM_SIDECAR_CHANNEL_SUFFIX;
    assertThat(annotations.get(expectedChannelAnnotation)).isEqualTo("stable");
    String expectedArgsAnnotation = "mysidecar" + KubeConstants.PLATFORM_SIDECAR_ARGS_SUFFIX;
    assertThat(annotations.get(expectedArgsAnnotation)).isEqualTo(json_args);
}
Also used : PlatformSidecar(com.netflix.titus.api.jobmanager.model.job.PlatformSidecar) V1Affinity(io.kubernetes.client.openapi.models.V1Affinity) HashMap(java.util.HashMap) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) V1Pod(io.kubernetes.client.openapi.models.V1Pod) Test(org.junit.Test)

Aggregations

PlatformSidecar (com.netflix.titus.api.jobmanager.model.job.PlatformSidecar)3 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)2 Test (org.junit.Test)2 Struct (com.google.protobuf.Struct)1 BatchJobTask (com.netflix.titus.api.jobmanager.model.job.BatchJobTask)1 ServiceJobExt (com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt)1 ValidationError (com.netflix.titus.common.model.sanitizer.ValidationError)1 V1Affinity (io.kubernetes.client.openapi.models.V1Affinity)1 V1Pod (io.kubernetes.client.openapi.models.V1Pod)1 HashMap (java.util.HashMap)1