Search in sources :

Example 26 with SchedulerStateManagerAdaptor

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);
}
Also used : ExecutionEnvironment(com.twitter.heron.proto.system.ExecutionEnvironment) SchedulerStateManagerAdaptor(com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 27 with SchedulerStateManagerAdaptor

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);
}
Also used : SchedulerStateManagerAdaptor(com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 28 with SchedulerStateManagerAdaptor

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);
}
Also used : ISchedulerClient(com.twitter.heron.scheduler.client.ISchedulerClient) Scheduler(com.twitter.heron.proto.scheduler.Scheduler) SchedulerStateManagerAdaptor(com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 29 with SchedulerStateManagerAdaptor

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);
    }
}
Also used : ISchedulerClient(com.twitter.heron.scheduler.client.ISchedulerClient) Scheduler(com.twitter.heron.proto.scheduler.Scheduler) SchedulerStateManagerAdaptor(com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 30 with SchedulerStateManagerAdaptor

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));
}
Also used : PackingPlan(com.twitter.heron.spi.packing.PackingPlan) SchedulerStateManagerAdaptor(com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor) HashSet(java.util.HashSet) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

SchedulerStateManagerAdaptor (com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor)34 Test (org.junit.Test)20 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)20 Config (com.twitter.heron.spi.common.Config)13 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)12 Scheduler (com.twitter.heron.proto.scheduler.Scheduler)8 ISchedulerClient (com.twitter.heron.scheduler.client.ISchedulerClient)6 ILauncher (com.twitter.heron.spi.scheduler.ILauncher)6 PackingPlans (com.twitter.heron.proto.system.PackingPlans)5 HeronTopology (com.twitter.heron.api.HeronTopology)4 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)4 IStateManager (com.twitter.heron.spi.statemgr.IStateManager)4 ExecutionEnvironment (com.twitter.heron.proto.system.ExecutionEnvironment)3 IScheduler (com.twitter.heron.spi.scheduler.IScheduler)3 HashSet (java.util.HashSet)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 RoundRobinPacking (com.twitter.heron.packing.roundrobin.RoundRobinPacking)2 LauncherUtils (com.twitter.heron.scheduler.utils.LauncherUtils)2 PackingPlanProtoDeserializer (com.twitter.heron.spi.packing.PackingPlanProtoDeserializer)2 IScalable (com.twitter.heron.spi.scheduler.IScalable)2