use of com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent in project cloudbreak by hortonworks.
the class ClusterStatusSyncHandlerTest method testOnApplicationEventWhenCBStackStatusInActiveCBClusterStatusActive.
@Test
public void testOnApplicationEventWhenCBStackStatusInActiveCBClusterStatusActive() {
Cluster cluster = getACluster(ClusterState.SUSPENDED);
when(clusterService.findById(anyLong())).thenReturn(cluster);
StackStatusV4Response stackStatusV4Response = new StackStatusV4Response();
stackStatusV4Response.setStatus(Status.UPDATE_IN_PROGRESS);
stackStatusV4Response.setClusterStatus(Status.AVAILABLE);
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 testOnApplicationEventWhenCBStatusFails.
@Test(expected = RuntimeException.class)
public void testOnApplicationEventWhenCBStatusFails() {
Cluster cluster = getACluster(ClusterState.RUNNING);
when(clusterService.findById(anyLong())).thenReturn(cluster);
when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenThrow(new RuntimeException("some error in communication"));
underTest.onApplicationEvent(new ClusterStatusSyncEvent(AUTOSCALE_CLUSTER_ID));
verify(clusterService).findById(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 testOnApplicationEventWhenCBStatusDeleted.
@Test
public void testOnApplicationEventWhenCBStatusDeleted() {
Cluster cluster = getACluster(ClusterState.RUNNING);
when(clusterService.findById(anyLong())).thenReturn(cluster);
when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(getStackResponse(Status.DELETE_COMPLETED));
when(clusterService.countByEnvironmentCrn("testEnvironmentCrn")).thenReturn(2);
underTest.onApplicationEvent(new ClusterStatusSyncEvent(AUTOSCALE_CLUSTER_ID));
verify(clusterService).removeById(AUTOSCALE_CLUSTER_ID);
verify(clusterService, never()).save(cluster);
verify(cloudbreakCommunicator).getStackStatusByCrn(CLOUDBREAK_STACK_CRN);
verify(altusMachineUserService, never()).deleteMachineUserForEnvironment(anyString(), anyString(), anyString());
}
use of com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent in project cloudbreak by hortonworks.
the class ClusterStatusSyncHandlerTest method testOnApplicationEventWhenCBStatusStoppedAndPeriscopeClusterSuspended.
@Test
public void testOnApplicationEventWhenCBStatusStoppedAndPeriscopeClusterSuspended() {
Cluster cluster = getACluster(ClusterState.SUSPENDED);
cluster.setState(ClusterState.SUSPENDED);
when(clusterService.findById(anyLong())).thenReturn(cluster);
when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(getStackResponse(Status.STOPPED));
underTest.onApplicationEvent(new ClusterStatusSyncEvent(AUTOSCALE_CLUSTER_ID));
verify(clusterService, never()).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 testOnApplicationEventWhenCBStatusDeletedAndNoMoreEnvironmentClusters.
@Test
public void testOnApplicationEventWhenCBStatusDeletedAndNoMoreEnvironmentClusters() {
Cluster cluster = getACluster(ClusterState.RUNNING);
cluster.setMachineUserCrn("testMachineUserCrn");
when(clusterService.findById(anyLong())).thenReturn(cluster);
when(clusterService.countByEnvironmentCrn("testEnvironmentCrn")).thenReturn(1);
when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(getStackResponse(Status.DELETE_COMPLETED));
underTest.onApplicationEvent(new ClusterStatusSyncEvent(AUTOSCALE_CLUSTER_ID));
verify(clusterService).removeById(AUTOSCALE_CLUSTER_ID);
verify(clusterService, never()).save(cluster);
verify(cloudbreakCommunicator).getStackStatusByCrn(CLOUDBREAK_STACK_CRN);
verify(altusMachineUserService, times(1)).deleteMachineUserForEnvironment("testTenant", cluster.getMachineUserCrn(), "testEnvironmentCrn");
}
Aggregations