use of org.apache.heron.spi.common.Config in project heron by twitter.
the class AuroraContextTest method testUsesConfigString.
@Test
public void testUsesConfigString() {
final String auroraTemplate = "/dir/test.aurora";
Config config = Config.newBuilder().put(AuroraContext.JOB_TEMPLATE, auroraTemplate).put(Key.HERON_CONF, "/test").build();
Assert.assertEquals("Expected to use value from JOB_TEMPLATE config", auroraTemplate, AuroraContext.getHeronAuroraPath(config));
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class AuroraContextTest method testFallback.
@Test
public void testFallback() {
Config config = Config.newBuilder().put(Key.HERON_CONF, "/test").build();
Assert.assertEquals("Expected to use heron_conf/heron.aurora", "/test/heron.aurora", AuroraContext.getHeronAuroraPath(config));
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class AuroraSchedulerTest method testOnRestart.
@Test
public void testOnRestart() throws Exception {
Config mockConfig = Mockito.mock(Config.class);
PowerMockito.mockStatic(Config.class);
when(Config.toClusterMode(mockConfig)).thenReturn(mockConfig);
AuroraController controller = Mockito.mock(AuroraController.class);
doReturn(controller).when(scheduler).getController();
scheduler.initialize(mockConfig, Mockito.mock(Config.class));
// Construct the RestartTopologyRequest
int containerToRestart = 1;
Scheduler.RestartTopologyRequest restartTopologyRequest = Scheduler.RestartTopologyRequest.newBuilder().setTopologyName(TOPOLOGY_NAME).setContainerIndex(containerToRestart).build();
// Failed to kill job via controller
doReturn(false).when(controller).restart(containerToRestart);
Assert.assertFalse(scheduler.onRestart(restartTopologyRequest));
Mockito.verify(controller).restart(containerToRestart);
// Happy path
doReturn(true).when(controller).restart(containerToRestart);
assertTrue(scheduler.onRestart(restartTopologyRequest));
Mockito.verify(controller, Mockito.times(2)).restart(containerToRestart);
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class KubernetesSchedulerTest method testGetJobLinks.
@Test
public void testGetJobLinks() throws Exception {
final String SCHEDULER_URI = "http://k8s.uri";
final String JOB_LINK = SCHEDULER_URI + KubernetesConstants.JOB_LINK;
Config c = Config.newBuilder().put(KubernetesContext.HERON_KUBERNETES_SCHEDULER_URI, SCHEDULER_URI).build();
scheduler.initialize(c, mockRuntime);
List<String> links = scheduler.getJobLinks();
Assert.assertEquals(1, links.size());
System.out.println(links.get(0));
System.out.println(JOB_LINK);
Assert.assertTrue(links.get(0).equals(JOB_LINK));
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class V1Controller method addVolumesIfPresent.
/**
* Adds volume to the <code>Pod Spec</code> that Heron requires. Heron's values taking precedence.
* @param spec <code>Pod Spec</code> to be configured.
*/
@VisibleForTesting
protected void addVolumesIfPresent(final V1PodSpec spec) {
final Config config = getConfiguration();
if (KubernetesContext.hasVolume(config)) {
final V1Volume volumeFromConfig = Volumes.get().create(config);
if (volumeFromConfig != null) {
// Merge volumes. Deduplicate using volume's name with Heron defaults taking precedence.
KubernetesUtils.V1ControllerUtils<V1Volume> utils = new KubernetesUtils.V1ControllerUtils<>();
spec.setVolumes(utils.mergeListsDedupe(Collections.singletonList(volumeFromConfig), spec.getVolumes(), Comparator.comparing(V1Volume::getName), "Pod Template Volumes"));
LOG.fine("Adding volume: " + volumeFromConfig);
}
}
}
Aggregations