use of org.apache.heron.scheduler.client.ISchedulerClient in project heron by twitter.
the class RuntimeManagerRunnerTest method testKillTopologyHandlerFailCleanState.
@Test(expected = TopologyRuntimeManagementException.class)
public void testKillTopologyHandlerFailCleanState() {
Scheduler.KillTopologyRequest killTopologyRequest = Scheduler.KillTopologyRequest.newBuilder().setTopologyName(TOPOLOGY_NAME).build();
ISchedulerClient client = mock(ISchedulerClient.class);
RuntimeManagerRunner runner = newRuntimeManagerRunner(Command.KILL, client);
// Failed to invoke client's killTopology
when(client.killTopology(killTopologyRequest)).thenReturn(true);
doThrow(new TopologyRuntimeManagementException("")).when(runner).cleanState(eq(TOPOLOGY_NAME), any(SchedulerStateManagerAdaptor.class));
try {
runner.killTopologyHandler(TOPOLOGY_NAME);
} finally {
verify(client).killTopology(killTopologyRequest);
}
}
use of org.apache.heron.scheduler.client.ISchedulerClient in project heron by twitter.
the class RuntimeManagerRunnerTest method testKillTopologyHandlerOk.
@Test
public void testKillTopologyHandlerOk() {
Scheduler.KillTopologyRequest killTopologyRequest = Scheduler.KillTopologyRequest.newBuilder().setTopologyName(TOPOLOGY_NAME).build();
ISchedulerClient client = mock(ISchedulerClient.class);
RuntimeManagerRunner runner = newRuntimeManagerRunner(Command.KILL, client);
when(client.killTopology(killTopologyRequest)).thenReturn(true);
// Success case
doNothing().when(runner).cleanState(eq(TOPOLOGY_NAME), any(SchedulerStateManagerAdaptor.class));
runner.killTopologyHandler(TOPOLOGY_NAME);
verify(client).killTopology(killTopologyRequest);
}
use of org.apache.heron.scheduler.client.ISchedulerClient in project heron by twitter.
the class RuntimeManagerRunnerTest method testKillTopologyHandlerClientCantKill.
@Test(expected = TopologyRuntimeManagementException.class)
public void testKillTopologyHandlerClientCantKill() {
Scheduler.KillTopologyRequest killTopologyRequest = Scheduler.KillTopologyRequest.newBuilder().setTopologyName(TOPOLOGY_NAME).build();
ISchedulerClient client = mock(ISchedulerClient.class);
RuntimeManagerRunner runner = newRuntimeManagerRunner(Command.KILL, client);
// Failed to invoke client's killTopology
when(client.killTopology(killTopologyRequest)).thenReturn(false);
try {
runner.killTopologyHandler(TOPOLOGY_NAME);
} finally {
verify(client).killTopology(killTopologyRequest);
}
}
use of org.apache.heron.scheduler.client.ISchedulerClient in project heron by twitter.
the class RuntimeManagerMainTest method testManageTopologyFailCall.
@PrepareForTest(ReflectionUtils.class)
@Test(expected = TopologyRuntimeManagementException.class)
public void testManageTopologyFailCall() throws Exception {
config = mock(Config.class);
when(config.getStringValue(Key.TOPOLOGY_NAME)).thenReturn(TOPOLOGY_NAME);
RuntimeManagerMain runtimeManagerMain = spy(new RuntimeManagerMain(config, MOCK_COMMAND));
// Valid state manager class
Mockito.when(config.getStringValue(Key.STATE_MANAGER_CLASS)).thenReturn(IStateManager.class.getName());
PowerMockito.mockStatic(ReflectionUtils.class);
PowerMockito.doReturn(Mockito.mock(IStateManager.class)).when(ReflectionUtils.class, "newInstance", Mockito.eq(IStateManager.class.getName()));
// Legal request
doReturn(true).when(runtimeManagerMain).validateRuntimeManage(any(SchedulerStateManagerAdaptor.class), eq(TOPOLOGY_NAME));
// Successfully get ISchedulerClient
ISchedulerClient client = mock(ISchedulerClient.class);
doReturn(client).when(runtimeManagerMain).getSchedulerClient(any(Config.class));
// Failed to callRuntimeManagerRunner
doThrow(new TopologyRuntimeManagementException("")).when(runtimeManagerMain).callRuntimeManagerRunner(any(Config.class), eq(client), eq(false));
runtimeManagerMain.manageTopology();
}
Aggregations