use of org.apache.heron.spi.common.Config in project heron by twitter.
the class VolumesTests method testHostPathVolume.
@Test
public void testHostPathVolume() {
final String path = "/test/dir1";
final Config config = Config.newBuilder().put(KubernetesContext.KUBERNETES_VOLUME_TYPE, "hostPath").put(KubernetesContext.KUBERNETES_VOLUME_HOSTPATH_PATH, path).build();
final V1Volume volume = Volumes.get().create(config);
Assert.assertNotNull(volume);
Assert.assertNotNull(volume.getHostPath());
Assert.assertEquals(volume.getHostPath().getPath(), path);
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class VolumesTests method testNoVolume.
@Test
public void testNoVolume() {
final Config config = Config.newBuilder().build();
final V1Volume volume = Volumes.get().create(config);
Assert.assertNull(volume);
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class MarathonLauncher method launch.
@Override
public boolean launch(PackingPlan packing) {
LauncherUtils launcherUtils = LauncherUtils.getInstance();
Config ytruntime = launcherUtils.createConfigWithPackingDetails(runtime, packing);
return launcherUtils.onScheduleAsLibrary(config, ytruntime, getScheduler(), packing);
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class V1ControllerTest method testAddVolumesIfPresent.
@Test
public void testAddVolumesIfPresent() {
final String pathDefault = "config-host-volume-path";
final String pathNameDefault = "config-host-volume-name";
final Config configWithVolumes = Config.newBuilder().put(KubernetesContext.KUBERNETES_VOLUME_NAME, pathNameDefault).put(KubernetesContext.KUBERNETES_VOLUME_TYPE, Volumes.HOST_PATH).put(KubernetesContext.KUBERNETES_VOLUME_HOSTPATH_PATH, pathDefault).build();
final V1Controller controllerWithVol = new V1Controller(configWithVolumes, RUNTIME);
final V1Volume volumeDefault = new V1VolumeBuilder().withName(pathNameDefault).withNewHostPath().withNewPath(pathDefault).endHostPath().build();
final V1Volume volumeToBeKept = new V1VolumeBuilder().withName("volume-to-be-kept-name").withNewHostPath().withNewPath("volume-to-be-kept-path").endHostPath().build();
final List<V1Volume> customVolumeList = Arrays.asList(new V1VolumeBuilder().withName(pathNameDefault).withNewHostPath().withNewPath("this-path-must-be-replaced").endHostPath().build(), volumeToBeKept);
final List<V1Volume> expectedDefault = Collections.singletonList(volumeDefault);
final List<V1Volume> expectedCustom = Arrays.asList(volumeDefault, volumeToBeKept);
// No Volumes set.
V1Controller controllerDoNotSetVolumes = new V1Controller(Config.newBuilder().build(), RUNTIME);
V1PodSpec podSpecNoSetVolumes = new V1PodSpec();
controllerDoNotSetVolumes.addVolumesIfPresent(podSpecNoSetVolumes);
Assert.assertNull(podSpecNoSetVolumes.getVolumes());
// Default. Null Volumes.
V1PodSpec podSpecNull = new V1PodSpecBuilder().build();
controllerWithVol.addVolumesIfPresent(podSpecNull);
Assert.assertTrue("Default VOLUMES should be set in container with null VOLUMES", CollectionUtils.containsAll(expectedDefault, podSpecNull.getVolumes()));
// Empty Volumes list
V1PodSpec podSpecEmpty = new V1PodSpecBuilder().withVolumes(new LinkedList<>()).build();
controllerWithVol.addVolumesIfPresent(podSpecEmpty);
Assert.assertTrue("Default VOLUMES should be set in container with empty VOLUMES", CollectionUtils.containsAll(expectedDefault, podSpecEmpty.getVolumes()));
// Custom Volumes list
V1PodSpec podSpecCustom = new V1PodSpecBuilder().withVolumes(customVolumeList).build();
controllerWithVol.addVolumesIfPresent(podSpecCustom);
Assert.assertTrue("Default VOLUMES should be set in container with custom VOLUMES", CollectionUtils.containsAll(expectedCustom, podSpecCustom.getVolumes()));
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class V1ControllerTest method testGetPodTemplateLocationNoPodTemplate.
@Test
public void testGetPodTemplateLocationNoPodTemplate() {
expectedException.expect(TopologySubmissionException.class);
final Config testConfig = Config.newBuilder().put(POD_TEMPLATE_LOCATION_EXECUTOR, "CONFIGMAP-NAME.").build();
V1Controller v1Controller = new V1Controller(testConfig, RUNTIME);
v1Controller.getPodTemplateLocation(true);
}
Aggregations