use of org.apache.heron.scheduler.kubernetes.KubernetesConstants.VolumeConfigKeys in project heron by twitter.
the class V1ControllerTest method testCreateVolumeAndMountsHostPathCLI.
@Test
public void testCreateVolumeAndMountsHostPathCLI() {
final String volumeName = "volume-name-host-path";
final String type = "DirectoryOrCreate";
final String pathOnHost = "path.on.host";
final String path = "/path/to/mount";
final String subPath = "/sub/path/to/mount";
// Host Path.
final Map<String, Map<VolumeConfigKeys, String>> config = ImmutableMap.of(volumeName, new HashMap<VolumeConfigKeys, String>() {
{
put(VolumeConfigKeys.type, type);
put(VolumeConfigKeys.pathOnHost, pathOnHost);
put(VolumeConfigKeys.path, path);
put(VolumeConfigKeys.subPath, subPath);
}
});
final List<V1Volume> expectedVolumes = Collections.singletonList(new V1VolumeBuilder().withName(volumeName).withNewHostPath().withNewType(type).withNewPath(pathOnHost).endHostPath().build());
final List<V1VolumeMount> expectedMounts = Collections.singletonList(new V1VolumeMountBuilder().withName(volumeName).withMountPath(path).withSubPath(subPath).build());
List<V1Volume> actualVolumes = new LinkedList<>();
List<V1VolumeMount> actualMounts = new LinkedList<>();
v1ControllerPodTemplate.createVolumeAndMountsHostPathCLI(config, actualVolumes, actualMounts);
Assert.assertEquals("Host Path Volume populated", expectedVolumes, actualVolumes);
Assert.assertEquals("Host Path Volume Mount populated", expectedMounts, actualMounts);
}
Aggregations