Search in sources :

Example 11 with ClusterStatusSyncEvent

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);
}
Also used : ClusterStatusSyncEvent(com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent) Cluster(com.sequenceiq.periscope.domain.Cluster) Test(org.junit.Test)

Example 12 with ClusterStatusSyncEvent

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);
}
Also used : ClusterStatusSyncEvent(com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent) Cluster(com.sequenceiq.periscope.domain.Cluster) AutoscaleStackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response) StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response) Test(org.junit.Test)

Example 13 with ClusterStatusSyncEvent

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);
}
Also used : ClusterStatusSyncEvent(com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent) Cluster(com.sequenceiq.periscope.domain.Cluster) Test(org.junit.Test)

Example 14 with ClusterStatusSyncEvent

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);
}
Also used : ClusterState(com.sequenceiq.periscope.api.model.ClusterState) ClusterStatusSyncEvent(com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent) Cluster(com.sequenceiq.periscope.domain.Cluster) StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response) Test(org.junit.Test)

Example 15 with ClusterStatusSyncEvent

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

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