Search in sources :

Example 36 with SchedulerStateManagerAdaptor

use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project incubator-heron by apache.

the class RuntimeManagerMainTest method testValidateRuntimeManageExecStateNotRequiredForKillCommand.

@Test
public void testValidateRuntimeManageExecStateNotRequiredForKillCommand() {
    SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
    RuntimeManagerMain runtimeManagerMain = new RuntimeManagerMain(config, Command.KILL);
    when(adaptor.isTopologyRunning(eq(TOPOLOGY_NAME))).thenReturn(true);
    when(adaptor.getExecutionState(eq(TOPOLOGY_NAME))).thenReturn(null);
    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 37 with SchedulerStateManagerAdaptor

use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project incubator-heron by apache.

the class RuntimeManagerMainTest method testValidateRuntimeManageNoExecState.

@Test(expected = TopologyRuntimeManagementException.class)
public void testValidateRuntimeManageNoExecState() {
    SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
    RuntimeManagerMain runtimeManagerMain = new RuntimeManagerMain(config, MOCK_COMMAND);
    when(adaptor.isTopologyRunning(eq(TOPOLOGY_NAME))).thenReturn(true);
    when(adaptor.getExecutionState(eq(TOPOLOGY_NAME))).thenReturn(null);
    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 38 with SchedulerStateManagerAdaptor

use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project incubator-heron by apache.

the class RuntimeManagerMainTest method testValidateRuntimeManageWrongStateForKillCommand.

@Test(expected = TopologyRuntimeManagementException.class)
public void testValidateRuntimeManageWrongStateForKillCommand() {
    SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
    RuntimeManagerMain runtimeManagerMain = new RuntimeManagerMain(config, Command.KILL);
    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 39 with SchedulerStateManagerAdaptor

use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project incubator-heron by apache.

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 40 with SchedulerStateManagerAdaptor

use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project incubator-heron by apache.

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)

Aggregations

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