Search in sources :

Example 1 with ClouderaManagerCommandPollerObject

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);
}
Also used : ClouderaManagerCommandPollerObject(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject) ApiClient(com.cloudera.api.swagger.client.ApiClient) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 2 with ClouderaManagerCommandPollerObject

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));
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) ClouderaManagerCommandPollerObject(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject) ApiParcelList(com.cloudera.api.swagger.model.ApiParcelList) Test(org.junit.jupiter.api.Test)

Example 3 with 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);
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) ParcelResourceApi(com.cloudera.api.swagger.ParcelResourceApi) ClouderaManagerCommandPollerObject(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject) ApiClient(com.cloudera.api.swagger.client.ApiClient)

Example 4 with ClouderaManagerCommandPollerObject

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);
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) ParcelResourceApi(com.cloudera.api.swagger.ParcelResourceApi) ClouderaManagerCommandPollerObject(com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject) ApiClient(com.cloudera.api.swagger.client.ApiClient)

Example 5 with ClouderaManagerCommandPollerObject

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);
}
Also used : SocketException(java.net.SocketException) SocketTimeoutException(java.net.SocketTimeoutException) 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)

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