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