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