Search in sources :

Example 71 with BatchJobExt

use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt 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)

Example 72 with BatchJobExt

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

the class V1SpecPodFactoryTest method testCapacityGroupAssignment.

@Test
public void testCapacityGroupAssignment() {
    Job<BatchJobExt> job = JobGenerator.oneBatchJob();
    BatchJobTask task = JobGenerator.oneBatchTask();
    job = job.toBuilder().withJobDescriptor(job.getJobDescriptor().toBuilder().withCapacityGroup("myGroup").build()).build();
    when(capacityGroupManagement.getApplicationSLA("myGroup")).thenReturn(ApplicationSLA.newBuilder().withAppName("myGroup").build());
    when(podAffinityFactory.buildV1Affinity(job, task)).thenReturn(Pair.of(new V1Affinity(), new HashMap<>()));
    V1Pod pod = podFactory.buildV1Pod(job, task);
    assertThat(pod.getMetadata().getLabels()).containsEntry(KubeConstants.LABEL_CAPACITY_GROUP, "mygroup");
}
Also used : 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)

Example 73 with BatchJobExt

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

the class V1SpecPodFactoryTest method testNetworkConfigurationIsNotNullAndSetToUnknownByDefault.

@Test
public void testNetworkConfigurationIsNotNullAndSetToUnknownByDefault() {
    Job<BatchJobExt> job = JobGenerator.oneBatchJob();
    BatchJobTask task = JobGenerator.oneBatchTask();
    job = job.toBuilder().withJobDescriptor(job.getJobDescriptor().toBuilder().build()).build();
    when(podAffinityFactory.buildV1Affinity(job, task)).thenReturn(Pair.of(new V1Affinity(), new HashMap<>()));
    V1Pod pod = podFactory.buildV1Pod(job, task);
    String networkModeAnnotationValue = pod.getMetadata().getAnnotations().get("network.netflix.com/network-mode");
    assertThat(networkModeAnnotationValue).isEqualTo("UnknownNetworkMode");
}
Also used : 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

BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)73 Test (org.junit.Test)55 Task (com.netflix.titus.api.jobmanager.model.job.Task)30 BatchJobTask (com.netflix.titus.api.jobmanager.model.job.BatchJobTask)25 List (java.util.List)20 ArrayList (java.util.ArrayList)19 JobStore (com.netflix.titus.api.jobmanager.store.JobStore)17 HashMap (java.util.HashMap)16 V1Affinity (io.kubernetes.client.openapi.models.V1Affinity)14 IntegrationNotParallelizableTest (com.netflix.titus.testkit.junit.category.IntegrationNotParallelizableTest)13 ServiceJobTask (com.netflix.titus.api.jobmanager.model.job.ServiceJobTask)11 V1Pod (io.kubernetes.client.openapi.models.V1Pod)11 Job (com.netflix.titus.api.jobmanager.model.job.Job)10 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)10 Container (com.netflix.titus.api.jobmanager.model.job.Container)6 Map (java.util.Map)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6 V1Container (io.kubernetes.client.openapi.models.V1Container)5 BasicContainer (com.netflix.titus.api.jobmanager.model.job.BasicContainer)4 Image (com.netflix.titus.api.jobmanager.model.job.Image)4