use of org.apache.heron.spi.common.Config in project heron by twitter.
the class NomadSchedulerTest method setUp.
@Before
public void setUp() throws Exception {
Config config = Config.newBuilder().put(Key.TOPOLOGY_NAME, TOPOLOGY_NAME).put(Key.TOPOLOGY_ID, TOPOLOGY_ID).put(NomadContext.HERON_NOMAD_SCHEDULER_URI, SCHEDULER_URI).put(NomadContext.HERON_NOMAD_CORE_FREQ_MAPPING, HERON_NOMAD_CORE_FREQ_MAPPING).put(Key.CORE_PACKAGE_URI, CORE_PACKAGE_URI).put(Key.USE_CORE_PACKAGE_URI, USE_CORE_PACKAGE_URI).put(Key.EXECUTOR_BINARY, EXECUTOR_BINARY).put(NomadContext.HERON_NOMAD_DRIVER, NomadConstants.NomadDriver.RAW_EXEC.getName()).put(NomadContext.HERON_NOMAD_NETWORK_MODE, "default").build();
this.mockRuntime = config;
this.mockConfig = config;
scheduler = Mockito.spy(NomadScheduler.class);
}
use of org.apache.heron.spi.common.Config 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();
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class YarnLauncherTest method getHMDriverConfConstructsReefConfig.
// This test verifies if launcher correctly provides all heron specific configurations are to reef
// framework. It does so by ensuring required configs exist. The test fails if an unknown config
// is found. Presence of unknown config should be verified and then added to the test below
@Test
public void getHMDriverConfConstructsReefConfig() throws Exception {
YarnLauncher launcher = new YarnLauncher();
YarnLauncher spyLauncher = Mockito.spy(launcher);
Mockito.doNothing().when(spyLauncher).addLibraryToClasspathSet(Mockito.anyString());
// inputConf contains configs provided to the launcher
Map<String, String> inputConf = new HashMap<>();
// expected contains the reef configs launcher is expected to construct using testConfigs
Map<String, String> expected = new HashMap<>();
setConfigs(inputConf, expected, Key.TOPOLOGY_NAME, "topology", TopologyName.class);
setConfigs(inputConf, expected, Key.TOPOLOGY_BINARY_FILE, "binary", TopologyJar.class);
setConfigs(inputConf, expected, Key.TOPOLOGY_PACKAGE_FILE, "pack", TopologyPackageName.class);
setConfigs(inputConf, expected, Key.CLUSTER, "cluster", Cluster.class);
setConfigs(inputConf, expected, Key.ROLE, "role", Role.class);
setConfigs(inputConf, expected, Key.ENVIRON, "env", Environ.class);
setConfigs(inputConf, expected, YarnKey.HERON_SCHEDULER_YARN_QUEUE.value(), "q", JobQueue.class);
setConfigs(inputConf, expected, YarnKey.YARN_SCHEDULER_DRIVER_MEMORY_MB.value(), "123", DriverMemory.class);
setConfigs(inputConf, expected, Key.CORE_PACKAGE_URI, new File(".").getName(), HeronCorePackageName.class);
// the following expected values are mostly specific to reef runtime
expected.put(JobControlHandler.class.getSimpleName(), ClientManager.class.getName());
expected.put(NodeDescriptorHandler.class.getSimpleName(), NodeDescriptorHandler.class.getName());
expected.put(ResourceAllocationHandler.class.getSimpleName(), ResourceAllocationHandler.class.getName());
expected.put(ResourceStatusHandler.class.getSimpleName(), ResourceStatusHandler.class.getName());
expected.put(RuntimeParameters.RuntimeStatusHandler.class.getSimpleName(), ResourceManagerStatus.class.getName());
expected.put(VerboseLogMode.class.getSimpleName(), "false");
expected.put(HttpPort.class.getSimpleName(), "0");
expected.put(DriverIdentifier.class.getSimpleName(), "topology");
Config.Builder builder = new Config.Builder();
for (String configName : inputConf.keySet()) {
builder.put(configName, inputConf.get(configName));
}
builder.put(Key.STATE_MANAGER_CLASS, "statemanager");
builder.put(Key.PACKING_CLASS, "packing");
Config config = builder.build();
spyLauncher.initialize(config, null);
Configuration resultConf = spyLauncher.getHMDriverConf();
for (NamedParameterNode<?> reefConfigNode : resultConf.getNamedParameters()) {
String resultValue = resultConf.getNamedParameter(reefConfigNode);
String expectedValue = expected.get(reefConfigNode.getName());
if (expectedValue == null) {
Assert.fail(String.format("Unknown config, %s:%s, provided to heron driver", reefConfigNode.getName(), resultConf.getNamedParameter(reefConfigNode)));
} else {
Assert.assertEquals(expectedValue, resultValue);
}
expected.remove(reefConfigNode.getName());
}
Assert.assertEquals(String.format("Missing expected configurations: %s", expected), 0, expected.size());
}
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());
}
Aggregations