Search in sources :

Example 36 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class ClusterRepairServiceTest method testRepairByHostGroups.

@Test
public void testRepairByHostGroups() {
    HostGroup hostGroup1 = new HostGroup();
    hostGroup1.setName("hostGroup1");
    hostGroup1.setRecoveryMode(RecoveryMode.MANUAL);
    InstanceMetaData host1 = getHost("host1", hostGroup1.getName(), InstanceStatus.SERVICES_UNHEALTHY, InstanceGroupType.CORE);
    hostGroup1.setInstanceGroup(host1.getInstanceGroup());
    when(hostGroupService.getByCluster(eq(1L))).thenReturn(Set.of(hostGroup1));
    when(stackUpdater.updateStackStatus(1L, DetailedStackStatus.REPAIR_IN_PROGRESS)).thenReturn(stack);
    when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack);
    when(stack.getInstanceMetaDataAsList()).thenReturn(List.of(host1));
    when(freeipaService.checkFreeipaRunning(stack.getEnvironmentCrn())).thenReturn(true);
    when(environmentService.environmentStatusInDesiredState(stack, Set.of(EnvironmentStatus.AVAILABLE))).thenReturn(true);
    when(stackStopRestrictionService.isInfrastructureStoppable(stack)).thenReturn(StopRestrictionReason.NONE);
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.repairHostGroups(1L, Set.of("hostGroup1"), false));
    verify(flowManager).triggerClusterRepairFlow(eq(1L), eq(Map.of("hostGroup1", List.of("host1"))), eq(false), eq(false));
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Test(org.junit.jupiter.api.Test)

Example 37 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class RecipeTemplateServiceTest method testCompareGenerateRecipesWithMultipleHostGroups.

@Test
public void testCompareGenerateRecipesWithMultipleHostGroups() {
    // GIVEN
    Set<HostGroup> hgs = new HashSet<>();
    HostGroup hgMaster = hostGroup("master", Set.of(recipe("r1", DUMMY_CONTENT_1), recipe("r2", DUMMY_CONTENT_2)));
    HostGroup hgGateway = hostGroup("gateway", new HashSet<>(), new HashSet<>());
    HostGroup hgWorker = hostGroup("worker", Set.of(recipe("r2", DUMMY_CONTENT_2)));
    hgs.add(hgMaster);
    hgs.add(hgGateway);
    hgs.add(hgWorker);
    Map<HostGroup, List<RecipeModel>> recipeModels = new HashMap<>();
    recipeModels.put(hgMaster, List.of(new RecipeModel("r1", RecipeType.PRE_CLOUDERA_MANAGER_START, DUMMY_CONTENT_1), new RecipeModel("r2", RecipeType.PRE_CLOUDERA_MANAGER_START, DUMMY_CONTENT_2)));
    recipeModels.put(hgWorker, List.of(new RecipeModel("r2", RecipeType.PRE_CLOUDERA_MANAGER_START, DUMMY_CONTENT_2)));
    // WHEN
    boolean result = recipeTemplateService.isGeneratedRecipesInDbStale(hgs, recipeModels);
    // THEN
    assertTrue(result);
}
Also used : HashMap(java.util.HashMap) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) List(java.util.List) RecipeModel(com.sequenceiq.cloudbreak.orchestrator.model.RecipeModel) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 38 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class RecipeTemplateServiceTest method testCompareGenerateRecipesWithNotMatchingModel.

@Test
public void testCompareGenerateRecipesWithNotMatchingModel() {
    // GIVEN
    Set<HostGroup> hgs = new HashSet<>();
    HostGroup hgMaster = hostGroup("master", Set.of(recipe("r1", DUMMY_CONTENT_1)));
    hgs.add(hgMaster);
    Map<HostGroup, List<RecipeModel>> recipeModels = new HashMap<>();
    recipeModels.put(hgMaster, List.of(new RecipeModel("r1", RecipeType.PRE_CLOUDERA_MANAGER_START, DUMMY_CONTENT_2)));
    // WHEN
    boolean result = recipeTemplateService.isGeneratedRecipesInDbStale(hgs, recipeModels);
    // THEN
    assertFalse(result);
}
Also used : HashMap(java.util.HashMap) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) List(java.util.List) RecipeModel(com.sequenceiq.cloudbreak.orchestrator.model.RecipeModel) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 39 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class RecipeTemplateServiceTest method testCompareGenerateRecipesDifferentSize.

@Test
public void testCompareGenerateRecipesDifferentSize() {
    // GIVEN
    Set<HostGroup> hgs = new HashSet<>();
    HostGroup hgMaster = hostGroup("master", Set.of(recipe("r1", DUMMY_CONTENT_1), recipe("r2", DUMMY_CONTENT_1)));
    hgs.add(hgMaster);
    Map<HostGroup, List<RecipeModel>> recipeModels = new HashMap<>();
    recipeModels.put(hgMaster, List.of(new RecipeModel("r1", RecipeType.PRE_CLOUDERA_MANAGER_START, DUMMY_CONTENT_1)));
    // WHEN
    boolean result = recipeTemplateService.isGeneratedRecipesInDbStale(hgs, recipeModels);
    // THEN
    assertFalse(result);
}
Also used : HashMap(java.util.HashMap) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) List(java.util.List) RecipeModel(com.sequenceiq.cloudbreak.orchestrator.model.RecipeModel) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 40 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class RecipeTemplateServiceTest method testCompareGenerateRecipesWithoutGeneratedRecipes.

@Test
public void testCompareGenerateRecipesWithoutGeneratedRecipes() {
    // GIVEN
    Set<HostGroup> hgs = new HashSet<>();
    HostGroup hgMaster = hostGroup("master", Set.of(recipe("r1", DUMMY_CONTENT_1)), new HashSet<>());
    hgs.add(hgMaster);
    Map<HostGroup, List<RecipeModel>> recipeModels = new HashMap<>();
    recipeModels.put(hgMaster, List.of(new RecipeModel("r1", RecipeType.PRE_CLOUDERA_MANAGER_START, DUMMY_CONTENT_1)));
    // WHEN
    boolean result = recipeTemplateService.isGeneratedRecipesInDbStale(hgs, recipeModels);
    // THEN
    assertFalse(result);
}
Also used : HashMap(java.util.HashMap) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) List(java.util.List) RecipeModel(com.sequenceiq.cloudbreak.orchestrator.model.RecipeModel) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)132 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)66 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)60 HashSet (java.util.HashSet)55 Test (org.junit.jupiter.api.Test)52 List (java.util.List)50 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)43 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)37 Map (java.util.Map)37 Set (java.util.Set)37 Collectors (java.util.stream.Collectors)35 HostGroupService (com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService)25 Optional (java.util.Optional)25 ArrayList (java.util.ArrayList)24 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)22 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)21 ClusterApiConnectors (com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors)21 HashMap (java.util.HashMap)19 Logger (org.slf4j.Logger)19 LoggerFactory (org.slf4j.LoggerFactory)19