use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ClusterUpscaleServiceTest method testInstallServicesWithoutRepairAndServiceRestart.
@Test
public void testInstallServicesWithoutRepairAndServiceRestart() throws CloudbreakException {
HostGroup hostGroup = newHostGroup("master", newInstance(InstanceStatus.SERVICES_HEALTHY), newInstance(InstanceStatus.SERVICES_HEALTHY), newInstance(InstanceStatus.DELETED_BY_PROVIDER));
stack.setInstanceGroups(Set.of(hostGroup.getInstanceGroup()));
when(hostGroupService.getByClusterWithRecipes(any())).thenReturn(Set.of(hostGroup));
when(hostGroupService.getByCluster(any())).thenReturn(Set.of(hostGroup));
when(parcelService.removeUnusedParcelComponents(stack)).thenReturn(new ParcelOperationStatus(Map.of(), Map.of()));
when(clusterApiConnectors.getConnector(any(Stack.class))).thenReturn(clusterApi);
underTest.installServicesOnNewHosts(1L, Set.of("master"), false, false, Map.of("master", Set.of("master-1", "master-2", "master-3")));
inOrder.verify(parcelService).removeUnusedParcelComponents(stack);
inOrder.verify(recipeEngine, times(1)).executePostAmbariStartRecipes(stack, Set.of(hostGroup));
inOrder.verify(clusterApi, times(1)).upscaleCluster(any());
inOrder.verify(clusterApi, times(0)).restartAll(false);
inOrder.verify(clusterStatusService, times(0)).getDecommissionedHostsFromCM();
inOrder.verify(clusterCommissionService, times(0)).recommissionHosts(any());
}
use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ClusterUpscaleServiceTest method testInstallServicesWithRepairAndServiceRestartWhenOneHostIsUnhealthy.
@Test
public void testInstallServicesWithRepairAndServiceRestartWhenOneHostIsUnhealthy() throws CloudbreakException {
HostGroup hostGroup = newHostGroup("master", newInstance(InstanceStatus.SERVICES_HEALTHY), newInstance(InstanceStatus.SERVICES_HEALTHY), newInstance(InstanceStatus.DELETED_BY_PROVIDER));
stack.setInstanceGroups(Set.of(hostGroup.getInstanceGroup()));
when(hostGroupService.getByClusterWithRecipes(any())).thenReturn(Set.of(hostGroup));
when(hostGroupService.getByCluster(any())).thenReturn(Set.of(hostGroup));
when(parcelService.removeUnusedParcelComponents(stack)).thenReturn(new ParcelOperationStatus(Map.of(), Map.of()));
when(clusterApiConnectors.getConnector(any(Stack.class))).thenReturn(clusterApi);
when(clusterApi.clusterStatusService()).thenReturn(clusterStatusService);
when(clusterStatusService.getDecommissionedHostsFromCM()).thenReturn(List.of());
underTest.installServicesOnNewHosts(1L, Set.of("master"), true, true, Map.of("master", Set.of("master-1", "master-2", "master-3")));
inOrder.verify(parcelService).removeUnusedParcelComponents(stack);
inOrder.verify(recipeEngine, times(1)).executePostAmbariStartRecipes(stack, Set.of(hostGroup));
inOrder.verify(clusterApi, times(1)).upscaleCluster(any());
inOrder.verify(clusterApi, times(0)).restartAll(false);
inOrder.verify(clusterCommissionService, times(0)).recommissionHosts(any());
}
use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ParcelServiceTest method testRemoveUnusedComponents.
@Test
void testRemoveUnusedComponents() throws CloudbreakException, CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
Stack stack = createStack();
Set<String> parcelNames = Set.of(PARCEL_NAME);
Set<ClusterComponent> clusterComponentsByBlueprint = Collections.emptySet();
ParcelOperationStatus removalStatus = new ParcelOperationStatus();
when(clusterApiConnectors.getConnector(stack)).thenReturn(clusterApi);
when(imageReaderService.getParcelNames(STACK_ID)).thenReturn(parcelNames);
when(clusterApi.removeUnusedParcels(clusterComponentsByBlueprint, parcelNames)).thenReturn(removalStatus);
underTest.removeUnusedParcelComponents(stack, clusterComponentsByBlueprint);
verify(imageReaderService).getParcelNames(STACK_ID);
verify(clusterApiConnectors).getConnector(stack);
verify(clusterApi).removeUnusedParcels(clusterComponentsByBlueprint, parcelNames);
verify(clusterComponentUpdater).removeUnusedCdhProductsFromClusterComponents(stack.getCluster().getId(), clusterComponentsByBlueprint, removalStatus);
}
use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ClusterComponentUpdaterTest method testRemoveUnusedCdhProductsFromClusterComponentsWhenThereIsOneComponentToDelete.
@Test
public void testRemoveUnusedCdhProductsFromClusterComponentsWhenThereIsOneComponentToDelete() {
Set<ClusterComponent> clusterComponentsByBlueprint = createComponents(Set.of(CDH));
ClusterComponent flinkComponent = createComponent(FLINK);
ClusterComponent cdhComponent = createComponent(CDH);
Set<ClusterComponent> clusterComponentsFromDb = Set.of(flinkComponent, cdhComponent);
when(clusterComponentConfigProvider.getComponentsByClusterId(CLUSTER_ID)).thenReturn(clusterComponentsFromDb);
underTest.removeUnusedCdhProductsFromClusterComponents(CLUSTER_ID, clusterComponentsByBlueprint, new ParcelOperationStatus(Map.of("FLINK", "version"), Map.of()));
verify(clusterComponentConfigProvider).getComponentsByClusterId(CLUSTER_ID);
verify(clusterComponentConfigProvider).deleteClusterComponents(Set.of(flinkComponent));
}
use of com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus in project cloudbreak by hortonworks.
the class ClouderaManagerParcelDecommissionServiceTest method testUndistributeUnusedComponents.
@Test
public void testUndistributeUnusedComponents() 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.DISTRIBUTED);
when(parcelsResourceApi.readParcels(STACK_NAME, "summary")).thenReturn(parcelList);
Stack stack = mock(Stack.class);
when(stack.getName()).thenReturn(STACK_NAME);
when(clouderaManagerPollingServiceProvider.startPollingCmParcelStatus(eq(stack), eq(apiClient), any(), any())).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
// WHEN
ParcelOperationStatus operationStatus = underTest.undistributeUnusedParcels(apiClient, parcelsResourceApi, parcelResourceApi, stack, usedComponents, productsFromImage);
// THEN
verify(parcelResourceApi, times(1)).startRemovalOfDistributionCommand(STACK_NAME, "product3", "version3");
verify(parcelResourceApi, times(0)).startRemovalOfDistributionCommand(STACK_NAME, "product1", "version1");
verify(parcelResourceApi, times(0)).startRemovalOfDistributionCommand(STACK_NAME, "product2", "version2");
verifyNoMoreInteractions(parcelResourceApi);
assertEquals(1, operationStatus.getSuccessful().size());
assertEquals(0, operationStatus.getFailed().size());
assertTrue(operationStatus.getSuccessful().containsEntry("product3", "version3"));
}
Aggregations