use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project heron by twitter.
the class RuntimeManagerMainTest method testValidateRuntimeManageWrongState.
@Test(expected = TopologyRuntimeManagementException.class)
public void testValidateRuntimeManageWrongState() {
SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
RuntimeManagerMain runtimeManagerMain = new RuntimeManagerMain(config, MOCK_COMMAND);
when(adaptor.isTopologyRunning(eq(TOPOLOGY_NAME))).thenReturn(true);
// Topology is running
ExecutionEnvironment.ExecutionState.Builder stateBuilder = ExecutionEnvironment.ExecutionState.newBuilder().setTopologyName(TOPOLOGY_NAME).setTopologyId(TOPOLOGY_ID).setCluster(CLUSTER).setEnviron(ENVIRON);
final String WRONG_ROLE = "wrong";
ExecutionEnvironment.ExecutionState wrongState = stateBuilder.setRole(WRONG_ROLE).build();
// cluster/role/environ not matched
when(adaptor.getExecutionState(eq(TOPOLOGY_NAME))).thenReturn(wrongState);
runtimeManagerMain.validateRuntimeManage(adaptor, TOPOLOGY_NAME);
}
use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project heron by twitter.
the class RuntimeManagerMainTest method testValidateRuntimeManageTopologyNotRunning.
@Test(expected = TopologyRuntimeManagementException.class)
public void testValidateRuntimeManageTopologyNotRunning() throws Exception {
SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
RuntimeManagerMain runtimeManagerMain = new RuntimeManagerMain(config, MOCK_COMMAND);
when(adaptor.isTopologyRunning(eq(TOPOLOGY_NAME))).thenReturn(false);
runtimeManagerMain.validateRuntimeManage(adaptor, TOPOLOGY_NAME);
}
use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project heron by twitter.
the class RuntimeManagerRunnerTest method testRestartTopologyHandlerSuccRestartTopology.
@Test
public void testRestartTopologyHandlerSuccRestartTopology() {
ISchedulerClient client = mock(ISchedulerClient.class);
SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
RuntimeManagerRunner runner = newRuntimeManagerRunner(Command.RESTART, client);
// Restart container 1, not containing TMaster
Scheduler.RestartTopologyRequest restartTopologyRequest = Scheduler.RestartTopologyRequest.newBuilder().setTopologyName(TOPOLOGY_NAME).setContainerIndex(1).build();
when(config.getIntegerValue(Key.TOPOLOGY_CONTAINER_ID)).thenReturn(1);
// Success case
when(client.restartTopology(restartTopologyRequest)).thenReturn(true);
runner.restartTopologyHandler(TOPOLOGY_NAME);
// Should not invoke DeleteTMasterLocation
verify(adaptor, never()).deleteTMasterLocation(TOPOLOGY_NAME);
}
use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project heron by twitter.
the class RuntimeManagerRunnerTest method testRestartTopologyHandlerFailDeleteTMasterLoc.
@Test(expected = TopologyRuntimeManagementException.class)
public void testRestartTopologyHandlerFailDeleteTMasterLoc() {
ISchedulerClient client = mock(ISchedulerClient.class);
SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
RuntimeManagerRunner runner = newRuntimeManagerRunner(Command.RESTART, client);
// Restart container 1, not containing TMaster
Scheduler.RestartTopologyRequest restartTopologyRequest = Scheduler.RestartTopologyRequest.newBuilder().setTopologyName(TOPOLOGY_NAME).setContainerIndex(1).build();
when(config.getIntegerValue(Key.TOPOLOGY_CONTAINER_ID)).thenReturn(1);
// Restart container 0, containing TMaster
when(config.getIntegerValue(Key.TOPOLOGY_CONTAINER_ID)).thenReturn(0);
when(runtime.get(Key.SCHEDULER_STATE_MANAGER_ADAPTOR)).thenReturn(adaptor);
when(adaptor.deleteTMasterLocation(TOPOLOGY_NAME)).thenReturn(false);
try {
runner.restartTopologyHandler(TOPOLOGY_NAME);
} finally {
// DeleteTMasterLocation should be invoked
verify(adaptor).deleteTMasterLocation(TOPOLOGY_NAME);
}
}
use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project heron by twitter.
the class SchedulerUtilsTest method persistUpdatedPackingPlanWillUpdatesStateManager.
@Test
public void persistUpdatedPackingPlanWillUpdatesStateManager() {
SchedulerStateManagerAdaptor adaptor = Mockito.mock(SchedulerStateManagerAdaptor.class);
Mockito.when(adaptor.updatePackingPlan(Mockito.any(PackingPlans.PackingPlan.class), eq(TOPOLOGY_NAME))).thenReturn(true);
Set<PackingPlan.ContainerPlan> containers = new HashSet<>();
containers.add(PackingTestUtils.testContainerPlan(1, 0, 1, 2));
PackingPlan packing = new PackingPlan("id", containers);
SchedulerUtils.persistUpdatedPackingPlan(TOPOLOGY_NAME, packing, adaptor);
Mockito.verify(adaptor).updatePackingPlan(Mockito.any(PackingPlans.PackingPlan.class), eq(TOPOLOGY_NAME));
}
Aggregations