use of org.apache.heron.spi.common.Config in project heron by twitter.
the class MesosLauncherTest method testLaunch.
@Test
public void testLaunch() throws Exception {
MesosLauncher launcher = Mockito.spy(MesosLauncher.class);
PackingPlan packingPlan = Mockito.mock(PackingPlan.class);
Config config = Mockito.mock(Config.class);
Mockito.doReturn("working-dir").when(config).getStringValue(MesosContext.SCHEDULER_WORKING_DIRECTORY);
Config runtime = Mockito.mock(Config.class);
launcher.initialize(config, runtime);
// Failed to setup working dir
Mockito.doReturn(false).when(launcher).setupWorkingDirectory();
Assert.assertFalse(launcher.launch(packingPlan));
Mockito.doReturn(true).when(launcher).setupWorkingDirectory();
String[] mockCommand = new String[] { "mock", "scheduler", "command" };
Mockito.doReturn(mockCommand).when(launcher).getSchedulerCommand();
// Failed to spwan the process
Mockito.doReturn(null).when(launcher).startScheduler(mockCommand);
Assert.assertFalse(launcher.launch(packingPlan));
// Happy path
Process p = Mockito.mock(Process.class);
Mockito.doReturn(p).when(launcher).startScheduler(mockCommand);
Assert.assertTrue(launcher.launch(packingPlan));
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class MesosSchedulerTest method before.
@Before
public void before() throws Exception {
Config config = Mockito.mock(Config.class);
Mockito.when(config.getStringValue(Key.TOPOLOGY_NAME)).thenReturn(TOPOLOGY_NAME);
Mockito.when(config.getStringValue(Key.ROLE)).thenReturn(ROLE);
Mockito.when(config.getStringValue(Key.CORE_PACKAGE_URI)).thenReturn(CORE_PACKAGE_URI);
Config runtime = Mockito.mock(Config.class);
Mockito.when(runtime.getLongValue(Key.NUM_CONTAINERS)).thenReturn(NUM_CONTAINER);
Properties properties = new Properties();
properties.put(Key.TOPOLOGY_PACKAGE_URI.value(), TOPOLOGY_PACKAGE_URI);
Mockito.when(runtime.get(Key.SCHEDULER_PROPERTIES)).thenReturn(properties);
mesosFramework = Mockito.mock(MesosFramework.class);
SchedulerDriver driver = Mockito.mock(SchedulerDriver.class);
baseContainer = Mockito.mock(BaseContainer.class);
scheduler = Mockito.spy(MesosScheduler.class);
Mockito.doReturn(mesosFramework).when(scheduler).getMesosFramework();
Mockito.doReturn(driver).when(scheduler).getSchedulerDriver(Mockito.anyString(), Mockito.eq(mesosFramework));
Mockito.doNothing().when(scheduler).startSchedulerDriver();
scheduler.initialize(config, runtime);
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class SlurmSchedulerTest method testOnKill.
@Test
public void testOnKill() throws Exception {
SlurmController controller = Mockito.mock(SlurmController.class);
Mockito.doReturn(controller).when(scheduler).getController();
Mockito.doReturn(SLURM_ID_FILE).when(scheduler).getJobIdFilePath();
Config config = createRunnerConfig();
Config runtime = Mockito.mock(Config.class);
PowerMockito.spy(SlurmContext.class);
PowerMockito.doReturn(WORKING_DIRECTORY).when(SlurmContext.class, "workingDirectory", config);
scheduler.initialize(config, runtime);
// Failed to kill job via controller
Mockito.doReturn(false).when(controller).killJob(Mockito.anyString());
Assert.assertFalse(scheduler.onKill(Scheduler.KillTopologyRequest.getDefaultInstance()));
Mockito.verify(controller).killJob(Mockito.anyString());
// Happy path
Mockito.doReturn(true).when(controller).killJob(Mockito.anyString());
Assert.assertTrue(scheduler.onKill(Scheduler.KillTopologyRequest.getDefaultInstance()));
Mockito.verify(controller, Mockito.times(2)).killJob(Mockito.anyString());
}
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));
}
Aggregations