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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations