Search in sources :

Example 6 with TopologyRuntimeManagementException

use of com.twitter.heron.scheduler.TopologyRuntimeManagementException in project incubator-heron by apache.

the class KubernetesSchedulerTest method testRemoveContainers.

@Test
public void testRemoveContainers() throws Exception {
    KubernetesController controller = Mockito.mock(KubernetesController.class);
    Mockito.doReturn(controller).when(scheduler).getController();
    scheduler.initialize(config, mockRuntime);
    Set<PackingPlan.ContainerPlan> containers = new HashSet<>();
    containers.add(PackingTestUtils.testContainerPlan(0));
    // Failure to remove container
    Mockito.doThrow(new TopologyRuntimeManagementException("")).when(controller).removeContainers(Mockito.anySetOf(PackingPlan.ContainerPlan.class));
    expectedException.expect(TopologyRuntimeManagementException.class);
    scheduler.removeContainers(containers);
    // Successful removal
    Mockito.doNothing().when(controller).removeContainers(Mockito.anySetOf(PackingPlan.ContainerPlan.class));
    scheduler.removeContainers(containers);
}
Also used : TopologyRuntimeManagementException(com.twitter.heron.scheduler.TopologyRuntimeManagementException) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

TopologyRuntimeManagementException (com.twitter.heron.scheduler.TopologyRuntimeManagementException)6 ApiException (io.kubernetes.client.ApiException)4 Response (com.squareup.okhttp.Response)2 V1beta1StatefulSet (io.kubernetes.client.models.V1beta1StatefulSet)2 V1beta1StatefulSetSpec (io.kubernetes.client.models.V1beta1StatefulSetSpec)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 ApiClient (io.kubernetes.client.ApiClient)1 CoreV1Api (io.kubernetes.client.apis.CoreV1Api)1 V1DeleteOptions (io.kubernetes.client.models.V1DeleteOptions)1