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();
}
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);
}
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);
}
Aggregations