Search in sources :

Example 11 with VolumeConfigKeys

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);
}
Also used : V1VolumeBuilder(io.kubernetes.client.openapi.models.V1VolumeBuilder) VolumeConfigKeys(org.apache.heron.scheduler.kubernetes.KubernetesConstants.VolumeConfigKeys) V1Volume(io.kubernetes.client.openapi.models.V1Volume) Matchers.anyString(org.mockito.Matchers.anyString) V1VolumeMountBuilder(io.kubernetes.client.openapi.models.V1VolumeMountBuilder) HashMap(java.util.HashMap) V1ConfigMap(io.kubernetes.client.openapi.models.V1ConfigMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) LinkedList(java.util.LinkedList) V1VolumeMount(io.kubernetes.client.openapi.models.V1VolumeMount) Test(org.junit.Test)

Aggregations

VolumeConfigKeys (org.apache.heron.scheduler.kubernetes.KubernetesConstants.VolumeConfigKeys)11 ImmutableMap (com.google.common.collect.ImmutableMap)10 HashMap (java.util.HashMap)10 Map (java.util.Map)10 LinkedList (java.util.LinkedList)7 Pair (org.apache.heron.common.basics.Pair)7 V1ConfigMap (io.kubernetes.client.openapi.models.V1ConfigMap)6 Test (org.junit.Test)6 Matchers.anyString (org.mockito.Matchers.anyString)6 V1VolumeMount (io.kubernetes.client.openapi.models.V1VolumeMount)5 V1VolumeMountBuilder (io.kubernetes.client.openapi.models.V1VolumeMountBuilder)5 Config (org.apache.heron.spi.common.Config)5 V1Volume (io.kubernetes.client.openapi.models.V1Volume)4 V1VolumeBuilder (io.kubernetes.client.openapi.models.V1VolumeBuilder)4 TestTuple (org.apache.heron.scheduler.kubernetes.KubernetesUtils.TestTuple)2 Quantity (io.kubernetes.client.custom.Quantity)1 V1PersistentVolumeClaim (io.kubernetes.client.openapi.models.V1PersistentVolumeClaim)1 V1PersistentVolumeClaimBuilder (io.kubernetes.client.openapi.models.V1PersistentVolumeClaimBuilder)1 List (java.util.List)1