Search in sources :

Example 6 with ClouderaManagerCommandPollerObject

use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject in project cloudbreak by hortonworks.

the class AbstractClouderaManagerCommandCheckerTaskTest method testPollingWithFiveInternalServerErrors.

@Test
public void testPollingWithFiveInternalServerErrors() throws ApiException {
    Stack stack = new Stack();
    BigDecimal id = new BigDecimal(ID);
    ClouderaManagerCommandPollerObject pollerObject = new ClouderaManagerCommandPollerObject(stack, apiClient, id);
    when(commandsResourceApi.readCommand(id)).thenAnswer(new Http500Answer(FIVE));
    for (int i = 0; i < FIVE; i++) {
        boolean inProgress = underTest.checkStatus(pollerObject);
        assertFalse(inProgress);
    }
    boolean result = underTest.checkStatus(pollerObject);
    assertTrue(result);
}
Also used : ClouderaManagerCommandPollerObject(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject) BigDecimal(java.math.BigDecimal) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 7 with ClouderaManagerCommandPollerObject

use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject in project cloudbreak by hortonworks.

the class AbstractClouderaManagerCommandCheckerTaskTest method testPollingWithConnectException.

@Test
public void testPollingWithConnectException() throws ApiException {
    Stack stack = new Stack();
    stack.setId(1L);
    StackStatus stackStatus = new StackStatus();
    stackStatus.setStatus(Status.UPDATE_IN_PROGRESS);
    stack.setStackStatus(stackStatus);
    BigDecimal id = new BigDecimal(1);
    ClouderaManagerCommandPollerObject pollerObject = new ClouderaManagerCommandPollerObject(stack, apiClient, id);
    ConnectException connectException = new ConnectException("Connect failed.");
    ApiException apiException = new ApiException(connectException);
    ApiException[] exceptions = new ApiException[TEN];
    for (int i = 0; i < TEN; i++) {
        exceptions[i] = apiException;
    }
    when(commandsResourceApi.readCommand(id)).thenAnswer(new ExceptionThrowingApiCommandAnswer(exceptions));
    for (int i = 0; i < TEN; i++) {
        boolean inProgress = underTest.checkStatus(pollerObject);
        assertFalse(inProgress);
    }
    underTest.checkStatus(pollerObject);
    verify(clusterEventService, times(1)).fireCloudbreakEvent(any(), any(), anyList());
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) ClouderaManagerCommandPollerObject(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject) BigDecimal(java.math.BigDecimal) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ConnectException(java.net.ConnectException) ApiException(com.cloudera.api.swagger.client.ApiException) Test(org.junit.Test)

Example 8 with ClouderaManagerCommandPollerObject

use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject in project cloudbreak by hortonworks.

the class AbstractClouderaManagerCommandCheckerTaskTest method testPollingWithSixInternalServerErrors.

@Test
public void testPollingWithSixInternalServerErrors() throws ApiException {
    Stack stack = new Stack();
    BigDecimal id = new BigDecimal(1);
    ClouderaManagerCommandPollerObject pollerObject = new ClouderaManagerCommandPollerObject(stack, apiClient, id);
    when(commandsResourceApi.readCommand(id)).thenAnswer(new Http500Answer(SIX));
    expectedEx.expect(ClouderaManagerOperationFailedException.class);
    expectedEx.expectMessage("Operation is considered failed.");
    for (int i = 0; i < SIX; i++) {
        boolean inProgress = underTest.checkStatus(pollerObject);
        assertFalse(inProgress);
    }
    underTest.checkStatus(pollerObject);
}
Also used : ClouderaManagerCommandPollerObject(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject) BigDecimal(java.math.BigDecimal) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 9 with ClouderaManagerCommandPollerObject

use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject in project cloudbreak by hortonworks.

the class AbstractClouderaManagerCommandCheckerTaskTest method testPollingWithThreeInternalServerErrorAndThreeSocketExceptions.

@Test
public void testPollingWithThreeInternalServerErrorAndThreeSocketExceptions() throws ApiException {
    Stack stack = new Stack();
    BigDecimal id = new BigDecimal(1);
    ClouderaManagerCommandPollerObject pollerObject = new ClouderaManagerCommandPollerObject(stack, apiClient, id);
    SocketException socketException = new SocketException("Network is unreachable (connect failed)");
    ApiException socketApiException = new ApiException(socketException);
    ApiException internalServerError = new ApiException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "error");
    when(commandsResourceApi.readCommand(id)).thenAnswer(new ExceptionThrowingApiCommandAnswer(internalServerError, internalServerError, internalServerError, socketApiException, socketApiException, socketApiException));
    expectedEx.expect(ClouderaManagerOperationFailedException.class);
    expectedEx.expectMessage("Operation is considered failed.");
    for (int i = 0; i < SIX; i++) {
        boolean inProgress = underTest.checkStatus(pollerObject);
        assertFalse(inProgress);
    }
    underTest.checkStatus(pollerObject);
}
Also used : SocketException(java.net.SocketException) ClouderaManagerCommandPollerObject(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject) BigDecimal(java.math.BigDecimal) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ApiException(com.cloudera.api.swagger.client.ApiException) Test(org.junit.Test)

Example 10 with ClouderaManagerCommandPollerObject

use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject in project cloudbreak by hortonworks.

the class ClouderaManagerHostStatusCheckerTest method getPollerObject.

private ClouderaManagerCommandPollerObject getPollerObject(InstanceMetaData... instanceMetaDatas) {
    Stack stack = new Stack();
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setInstanceMetaData(Set.of(instanceMetaDatas));
    stack.setInstanceGroups(Set.of(instanceGroup));
    return new ClouderaManagerCommandPollerObject(stack, new ApiClient(), BigDecimal.ONE);
}
Also used : ClouderaManagerCommandPollerObject(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject) ApiClient(com.cloudera.api.swagger.client.ApiClient) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Aggregations

ClouderaManagerCommandPollerObject (com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject)14 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)8 ApiParcel (com.cloudera.api.swagger.model.ApiParcel)6 BigDecimal (java.math.BigDecimal)5 Test (org.junit.Test)5 ApiClient (com.cloudera.api.swagger.client.ApiClient)4 ApiParcelList (com.cloudera.api.swagger.model.ApiParcelList)4 Test (org.junit.jupiter.api.Test)4 ApiException (com.cloudera.api.swagger.client.ApiException)3 ParcelResourceApi (com.cloudera.api.swagger.ParcelResourceApi)2 SocketException (java.net.SocketException)2 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)1 ConnectException (java.net.ConnectException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1