Search in sources :

Example 1 with BasicContainer

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

the class V1SpecPodFactoryTest method multipleContainers.

@Test
public void multipleContainers() {
    Job<BatchJobExt> job = JobGenerator.oneBatchJob();
    BatchJobTask task = JobGenerator.oneBatchTask();
    Image testImage = Image.newBuilder().withName("testImage").withDigest("123").build();
    List<BasicContainer> extraContainers = Arrays.asList(new BasicContainer("extraContainer1", testImage, Collections.emptyList(), Collections.emptyList(), new HashMap<>(), Collections.emptyList()), new BasicContainer("extraContainer2", testImage, Collections.emptyList(), Collections.emptyList(), new HashMap<>(), Collections.emptyList()));
    job = job.toBuilder().withJobDescriptor(job.getJobDescriptor().toBuilder().withExtraContainers(extraContainers).build()).build();
    when(podAffinityFactory.buildV1Affinity(job, task)).thenReturn(Pair.of(new V1Affinity(), new HashMap<>()));
    V1Pod pod = podFactory.buildV1Pod(job, task);
    List<V1Container> containers = Objects.requireNonNull(pod.getSpec()).getContainers();
    // 3 containers here, 1 from the main container, 2 from the extras
    assertThat(containers.size()).isEqualTo(1 + extraContainers.size());
}
Also used : V1Container(io.kubernetes.client.openapi.models.V1Container) HashMap(java.util.HashMap) V1Affinity(io.kubernetes.client.openapi.models.V1Affinity) 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) BasicContainer(com.netflix.titus.api.jobmanager.model.job.BasicContainer) Image(com.netflix.titus.api.jobmanager.model.job.Image) 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 Image (com.netflix.titus.api.jobmanager.model.job.Image)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 HashMap (java.util.HashMap)1 Test (org.junit.Test)1