use of com.twitter.heron.scheduler.utils.LauncherUtils 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 com.twitter.heron.scheduler.utils.LauncherUtils in project heron by twitter.
the class AuroraLauncher 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 com.twitter.heron.scheduler.utils.LauncherUtils in project heron by twitter.
the class SlurmLauncherTest method testLaunch.
/**
* Test slurm scheduler launcher
*/
@Test
public void testLaunch() throws Exception {
Config config = createRunnerConfig();
Config runtime = Mockito.mock(Config.class);
PackingPlan packingPlan = Mockito.mock(PackingPlan.class);
PackingPlan plan = new PackingPlan("plan.id", new HashSet<PackingPlan.ContainerPlan>());
PowerMockito.spy(SlurmContext.class);
PowerMockito.doReturn(WORKING_DIRECTORY).when(SlurmContext.class, "workingDirectory", config);
LauncherUtils mockLauncherUtils = Mockito.mock(LauncherUtils.class);
PowerMockito.spy(LauncherUtils.class);
PowerMockito.doReturn(mockLauncherUtils).when(LauncherUtils.class, "getInstance");
SlurmLauncher slurmLauncher = Mockito.spy(new SlurmLauncher());
slurmLauncher.initialize(config, runtime);
SlurmScheduler slurmScheduler = Mockito.spy(new SlurmScheduler());
PowerMockito.doReturn(true).when(slurmScheduler).onSchedule(plan);
// Failed to download
Mockito.doReturn(false).when(slurmLauncher).setupWorkingDirectory();
Assert.assertFalse(slurmLauncher.launch(packingPlan));
Mockito.verify(slurmLauncher).setupWorkingDirectory();
// Failed to schedule
Mockito.when(mockLauncherUtils.onScheduleAsLibrary(Mockito.any(Config.class), Mockito.any(Config.class), Mockito.any(IScheduler.class), Mockito.any(PackingPlan.class))).thenReturn(false);
PowerMockito.doReturn(true).when(slurmLauncher).setupWorkingDirectory();
Assert.assertFalse(slurmLauncher.launch(Mockito.mock(PackingPlan.class)));
Mockito.verify(mockLauncherUtils).onScheduleAsLibrary(Mockito.any(Config.class), Mockito.any(Config.class), Mockito.any(IScheduler.class), Mockito.any(PackingPlan.class));
// happy path
Mockito.when(mockLauncherUtils.onScheduleAsLibrary(Mockito.any(Config.class), Mockito.any(Config.class), Mockito.any(IScheduler.class), Mockito.any(PackingPlan.class))).thenReturn(true);
Assert.assertTrue(slurmLauncher.launch(Mockito.mock(PackingPlan.class)));
Mockito.verify(slurmLauncher, Mockito.times(3)).launch(Mockito.any(PackingPlan.class));
Mockito.verify(mockLauncherUtils, Mockito.times(2)).onScheduleAsLibrary(Mockito.any(Config.class), Mockito.any(Config.class), Mockito.any(IScheduler.class), Mockito.any(PackingPlan.class));
slurmLauncher.close();
}
Aggregations