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