Search in sources :

Example 96 with Stack

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);
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Example 97 with Stack

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);
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Example 98 with Stack

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());
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Example 99 with Stack

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());
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Example 100 with Stack

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);
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.Stack)207 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)74 Test (org.junit.Test)70 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)32 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)30 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)26 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)23 ArrayList (java.util.ArrayList)20 List (java.util.List)20 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)18 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)18 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)18 HashMap (java.util.HashMap)18 HashSet (java.util.HashSet)18 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)17 Map (java.util.Map)17 Matchers.anyString (org.mockito.Matchers.anyString)16 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)15 Set (java.util.Set)15 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)14