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);
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class LocalLauncherTest method testLaunch.
@Test
public void testLaunch() throws Exception {
Config config = createRunnerConfig();
Config runtime = Mockito.mock(Config.class);
URI mockURI = new URI("h:a");
Mockito.doReturn(mockURI).when(runtime).get(Key.TOPOLOGY_PACKAGE_URI);
PackingPlan packingPlan = Mockito.mock(PackingPlan.class);
PowerMockito.spy(LocalContext.class);
PowerMockito.doReturn(WORKING_DIRECTORY).when(LocalContext.class, "workingDirectory", config);
LocalLauncher localLauncher = Mockito.spy(new LocalLauncher());
localLauncher.initialize(config, runtime);
// Failed to setup working directory
Mockito.doReturn(false).when(localLauncher).setupWorkingDirectoryAndExtractPackages();
Assert.assertFalse(localLauncher.launch(packingPlan));
// setup successfully
Mockito.doReturn(true).when(localLauncher).setupWorkingDirectoryAndExtractPackages();
String[] expectedSchedulerCommand = { "expected", "scheduler", "command" };
Mockito.doReturn(expectedSchedulerCommand).when(localLauncher).getSchedulerCommand();
// Failed to start the Scheduler Process
Mockito.doReturn(null).when(localLauncher).startScheduler(Mockito.any(String[].class));
Assert.assertFalse(localLauncher.launch(packingPlan));
Mockito.verify(localLauncher).startScheduler(expectedSchedulerCommand);
// Happy path
Mockito.doReturn(Mockito.mock(Process.class)).when(localLauncher).startScheduler(Mockito.any(String[].class));
Assert.assertTrue(localLauncher.launch(packingPlan));
Mockito.verify(localLauncher, Mockito.times(2)).startScheduler(expectedSchedulerCommand);
localLauncher.close();
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class LocalLauncherTest method createRunnerConfig.
private static Config createRunnerConfig() {
Config config = Mockito.mock(Config.class);
Mockito.when(config.getStringValue(Key.TOPOLOGY_NAME)).thenReturn(TOPOLOGY_NAME);
Mockito.when(config.getStringValue(Key.CLUSTER)).thenReturn(CLUSTER);
Mockito.when(config.getStringValue(Key.ROLE)).thenReturn(ROLE);
Mockito.when(config.getStringValue(Key.ENVIRON)).thenReturn(ENVIRON);
return config;
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class MarathonSchedulerTest method testGetJobLinks.
@Test
public void testGetJobLinks() throws Exception {
final String SCHEDULER_URI = "http://marathon.scheduler.uri";
final String JOB_LINK = SCHEDULER_URI + MarathonConstants.JOB_LINK + TOPOLOGY_NAME;
Config mockConfig = Mockito.mock(Config.class);
Mockito.when(mockConfig.getStringValue(MarathonContext.HERON_MARATHON_SCHEDULER_URI)).thenReturn(SCHEDULER_URI);
Config mockRuntime = Mockito.mock(Config.class);
Mockito.when(mockRuntime.getStringValue(Key.TOPOLOGY_NAME)).thenReturn(TOPOLOGY_NAME);
scheduler.initialize(mockConfig, 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 MesosLauncherTest method testGetSchedulerCommand.
@Test
@SuppressWarnings("unchecked")
public void testGetSchedulerCommand() throws Exception {
final String JAVA_HOME = "java_home";
final String NATIVE_LIBRARY_PATH = "native_library_path";
final URI mockURI = TypeUtils.getURI("file:///mock/uri");
Config config = Mockito.mock(Config.class);
Mockito.when(config.getStringValue(MesosContext.SCHEDULER_WORKING_DIRECTORY)).thenReturn("working-dir");
Mockito.when(config.getStringValue(MesosContext.HERON_MESOS_NATIVE_LIBRARY_PATH)).thenReturn(NATIVE_LIBRARY_PATH);
Mockito.when(config.getStringValue(Key.JAVA_HOME)).thenReturn(JAVA_HOME);
Config runtime = Mockito.mock(Config.class);
Mockito.when(runtime.get(Key.TOPOLOGY_PACKAGE_URI)).thenReturn(mockURI);
MesosLauncher launcher = Mockito.spy(MesosLauncher.class);
String[] mockCommand = new String[] { "mock", "scheduler", "command" };
Mockito.doReturn(mockCommand).when(launcher).schedulerCommandArgs(Mockito.anyList());
launcher.initialize(config, runtime);
String[] command = launcher.getSchedulerCommand();
// Assert the content of command
Assert.assertEquals(String.format("%s/bin/java", JAVA_HOME), command[0]);
Assert.assertEquals(String.format("-Djava.library.path=%s", NATIVE_LIBRARY_PATH), command[1]);
Assert.assertEquals("-cp", command[2]);
Assert.assertEquals(String.format("-Pheron.package.topology.uri=%s", mockURI.toString()), command[5]);
Assert.assertEquals(mockCommand[0], command[6]);
Assert.assertEquals(mockCommand[1], command[7]);
Assert.assertEquals(mockCommand[2], command[8]);
}
Aggregations