Search in sources :

Example 41 with HostGroup

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

the class RecipeTemplateServiceTest method testCompareGenerateRecipesMatches.

@Test
public void testCompareGenerateRecipesMatches() {
    // 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_1)));
    // 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 42 with HostGroup

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

the class RecipeTemplateServiceTest method hostGroup.

private HostGroup hostGroup(String name, Set<Recipe> recipes, Set<GeneratedRecipe> generatedRecipes) {
    HostGroup hg = new HostGroup();
    hg.setName(name);
    hg.setRecipes(recipes);
    hg.setGeneratedRecipes(generatedRecipes);
    return hg;
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)

Example 43 with HostGroup

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

the class RecipeTemplateServiceTest method testCompareGenerateRecipesWithGeneratedRecipeButNoRecipe.

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

Example 44 with HostGroup

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

the class ClusterOperationServiceTest method shouldTriggerRecoveryInAutoRecoveryHostsAndUpdateHostMetaData.

@Test
public void shouldTriggerRecoveryInAutoRecoveryHostsAndUpdateHostMetaData() {
    Blueprint blueprint = new Blueprint();
    blueprint.setBlueprintText("{ \"Blueprints\": { \"blueprint_name\": \"MyBlueprint\" } }");
    cluster.setBlueprint(blueprint);
    when(stackService.findByCrn(STACK_CRN)).thenReturn(stack);
    when(cloudbreakMessagesService.getMessage(any(), anyCollection())).thenReturn("auto recovery").thenReturn("failed node");
    InstanceMetaData host1 = getHost("host1", "master", InstanceStatus.SERVICES_HEALTHY, InstanceGroupType.GATEWAY);
    InstanceMetaData host2 = getHost("host2", "group2", InstanceStatus.SERVICES_HEALTHY, InstanceGroupType.GATEWAY);
    HostGroup hostGroup = getHostGroup(host1, RecoveryMode.AUTO);
    when(instanceMetaDataService.getAllInstanceMetadataByStackId(eq(stack.getId()))).thenReturn(Set.of(host1, host2));
    when(instanceMetaDataService.findNotTerminatedAndNotZombieForStack(eq(stack.getId()))).thenReturn(Set.of(host1, host2));
    when(hostGroupService.findHostGroupsInCluster(stack.getCluster().getId())).thenReturn(Set.of(hostGroup, getHostGroup(host2, RecoveryMode.MANUAL)));
    underTest.reportHealthChange(STACK_CRN, Map.of("host1", Optional.empty(), "host2", Optional.empty()), Set.of());
    Map<String, List<String>> autoRecoveredNodes = Map.of("master", List.of("host1"));
    verify(flowManager).triggerClusterRepairFlow(STACK_ID, autoRecoveredNodes, false);
    verify(cloudbreakMessagesService, times(1)).getMessage(eq(CLUSTER_AUTORECOVERY_REQUESTED_HOST_EVENT.getMessage()), any());
    verify(cloudbreakMessagesService, times(1)).getMessage(eq(CLUSTER_AUTORECOVERY_REQUESTED_CLUSTER_EVENT.getMessage()), any());
    verify(cloudbreakEventService, times(1)).fireCloudbreakEvent(STACK_ID, "RECOVERY", CLUSTER_AUTORECOVERY_REQUESTED_CLUSTER_EVENT, List.of("host1"));
    verify(cloudbreakMessagesService, times(1)).getMessage(eq(CLUSTER_FAILED_NODES_REPORTED_HOST_EVENT.getMessage()), any());
    verify(cloudbreakMessagesService, times(1)).getMessage(eq(CLUSTER_FAILED_NODES_REPORTED_CLUSTER_EVENT.getMessage()), any());
    verify(cloudbreakEventService, times(1)).fireCloudbreakEvent(STACK_ID, "RECOVERY", CLUSTER_FAILED_NODES_REPORTED_CLUSTER_EVENT, List.of("host2"));
    verify(updateHostsValidator, times(1)).validateComponentsCategory(stack, hostGroup.getName());
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 45 with HostGroup

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

the class RecipeEngineTest method testGetRecipeNameMapWithDuplications.

@Test
public void testGetRecipeNameMapWithDuplications() throws CloudbreakException {
    // GIVEN
    Recipe recipe = new Recipe();
    recipe.setName("myrecipe");
    Set<HostGroup> hgs = new HashSet<>();
    HostGroup hg1 = new HostGroup();
    hg1.setRecipes(Set.of(recipe));
    hg1.setName("master");
    HostGroup hg2 = new HostGroup();
    hg2.setRecipes(Set.of(recipe));
    hg2.setName("worker");
    hgs.add(hg1);
    hgs.add(hg2);
    given(stackService.getByIdWithListsInTransaction(eq(DUMMY_STACK_ID))).willReturn(stack());
    given(hostGroupService.getByClusterWithRecipes(eq(DUMMY_STACK_ID))).willReturn(hgs);
    // WHEN
    recipeEngine.uploadRecipes(DUMMY_STACK_ID);
    // THEN
    verify(orchestratorRecipeExecutor, times(1)).uploadRecipes(any(Stack.class), anyMap());
    verify(recipeTemplateService, times(1)).updateAllGeneratedRecipes(anySet(), anyMap());
}
Also used : Recipe(com.sequenceiq.cloudbreak.domain.Recipe) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) HashSet(java.util.HashSet) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) 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