use of com.cloudera.api.swagger.model.ApiParcel in project cloudbreak by hortonworks.
the class ParcelGeneratorUtil method getActivatedCDHParcelWithVersion.
public ApiParcel getActivatedCDHParcelWithVersion(String version) {
ApiParcel parcel = new ApiParcel();
ApiParcelState state = new ApiParcelState();
state.setCount(new BigDecimal(0));
parcel.setProduct("CDH");
parcel.setState(state);
parcel.setVersion(version);
parcel.setStage("ACTIVATED");
return parcel;
}
use of com.cloudera.api.swagger.model.ApiParcel in project cloudbreak by hortonworks.
the class ParcelMockActivatorUtil method getDefaultApiParcels.
private List<ApiParcel> getDefaultApiParcels(MockedTestContext testContext) {
String blueprintCdhVersion = testContext.getCloudProvider().getBlueprintCdhVersion();
DefaultCDHInfo defaultCDHInfo = inTestCdhParcelProvider.getParcels(blueprintCdhVersion).get(blueprintCdhVersion);
return defaultCDHInfo.getParcels().stream().map(product -> {
ApiParcel apiParcel = new ApiParcel();
apiParcel.setVersion(product.getVersion());
apiParcel.setProduct(product.getName());
apiParcel.setStage("ACTIVATED");
ApiParcelState state = new ApiParcelState();
state.setCount(new BigDecimal(0));
apiParcel.setState(state);
return apiParcel;
}).collect(Collectors.toList());
}
use of com.cloudera.api.swagger.model.ApiParcel in project cloudbreak by hortonworks.
the class ClouderaManagerParcelDecommissionServiceTest method testRemoveUnusedParcelVersions.
@Test
public void testRemoveUnusedParcelVersions() throws ApiException {
Stack stack = mock(Stack.class);
when(stack.getName()).thenReturn(STACK_NAME);
ClouderaManagerProduct currentProductWithVersionToKeep = new ClouderaManagerProduct().withName("CDH").withVersion("current");
doReturn(List.of(new ApiParcel().product("ignored").version("current"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version("old"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version("old2"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version(currentProductWithVersionToKeep.getVersion()))).when(parcelManagementService).getClouderaManagerParcelsByStatus(parcelsResourceApi, STACK_NAME, ParcelStatus.DISTRIBUTED);
ArgumentCaptor<Multimap<String, String>> parcelVersionsCaptorForDownloaded = ArgumentCaptor.forClass(Multimap.class);
when(clouderaManagerPollingServiceProvider.startPollingCmParcelStatus(eq(stack), eq(apiClient), parcelVersionsCaptorForDownloaded.capture(), eq(ParcelStatus.DOWNLOADED))).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
doReturn(List.of(new ApiParcel().product("ignored").version("current"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version("old"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version("old2"), new ApiParcel().product(currentProductWithVersionToKeep.getName()).version(currentProductWithVersionToKeep.getVersion()))).when(parcelManagementService).getClouderaManagerParcelsByStatus(parcelsResourceApi, STACK_NAME, ParcelStatus.DOWNLOADED);
ArgumentCaptor<Multimap<String, String>> parcelVersionsCaptorForDelete = ArgumentCaptor.forClass(Multimap.class);
when(clouderaManagerPollingServiceProvider.startPollingCmParcelDelete(eq(stack), eq(apiClient), parcelVersionsCaptorForDelete.capture())).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
underTest.removeUnusedParcelVersions(apiClient, parcelsResourceApi, parcelResourceApi, stack, currentProductWithVersionToKeep);
verify(parcelResourceApi).startRemovalOfDistributionCommand(STACK_NAME, currentProductWithVersionToKeep.getName(), "old");
verify(parcelResourceApi).startRemovalOfDistributionCommand(STACK_NAME, currentProductWithVersionToKeep.getName(), "old2");
assertEquals(2, parcelVersionsCaptorForDownloaded.getValue().size());
assertTrue(parcelVersionsCaptorForDownloaded.getValue().containsEntry("CDH", "old"));
assertTrue(parcelVersionsCaptorForDownloaded.getValue().containsEntry("CDH", "old2"));
verify(parcelResourceApi).removeDownloadCommand(STACK_NAME, currentProductWithVersionToKeep.getName(), "old");
verify(parcelResourceApi).removeDownloadCommand(STACK_NAME, currentProductWithVersionToKeep.getName(), "old2");
assertEquals(2, parcelVersionsCaptorForDelete.getValue().size());
assertTrue(parcelVersionsCaptorForDelete.getValue().containsEntry("CDH", "old"));
assertTrue(parcelVersionsCaptorForDelete.getValue().containsEntry("CDH", "old2"));
verifyNoMoreInteractions(parcelResourceApi);
}
use of com.cloudera.api.swagger.model.ApiParcel in project cloudbreak by hortonworks.
the class ClouderaManagerParcelDecommissionServiceTest method createApiParcelList.
private ApiParcelList createApiParcelList(Map<String, String> products, ParcelStatus parcelStatus) {
ApiParcelList parcelList = new ApiParcelList();
List<ApiParcel> apiParcels = products.entrySet().stream().map(entry -> createApiParcel(entry.getKey(), entry.getValue(), parcelStatus)).collect(Collectors.toList());
parcelList.setItems(apiParcels);
return parcelList;
}
use of com.cloudera.api.swagger.model.ApiParcel 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));
}
Aggregations