Search in sources :

Example 1 with Volume

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

the class JobModelSanitizationTest method testJobWithInvalidVolume.

@Test
public void testJobWithInvalidVolume() {
    VolumeSource vs = new SaaSVolumeSource("BAD_SAAS_NAME");
    Volume badVolume = Volume.newBuilder().withName("BAD_NAME").withVolumeSource(vs).build();
    JobDescriptor<BatchJobExt> badJobDescriptor = oneTaskBatchJobDescriptor().but(jd -> jd.toBuilder().withVolumes(Collections.singletonList(badVolume)).build());
    Set<ValidationError> violations = entitySanitizer.validate(badJobDescriptor);
    assertThat(violations).hasSize(2);
}
Also used : SaaSVolumeSource(com.netflix.titus.api.jobmanager.model.job.volume.SaaSVolumeSource) VolumeSource(com.netflix.titus.api.jobmanager.model.job.volume.VolumeSource) SaaSVolumeSource(com.netflix.titus.api.jobmanager.model.job.volume.SaaSVolumeSource) Volume(com.netflix.titus.api.jobmanager.model.job.volume.Volume) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Test(org.junit.Test)

Example 2 with Volume

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

the class V1SpecPodFactoryTest method podGetsSharedFlexVolumes.

@Test
public void podGetsSharedFlexVolumes() {
    Job<BatchJobExt> job = JobGenerator.oneBatchJob();
    BatchJobTask task = JobGenerator.oneBatchTask();
    List<Volume> volumes = Arrays.asList(new Volume("volume1", new SharedContainerVolumeSource("main", "/main-root")), new Volume("volume2", new SharedContainerVolumeSource("main", "/main-root")));
    job = job.toBuilder().withJobDescriptor(job.getJobDescriptor().toBuilder().withVolumes(volumes).build()).build();
    when(podAffinityFactory.buildV1Affinity(job, task)).thenReturn(Pair.of(new V1Affinity(), new HashMap<>()));
    V1Pod pod = podFactory.buildV1Pod(job, task);
    List<V1Volume> podVolumes = Objects.requireNonNull(pod.getSpec()).getVolumes();
    // dev-shm is third volume
    assertThat(podVolumes.size()).isEqualTo(3);
    V1Volume mainSharedVolume = podVolumes.get(0);
    assertThat(mainSharedVolume.getName()).isEqualTo("volume1");
    V1FlexVolumeSource flexVolume = mainSharedVolume.getFlexVolume();
    assertThat(flexVolume.getDriver()).isEqualTo("SharedContainerVolumeSource");
    Map<String, String> flexVolumeOptions = flexVolume.getOptions();
    assertThat(flexVolumeOptions.get("sourceContainer")).isEqualTo("main");
    assertThat(flexVolumeOptions.get("sourcePath")).isEqualTo("/main-root");
}
Also used : V1FlexVolumeSource(io.kubernetes.client.openapi.models.V1FlexVolumeSource) HashMap(java.util.HashMap) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) SharedContainerVolumeSource(com.netflix.titus.api.jobmanager.model.job.volume.SharedContainerVolumeSource) V1Volume(io.kubernetes.client.openapi.models.V1Volume) EbsVolume(com.netflix.titus.api.jobmanager.model.job.ebs.EbsVolume) V1Volume(io.kubernetes.client.openapi.models.V1Volume) Volume(com.netflix.titus.api.jobmanager.model.job.volume.Volume) V1Affinity(io.kubernetes.client.openapi.models.V1Affinity) BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) V1Pod(io.kubernetes.client.openapi.models.V1Pod) Test(org.junit.Test)

Aggregations

BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)2 Volume (com.netflix.titus.api.jobmanager.model.job.volume.Volume)2 Test (org.junit.Test)2 BatchJobTask (com.netflix.titus.api.jobmanager.model.job.BatchJobTask)1 EbsVolume (com.netflix.titus.api.jobmanager.model.job.ebs.EbsVolume)1 SaaSVolumeSource (com.netflix.titus.api.jobmanager.model.job.volume.SaaSVolumeSource)1 SharedContainerVolumeSource (com.netflix.titus.api.jobmanager.model.job.volume.SharedContainerVolumeSource)1 VolumeSource (com.netflix.titus.api.jobmanager.model.job.volume.VolumeSource)1 ValidationError (com.netflix.titus.common.model.sanitizer.ValidationError)1 V1Affinity (io.kubernetes.client.openapi.models.V1Affinity)1 V1FlexVolumeSource (io.kubernetes.client.openapi.models.V1FlexVolumeSource)1 V1Pod (io.kubernetes.client.openapi.models.V1Pod)1 V1Volume (io.kubernetes.client.openapi.models.V1Volume)1 HashMap (java.util.HashMap)1