Search in sources :

Example 11 with ApiParcelList

use of com.cloudera.api.swagger.model.ApiParcelList in project cloudbreak by hortonworks.

the class ClouderaManagerParcelDecommissionServiceTest method testDeactivateUnusedComponents.

@Test
void testDeactivateUnusedComponents() throws Exception {
    // GIVEN
    Set<String> productsFromImage = Set.of("product1", "product2", "product3");
    Set<String> usedComponents = Set.of("product1", "product2");
    Map<String, String> activatedParcels = Map.of("product1", "version1", "product3", "version3", "customParcel", "customParcelVersion");
    ApiParcelList parcelList = createApiParcelList(activatedParcels, ParcelStatus.ACTIVATED);
    when(parcelsResourceApi.readParcels(STACK_NAME, "summary")).thenReturn(parcelList);
    // WHEN
    ParcelOperationStatus actual = underTest.deactivateUnusedParcels(parcelsResourceApi, parcelResourceApi, STACK_NAME, usedComponents, productsFromImage);
    // THEN
    verify(parcelResourceApi, times(1)).deactivateCommand(STACK_NAME, "product3", "version3");
    verify(parcelResourceApi, times(0)).deactivateCommand(STACK_NAME, "product1", "version1");
    verify(parcelResourceApi, times(0)).deactivateCommand(STACK_NAME, "product2", "version2");
    verifyNoMoreInteractions(parcelResourceApi);
    assertEquals(1, actual.getSuccessful().size());
    assertEquals(0, actual.getFailed().size());
    assertTrue(actual.getSuccessful().containsEntry("product3", "version3"));
}
Also used : ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) ApiParcelList(com.cloudera.api.swagger.model.ApiParcelList) Test(org.junit.jupiter.api.Test)

Example 12 with ApiParcelList

use of com.cloudera.api.swagger.model.ApiParcelList in project cloudbreak by hortonworks.

the class ClouderaManagerParcelDecommissionServiceTest method testRemoveUnusedComponents.

@Test
public void testRemoveUnusedComponents() throws Exception {
    // GIVEN
    Set<String> productsFromImage = Set.of("product1", "product2", "product3");
    Set<String> usedComponents = Set.of("product1", "product2");
    Map<String, String> distributedParcels = Map.of("product1", "version1", "product3", "version3", "customParcel", "customParcelVersion");
    ApiParcelList parcelList = createApiParcelList(distributedParcels, ParcelStatus.DOWNLOADED);
    when(parcelsResourceApi.readParcels(STACK_NAME, "summary")).thenReturn(parcelList);
    Stack stack = mock(Stack.class);
    when(stack.getName()).thenReturn(STACK_NAME);
    when(clouderaManagerPollingServiceProvider.startPollingCmParcelDelete(eq(stack), eq(apiClient), any())).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
    // WHEN
    ParcelOperationStatus operationStatus = underTest.removeUnusedParcels(apiClient, parcelsResourceApi, parcelResourceApi, stack, usedComponents, productsFromImage);
    // THEN
    verify(parcelResourceApi, times(1)).removeDownloadCommand(STACK_NAME, "product3", "version3");
    verify(parcelResourceApi, times(0)).removeDownloadCommand(STACK_NAME, "product1", "version1");
    verify(parcelResourceApi, times(0)).removeDownloadCommand(STACK_NAME, "product2", "version2");
    verifyNoMoreInteractions(parcelResourceApi);
    assertEquals(0, operationStatus.getFailed().size());
    assertEquals(1, operationStatus.getSuccessful().size());
    assertTrue(operationStatus.getSuccessful().containsEntry("product3", "version3"));
}
Also used : ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) ApiParcelList(com.cloudera.api.swagger.model.ApiParcelList) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 13 with ApiParcelList

use of com.cloudera.api.swagger.model.ApiParcelList in project cloudbreak by hortonworks.

the class ClouderaManagerParcelActivationListenerTaskTest method checkStatusOneActivating.

@Test
void checkStatusOneActivating() throws ApiException {
    when(clouderaManagerApiPojoFactory.getParcelsResourceApi(apiClientMock)).thenReturn(parcelsResourcesApi);
    ClouderaManagerCommandPollerObject clouderaManagerCommandPollerObject = new ClouderaManagerCommandPollerObject(stack, apiClientMock, COMMAND_ID);
    ApiParcel apiParcel1 = TestUtil.apiParcel(CDH, ACTIVATED);
    ApiParcel apiParcel2 = TestUtil.apiParcel(CDSW, ACTIVATING);
    ApiParcelList apiParcelList = new ApiParcelList().items(List.of(apiParcel1, apiParcel2));
    when(parcelsResourcesApi.readParcels(eq(STACK_NAME), eq(SUMMARY))).thenReturn(apiParcelList);
    assertFalse(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 14 with ApiParcelList

use of com.cloudera.api.swagger.model.ApiParcelList in project cloudbreak by hortonworks.

the class ClouderaManagerParcelActivationListenerTaskTest method checkStatusBothActivating.

@Test
void checkStatusBothActivating() throws ApiException {
    when(clouderaManagerApiPojoFactory.getParcelsResourceApi(eq(apiClientMock))).thenReturn(parcelsResourcesApi);
    ClouderaManagerCommandPollerObject clouderaManagerCommandPollerObject = new ClouderaManagerCommandPollerObject(stack, apiClientMock, COMMAND_ID);
    ApiParcel apiParcel1 = TestUtil.apiParcel(CDH, ACTIVATING);
    ApiParcel apiParcel2 = TestUtil.apiParcel(CDSW, ACTIVATING);
    ApiParcelList apiParcelList = new ApiParcelList().items(List.of(apiParcel1, apiParcel2));
    when(parcelsResourcesApi.readParcels(eq(STACK_NAME), eq(SUMMARY))).thenReturn(apiParcelList);
    assertFalse(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 15 with ApiParcelList

use of com.cloudera.api.swagger.model.ApiParcelList in project cloudbreak by hortonworks.

the class ClouderaManagerParcelActivationListenerTaskTest method checkStatusMissing.

@Test
void checkStatusMissing() throws ApiException {
    when(clouderaManagerApiPojoFactory.getParcelsResourceApi(eq(apiClientMock))).thenReturn(parcelsResourcesApi);
    ClouderaManagerCommandPollerObject clouderaManagerCommandPollerObject = new ClouderaManagerCommandPollerObject(stack, apiClientMock, COMMAND_ID);
    ApiParcel apiParcel1 = TestUtil.apiParcel(CDH, ACTIVATED);
    ApiParcelList apiParcelList = new ApiParcelList().items(List.of(apiParcel1));
    when(parcelsResourcesApi.readParcels(eq(STACK_NAME), eq(SUMMARY))).thenReturn(apiParcelList);
    assertFalse(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)

Aggregations

ApiParcelList (com.cloudera.api.swagger.model.ApiParcelList)16 Test (org.junit.jupiter.api.Test)11 ApiParcel (com.cloudera.api.swagger.model.ApiParcel)8 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)8 ParcelOperationStatus (com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus)7 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)5 ApiClient (com.cloudera.api.swagger.client.ApiClient)4 ApiException (com.cloudera.api.swagger.client.ApiException)4 ClouderaManagerCommandPollerObject (com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerCommandPollerObject)4 ParcelsResourceApi (com.cloudera.api.swagger.ParcelsResourceApi)2 ParcelResourceApi (com.cloudera.api.swagger.ParcelResourceApi)1 Multimap (com.google.common.collect.Multimap)1 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)1 ParcelStatus (com.sequenceiq.cloudbreak.cm.model.ParcelStatus)1 ClouderaManagerPollingServiceProvider (com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerPollingServiceProvider)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1