Search in sources :

Example 6 with ParcelOperationStatus

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());
}
Also used : ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 7 with ParcelOperationStatus

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());
}
Also used : ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 8 with ParcelOperationStatus

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);
}
Also used : ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 9 with ParcelOperationStatus

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));
}
Also used : ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) Test(org.junit.Test)

Example 10 with ParcelOperationStatus

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

Aggregations

ParcelOperationStatus (com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus)25 Test (org.junit.jupiter.api.Test)16 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)15 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)8 ApiException (com.cloudera.api.swagger.client.ApiException)7 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)7 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)7 ApiParcelList (com.cloudera.api.swagger.model.ApiParcelList)6 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)5 ParcelResourceApi (com.cloudera.api.swagger.ParcelResourceApi)3 ParcelsResourceApi (com.cloudera.api.swagger.ParcelsResourceApi)3 ApiClient (com.cloudera.api.swagger.client.ApiClient)3 ApiParcel (com.cloudera.api.swagger.model.ApiParcel)3 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)3 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)3 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)3 Test (org.junit.Test)3 HashMultimap (com.google.common.collect.HashMultimap)2 Multimap (com.google.common.collect.Multimap)2