use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.
the class AmbariClusterStatusUpdaterTest method testUpdateClusterStatusShouldUpdateStackStatusWhenStackStatusChanged.
@Test
public void testUpdateClusterStatusShouldUpdateStackStatusWhenStackStatusChanged() throws CloudbreakSecuritySetupException {
// GIVEN
Stack stack = createStack(Status.AVAILABLE, Status.AVAILABLE);
BDDMockito.given(ambariClientProvider.getAmbariClient(BDDMockito.any(HttpClientConfig.class), BDDMockito.anyInt(), BDDMockito.any(Cluster.class))).willReturn(ambariClient);
BDDMockito.given(clusterStatusFactory.createClusterStatus(ambariClient, TEST_BLUEPRINT)).willReturn(ClusterStatus.INSTALLED);
// WHEN
underTest.updateClusterStatus(stack, stack.getCluster());
// THEN
BDDMockito.verify(clusterService, BDDMockito.times(1)).updateClusterStatusByStackId(stack.getId(), Status.STOPPED);
}
use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.
the class DefaultStackHostServiceTypeTest method updateStatusTestStartWhenClusterAndStackUpdateInProgressThenBadRequestExceptionDropping.
@Test
public void updateStatusTestStartWhenClusterAndStackUpdateInProgressThenBadRequestExceptionDropping() {
Stack stack = stack(UPDATE_IN_PROGRESS, UPDATE_IN_PROGRESS);
given(stackRepository.findOneWithLists(anyLong())).willReturn(stack);
given(clusterRepository.findOneWithLists(anyLong())).willReturn(stack.getCluster());
given(stackUpdater.updateStackStatus(anyLong(), any(DetailedStackStatus.class))).willReturn(stack);
thrown.expect(BadRequestException.class);
thrown.expectMessage("Cannot update the status of stack 'simplestack' to STARTED, because it isn't in STOPPED state.");
underTest.updateStatus(1L, StatusRequest.STARTED, true);
}
use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.
the class DefaultStackHostServiceTypeTest method updateStatusTestStopWhenClusterInStoppedAndStackUpdateInProgressThenBadRequestExceptionDropping.
@Test
public void updateStatusTestStopWhenClusterInStoppedAndStackUpdateInProgressThenBadRequestExceptionDropping() {
Stack stack = stack(UPDATE_IN_PROGRESS, STOPPED);
given(stackRepository.findOneWithLists(anyLong())).willReturn(stack);
given(clusterRepository.findOneWithLists(anyLong())).willReturn(stack.getCluster());
given(stackUpdater.updateStackStatus(anyLong(), any(DetailedStackStatus.class))).willReturn(stack);
thrown.expect(BadRequestException.class);
thrown.expectMessage("Cannot update the status of stack 'simplestack' to STOPPED, because it isn't in AVAILABLE state.");
underTest.updateStatus(1L, StatusRequest.STOPPED, true);
verify(flowManager, times(1)).triggerStackStop(anyObject());
}
use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.
the class DefaultStackHostServiceTypeTest method updateStatusTestStartWhenClusterInStoppedAndStackStartFailedThenTriggerStackStart.
@Test
public void updateStatusTestStartWhenClusterInStoppedAndStackStartFailedThenTriggerStackStart() {
Stack stack = stack(START_FAILED, STOPPED);
given(stackRepository.findOneWithLists(anyLong())).willReturn(stack);
given(clusterRepository.findOneWithLists(anyLong())).willReturn(stack.getCluster());
given(stackUpdater.updateStackStatus(anyLong(), any(DetailedStackStatus.class))).willReturn(stack);
underTest.updateStatus(1L, StatusRequest.STARTED, true);
verify(flowManager, times(1)).triggerStackStart(anyObject());
}
use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.
the class DefaultStackHostServiceTypeTest method updateStatusTestStopWhenClusterAndStackAvailableAndSpotInstancesThenBadRequestExceptionDropping.
@Test
public void updateStatusTestStopWhenClusterAndStackAvailableAndSpotInstancesThenBadRequestExceptionDropping() {
Stack stack = TestUtil.setSpotInstances(TestUtil.stack(AVAILABLE, TestUtil.awsCredential()));
given(stackRepository.findOneWithLists(anyLong())).willReturn(stack);
given(clusterRepository.findOneWithLists(anyLong())).willReturn(stack.getCluster());
given(stackUpdater.updateStackStatus(anyLong(), any(DetailedStackStatus.class))).willReturn(stack);
thrown.expect(BadRequestException.class);
thrown.expectMessage("Cannot stop a stack 'simplestack'. Reason: Spot instances cannot be stopped.");
underTest.updateStatus(1L, StatusRequest.STOPPED, true);
}
Aggregations