Search in sources :

Example 1 with VolumeMount

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

the class V1SpecPodFactoryTest method podMainContainerHasVolumeMounts.

@Test
public void podMainContainerHasVolumeMounts() {
    Job<BatchJobExt> job = JobGenerator.oneBatchJob();
    BatchJobTask task = JobGenerator.oneBatchTask();
    List<VolumeMount> volumeMounts = Arrays.asList(new VolumeMount("volume1", "", NONE_MOUNT_PROPAGATION, false, ""), new VolumeMount("volume2", "", NONE_MOUNT_PROPAGATION, false, ""));
    Container container = job.getJobDescriptor().getContainer().toBuilder().withVolumeMounts(volumeMounts).build();
    job = job.toBuilder().withJobDescriptor(job.getJobDescriptor().toBuilder().withContainer(container).build()).build();
    when(podAffinityFactory.buildV1Affinity(job, task)).thenReturn(Pair.of(new V1Affinity(), new HashMap<>()));
    V1Pod pod = podFactory.buildV1Pod(job, task);
    V1Container mainContainer = pod.getSpec().getContainers().get(0);
    List<V1VolumeMount> mounts = mainContainer.getVolumeMounts();
    // dev-shm is third volume
    assertThat(mounts.size()).isEqualTo(3);
    assertThat(mounts.get(0).getName()).isEqualTo("volume1");
    assertThat(mounts.get(1).getName()).isEqualTo("volume2");
}
Also used : V1Container(io.kubernetes.client.openapi.models.V1Container) V1Container(io.kubernetes.client.openapi.models.V1Container) BasicContainer(com.netflix.titus.api.jobmanager.model.job.BasicContainer) Container(com.netflix.titus.api.jobmanager.model.job.Container) 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) V1VolumeMount(io.kubernetes.client.openapi.models.V1VolumeMount) VolumeMount(com.netflix.titus.api.jobmanager.model.job.VolumeMount) V1Pod(io.kubernetes.client.openapi.models.V1Pod) V1VolumeMount(io.kubernetes.client.openapi.models.V1VolumeMount) Test(org.junit.Test)

Aggregations

BasicContainer (com.netflix.titus.api.jobmanager.model.job.BasicContainer)1 BatchJobTask (com.netflix.titus.api.jobmanager.model.job.BatchJobTask)1 Container (com.netflix.titus.api.jobmanager.model.job.Container)1 VolumeMount (com.netflix.titus.api.jobmanager.model.job.VolumeMount)1 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)1 V1Affinity (io.kubernetes.client.openapi.models.V1Affinity)1 V1Container (io.kubernetes.client.openapi.models.V1Container)1 V1Pod (io.kubernetes.client.openapi.models.V1Pod)1 V1VolumeMount (io.kubernetes.client.openapi.models.V1VolumeMount)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1