Search in sources :

Example 6 with ClusterStatusSyncEvent

use of com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent in project cloudbreak by hortonworks.

the class ClusterStatusSyncHandlerTest method testOnApplicationEventWhenCBStatusRunningAndPeriscopeClusterRunning.

@Test
public void testOnApplicationEventWhenCBStatusRunningAndPeriscopeClusterRunning() {
    Cluster cluster = getACluster(ClusterState.RUNNING);
    when(clusterService.findById(anyLong())).thenReturn(cluster);
    when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(getStackResponse(Status.AVAILABLE));
    underTest.onApplicationEvent(new ClusterStatusSyncEvent(AUTOSCALE_CLUSTER_ID));
    verify(clusterService, never()).setState(anyLong(), any(ClusterState.class));
    verify(cloudbreakCommunicator).getStackStatusByCrn(CLOUDBREAK_STACK_CRN);
}
Also used : ClusterState(com.sequenceiq.periscope.api.model.ClusterState) ClusterStatusSyncEvent(com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent) Cluster(com.sequenceiq.periscope.domain.Cluster) Test(org.junit.Test)

Example 7 with ClusterStatusSyncEvent

use of com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent in project cloudbreak by hortonworks.

the class ClusterStatusSyncHandlerTest method testOnApplicationEventWhenCBStatusNotAvailable.

@Test
public void testOnApplicationEventWhenCBStatusNotAvailable() {
    Cluster cluster = getACluster(ClusterState.RUNNING);
    when(clusterService.findById(anyLong())).thenReturn(cluster);
    when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(getStackResponse(null));
    underTest.onApplicationEvent(new ClusterStatusSyncEvent(AUTOSCALE_CLUSTER_ID));
    verify(clusterService, never()).removeById(AUTOSCALE_CLUSTER_ID);
    verify(cloudbreakCommunicator).getStackStatusByCrn(CLOUDBREAK_STACK_CRN);
}
Also used : ClusterStatusSyncEvent(com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent) Cluster(com.sequenceiq.periscope.domain.Cluster) Test(org.junit.Test)

Example 8 with ClusterStatusSyncEvent

use of com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent in project cloudbreak by hortonworks.

the class ClusterStatusSyncHandlerTest method testOnApplicationEventWhenCBStatusUnreachable.

@Test
public void testOnApplicationEventWhenCBStatusUnreachable() {
    Cluster cluster = getACluster(ClusterState.RUNNING);
    when(clusterService.findById(anyLong())).thenReturn(cluster);
    when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(getStackResponse(Status.UNREACHABLE));
    underTest.onApplicationEvent(new ClusterStatusSyncEvent(AUTOSCALE_CLUSTER_ID));
    verify(clusterService).setState(AUTOSCALE_CLUSTER_ID, ClusterState.SUSPENDED);
    verify(cloudbreakCommunicator).getStackStatusByCrn(CLOUDBREAK_STACK_CRN);
}
Also used : ClusterStatusSyncEvent(com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent) Cluster(com.sequenceiq.periscope.domain.Cluster) Test(org.junit.Test)

Example 9 with ClusterStatusSyncEvent

use of com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent in project cloudbreak by hortonworks.

the class ClusterStatusSyncHandlerTest method testOnApplicationEventWhenStopStartScalingEnabledAndClusterIsScaledDown.

@Test
public void testOnApplicationEventWhenStopStartScalingEnabledAndClusterIsScaledDown() {
    // At the moment, there's no good way to determine if the cluster is scaled down,
    // so this test essentially exercises existing flow with the stopStartMechanism enabled.
    Cluster cluster = getACluster(ClusterState.RUNNING);
    cluster.setStopStartScalingEnabled(Boolean.TRUE);
    when(clusterService.findById(anyLong())).thenReturn(cluster);
    when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(getStackResponse(Status.AVAILABLE));
    underTest.onApplicationEvent(new ClusterStatusSyncEvent(AUTOSCALE_CLUSTER_ID));
    assertEquals(ClusterState.RUNNING, cluster.getState());
    verify(clusterService).findById(AUTOSCALE_CLUSTER_ID);
    verify(clusterService, never()).setState(anyLong(), any(ClusterState.class));
    verify(cloudbreakCommunicator).getStackStatusByCrn(CLOUDBREAK_STACK_CRN);
}
Also used : ClusterState(com.sequenceiq.periscope.api.model.ClusterState) ClusterStatusSyncEvent(com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent) Cluster(com.sequenceiq.periscope.domain.Cluster) Test(org.junit.Test)

Example 10 with ClusterStatusSyncEvent

use of com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent in project cloudbreak by hortonworks.

the class ClusterStatusSyncHandlerTest method testOnApplicationEventWhenCBStatusNodeFailure.

@Test
public void testOnApplicationEventWhenCBStatusNodeFailure() {
    Cluster cluster = getACluster(ClusterState.RUNNING);
    when(clusterService.findById(anyLong())).thenReturn(cluster);
    when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(getStackResponse(Status.NODE_FAILURE));
    underTest.onApplicationEvent(new ClusterStatusSyncEvent(AUTOSCALE_CLUSTER_ID));
    verify(clusterService).setState(AUTOSCALE_CLUSTER_ID, ClusterState.SUSPENDED);
    verify(cloudbreakCommunicator).getStackStatusByCrn(CLOUDBREAK_STACK_CRN);
}
Also used : ClusterStatusSyncEvent(com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent) Cluster(com.sequenceiq.periscope.domain.Cluster) Test(org.junit.Test)

Aggregations

Cluster (com.sequenceiq.periscope.domain.Cluster)15 ClusterStatusSyncEvent (com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent)15 Test (org.junit.Test)15 ClusterState (com.sequenceiq.periscope.api.model.ClusterState)5 StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)3 AutoscaleStackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response)1