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