use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject in project cloudbreak by hortonworks.
the class ClouderaManagerHostHealthyStatusCheckerTest method getPollerObject.
private ClouderaManagerCommandPollerObject getPollerObject() {
Stack stack = new Stack();
stack.setId(1L);
return new ClouderaManagerCommandPollerObject(stack, new ApiClient(), BigDecimal.ONE);
}
use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject in project cloudbreak by hortonworks.
the class ClouderaManagerParcelActivationListenerTaskTest method checkStatusActivated.
@Test
void checkStatusActivated() throws ApiException {
when(clouderaManagerApiPojoFactory.getParcelsResourceApi(eq(apiClientMock))).thenReturn(parcelsResourcesApi);
ClouderaManagerCommandPollerObject clouderaManagerCommandPollerObject = new ClouderaManagerCommandPollerObject(stack, apiClientMock, COMMAND_ID);
ApiParcel apiParcel1 = TestUtil.apiParcel(CDH, ACTIVATED);
ApiParcel apiParcel2 = TestUtil.apiParcel(CDSW, ACTIVATED);
ApiParcelList apiParcelList = new ApiParcelList().items(List.of(apiParcel1, apiParcel2));
when(parcelsResourcesApi.readParcels(eq(STACK_NAME), eq(SUMMARY))).thenReturn(apiParcelList);
assertTrue(underTest.checkStatus(clouderaManagerCommandPollerObject));
}
use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject in project cloudbreak by hortonworks.
the class ClouderaManagerUpgradeParcelDistributeListenerTaskTest method testDoStatusCheckWhenParcelIsInState.
private void testDoStatusCheckWhenParcelIsInState(ParcelStatus parcelStatus, boolean expected) throws ApiException {
ApiClient apiClient = mock(ApiClient.class);
ParcelResourceApi parcelResourceApi = mock(ParcelResourceApi.class);
when(clouderaManagerApiPojoFactory.getParcelResourceApi(apiClient)).thenReturn(parcelResourceApi);
when(parcelResource.getProduct()).thenReturn("CDH");
when(parcelResource.getClusterName()).thenReturn("clusterName");
when(parcelResource.getVersion()).thenReturn("7.2.8");
ApiParcel apiParcel = mock(ApiParcel.class);
when(parcelResourceApi.readParcel("clusterName", "CDH", "7.2.8")).thenReturn(apiParcel);
when(apiParcel.getStage()).thenReturn(parcelStatus.name());
ClouderaManagerCommandPollerObject pollerObject = new ClouderaManagerCommandPollerObject(null, apiClient, BigDecimal.ONE);
boolean result = underTest.doStatusCheck(pollerObject);
Assertions.assertEquals(expected, result);
}
use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject in project cloudbreak by hortonworks.
the class ClouderaManagerUpgradeParcelDownloadListenerTaskTest method testDoStatusCheckWithParcelStatusShouldReturnTrue.
private void testDoStatusCheckWithParcelStatusShouldReturnTrue(ParcelStatus parcelStatus, boolean expected) throws ApiException {
ApiClient apiClient = mock(ApiClient.class);
ParcelResourceApi parcelResourceApi = mock(ParcelResourceApi.class);
when(clouderaManagerApiPojoFactory.getParcelResourceApi(apiClient)).thenReturn(parcelResourceApi);
when(parcelResource.getProduct()).thenReturn("CDH");
when(parcelResource.getClusterName()).thenReturn("clusterName");
when(parcelResource.getVersion()).thenReturn("7.2.8");
ApiParcel apiParcel = mock(ApiParcel.class);
when(parcelResourceApi.readParcel("clusterName", "CDH", "7.2.8")).thenReturn(apiParcel);
when(apiParcel.getStage()).thenReturn(parcelStatus.name());
ClouderaManagerCommandPollerObject pollerObject = new ClouderaManagerCommandPollerObject(null, apiClient, BigDecimal.ONE);
boolean result = underTest.doStatusCheck(pollerObject);
Assertions.assertEquals(expected, result);
}
use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject in project cloudbreak by hortonworks.
the class AbstractClouderaManagerCommandCheckerTaskTest method testPollingWithFiveSocketExceptions.
@Test
public void testPollingWithFiveSocketExceptions() throws ApiException {
Stack stack = new Stack();
BigDecimal id = new BigDecimal(ID);
ClouderaManagerCommandPollerObject pollerObject = new ClouderaManagerCommandPollerObject(stack, apiClient, id);
SocketTimeoutException socketTimeoutException = new SocketTimeoutException("timeout");
ApiException apiException0 = new ApiException(socketTimeoutException);
SocketException socketException = new SocketException("Network is unreachable (connect failed)");
ApiException apiException1 = new ApiException(socketException);
when(commandsResourceApi.readCommand(id)).thenAnswer(new ExceptionThrowingApiCommandAnswer(apiException0, apiException1, apiException1, apiException1, apiException1));
for (int i = 0; i < FIVE; i++) {
boolean inProgress = underTest.checkStatus(pollerObject);
assertFalse(inProgress);
}
boolean result = underTest.checkStatus(pollerObject);
assertTrue(result);
}
Aggregations