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);
}
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;
}
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);
}
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());
}
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());
}
Aggregations