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