use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class LauncherUtilsTest method generatesPackingPlan.
@Test
public void generatesPackingPlan() throws Exception {
final String PACKING_CLASS = "nonExistingTestPackingClass";
final PackingPlan mockPackingPlan = Mockito.mock(PackingPlan.class);
IPacking mockPacking = Mockito.mock(IPacking.class);
Mockito.when(mockPacking.pack()).thenReturn(mockPackingPlan);
PowerMockito.spy(ReflectionUtils.class);
PowerMockito.doReturn(mockPacking).when(ReflectionUtils.class, "newInstance", PACKING_CLASS);
TopologyAPI.Topology mockTopology = PowerMockito.mock(TopologyAPI.Topology.class);
Config mockConfig = Mockito.mock(Config.class);
Mockito.when(mockConfig.getStringValue(Key.PACKING_CLASS)).thenReturn(PACKING_CLASS);
Mockito.when(mockConfig.get(Key.TOPOLOGY_DEFINITION)).thenReturn(mockTopology);
PackingPlan resultPacking = LauncherUtils.getInstance().createPackingPlan(mockConfig, mockConfig);
Assert.assertEquals(mockPackingPlan, resultPacking);
Mockito.verify(mockPacking).initialize(Mockito.any(Config.class), Mockito.eq(mockTopology));
Mockito.verify(mockPacking).pack();
Mockito.verify(mockPacking).close();
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class AuroraScheduler method getController.
/**
* Get an AuroraController based on the config and runtime
*
* @return AuroraController
*/
protected AuroraController getController() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
Boolean cliController = config.getBooleanValue(Key.AURORA_CONTROLLER_CLASS);
Config localConfig = Config.toLocalMode(this.config);
if (cliController) {
return new AuroraCLIController(Runtime.topologyName(runtime), Context.cluster(localConfig), Context.role(localConfig), Context.environ(localConfig), AuroraContext.getHeronAuroraPath(localConfig), Context.verbose(localConfig));
} else {
return new AuroraHeronShellController(Runtime.topologyName(runtime), Context.cluster(localConfig), Context.role(localConfig), Context.environ(localConfig), AuroraContext.getHeronAuroraPath(localConfig), Context.verbose(localConfig), localConfig);
}
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class KubernetesLauncher 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.spi.common.Config in project incubator-heron by apache.
the class SubmitterMainTest method setUp.
@Before
public void setUp() throws Exception {
// Mock objects to be verified
IPacking packing = mock(IPacking.class);
statemgr = mock(IStateManager.class);
launcher = mock(ILauncher.class);
uploader = mock(IUploader.class);
// Mock ReflectionUtils stuff
PowerMockito.spy(ReflectionUtils.class);
PowerMockito.doReturn(statemgr).when(ReflectionUtils.class, "newInstance", STATE_MANAGER_CLASS);
PowerMockito.doReturn(launcher).when(ReflectionUtils.class, "newInstance", LAUNCHER_CLASS);
PowerMockito.doReturn(packing).when(ReflectionUtils.class, "newInstance", PACKING_CLASS);
PowerMockito.doReturn(uploader).when(ReflectionUtils.class, "newInstance", UPLOADER_CLASS);
config = mock(Config.class);
when(config.getStringValue(Key.STATE_MANAGER_CLASS)).thenReturn(STATE_MANAGER_CLASS);
when(config.getStringValue(Key.LAUNCHER_CLASS)).thenReturn(LAUNCHER_CLASS);
when(config.getStringValue(Key.PACKING_CLASS)).thenReturn(PACKING_CLASS);
when(config.getStringValue(Key.UPLOADER_CLASS)).thenReturn(UPLOADER_CLASS);
when(packing.pack()).thenReturn(PackingTestUtils.testPackingPlan(TOPOLOGY_NAME, new RoundRobinPacking()));
topology = TopologyAPI.Topology.getDefaultInstance();
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class SchedulerClientFactoryTest method testGetLibrarySchedulerClient.
@Test
@PrepareForTest(ReflectionUtils.class)
public void testGetLibrarySchedulerClient() throws Exception {
// Instantiate mock objects
Config config = Mockito.mock(Config.class);
Config runtime = Mockito.mock(Config.class);
// Return a MockScheduler
Mockito.when(config.getStringValue(Key.SCHEDULER_CLASS)).thenReturn(IScheduler.class.getName());
PowerMockito.mockStatic(ReflectionUtils.class);
PowerMockito.doReturn(Mockito.mock(IScheduler.class)).when(ReflectionUtils.class, "newInstance", Mockito.eq(IScheduler.class.getName()));
// Get a LibrarySchedulerClient
Mockito.when(config.getBooleanValue(Key.SCHEDULER_IS_SERVICE)).thenReturn(false);
Assert.assertNotNull(new SchedulerClientFactory(config, runtime).getSchedulerClient());
}
Aggregations