use of com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent in project cloudbreak by hortonworks.
the class ClusterStatusSyncHandlerTest method testOnApplicationEventWhenCBStatusStoppedAndPeriscopeClusterRunning.
@Test
public void testOnApplicationEventWhenCBStatusStoppedAndPeriscopeClusterRunning() {
Cluster cluster = getACluster(ClusterState.RUNNING);
when(clusterService.findById(anyLong())).thenReturn(cluster);
when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(getStackResponse(Status.STOPPED));
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 testOnApplicationEventWhenCBStackStatusActiveCBClusterStatusActive.
@Test
public void testOnApplicationEventWhenCBStackStatusActiveCBClusterStatusActive() {
Cluster cluster = getACluster(ClusterState.SUSPENDED);
when(clusterService.findById(anyLong())).thenReturn(cluster);
AutoscaleStackV4Response mockAutoscaleResponse = mock(AutoscaleStackV4Response.class);
StackStatusV4Response stackStatusV4Response = new StackStatusV4Response();
stackStatusV4Response.setStatus(Status.AVAILABLE);
stackStatusV4Response.setClusterStatus(Status.AVAILABLE);
when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(stackStatusV4Response);
when(cloudbreakCommunicator.getAutoscaleClusterByCrn(CLOUDBREAK_STACK_CRN)).thenReturn(mockAutoscaleResponse);
when(mockAutoscaleResponse.getEnvironmentCrn()).thenReturn("environmentcrn");
underTest.onApplicationEvent(new ClusterStatusSyncEvent(AUTOSCALE_CLUSTER_ID));
verify(clusterService).setState(AUTOSCALE_CLUSTER_ID, ClusterState.RUNNING);
verify(cloudbreakCommunicator).getStackStatusByCrn(CLOUDBREAK_STACK_CRN);
}
use of com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent in project cloudbreak by hortonworks.
the class ClusterStatusSyncHandlerTest method testOnApplicationEventWhenCBStatusRunningAndPeriscopeClusterStopped.
@Test
public void testOnApplicationEventWhenCBStatusRunningAndPeriscopeClusterStopped() {
Cluster cluster = getACluster(ClusterState.SUSPENDED);
when(clusterService.findById(anyLong())).thenReturn(cluster);
when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(getStackResponse(Status.AVAILABLE));
underTest.onApplicationEvent(new ClusterStatusSyncEvent(AUTOSCALE_CLUSTER_ID));
verify(clusterService).setState(AUTOSCALE_CLUSTER_ID, ClusterState.RUNNING);
verify(cloudbreakCommunicator).getStackStatusByCrn(CLOUDBREAK_STACK_CRN);
}
use of com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent in project cloudbreak by hortonworks.
the class ClusterStatusSyncHandlerTest method testOnApplicationEventWhenCBStackStatusActiveCBClusterStatusInactive.
@Test
public void testOnApplicationEventWhenCBStackStatusActiveCBClusterStatusInactive() {
Cluster cluster = getACluster(ClusterState.SUSPENDED);
when(clusterService.findById(anyLong())).thenReturn(cluster);
StackStatusV4Response stackStatusV4Response = new StackStatusV4Response();
stackStatusV4Response.setStatus(Status.AVAILABLE);
stackStatusV4Response.setClusterStatus(Status.UPDATE_IN_PROGRESS);
when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(stackStatusV4Response);
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 testOnApplicationEventWhenStopStartScalingEnabledAndClusterIsScaledUp.
@Test
public void testOnApplicationEventWhenStopStartScalingEnabledAndClusterIsScaledUp() {
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));
verify(clusterService).findById(AUTOSCALE_CLUSTER_ID);
verify(clusterService, never()).setState(anyLong(), any(ClusterState.class));
verify(cloudbreakCommunicator).getStackStatusByCrn(CLOUDBREAK_STACK_CRN);
}
Aggregations