use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.
the class ClouderaManagerCommissionerTest method testCollectHostsToCommissionMissingInCBAndCM.
@Test
public void testCollectHostsToCommissionMissingInCBAndCM() throws ApiException {
Set<String> hostNames = createHostnames(3);
Set<String> hostnamesKnownToCm = new HashSet<>(hostNames);
hostnamesKnownToCm.remove(hostNames.iterator().next());
ApiHostList apiHostList = createGoodHealthApiHostList(hostnamesKnownToCm);
mockListClusterHosts(apiHostList);
Set<String> hostnamesKnownToCb = new HashSet<>(hostNames);
hostnamesKnownToCb.remove(hostnamesKnownToCm.iterator().next());
HostGroup hostGroup = createHostGroup(hostnamesKnownToCb);
Map<String, InstanceMetaData> result = underTest.collectHostsToCommission(getStack(), hostGroup, hostNames, client);
assertEquals(1, result.size());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.
the class TestUtil method hostGroup.
public static HostGroup hostGroup(String name, int count) {
HostGroup hostGroup = new HostGroup();
hostGroup.setId(1L);
hostGroup.setName(name);
hostGroup.setRecipes(recipes(1));
InstanceGroup instanceGroup = instanceGroup(1L, name, InstanceGroupType.CORE, gcpTemplate(1L), count);
hostGroup.setInstanceGroup(instanceGroup);
hostGroup.setCluster(cluster(blueprint(), stack(), 1L));
hostGroup.setRecoveryMode(RecoveryMode.MANUAL);
return hostGroup;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.
the class TestUtil method hostGroups.
public static Set<HostGroup> hostGroups(Cluster cluster) {
Set<HostGroup> hostGroups = new HashSet<>();
HostGroup hg = new HostGroup();
hg.setCluster(cluster);
hg.setId(1L);
hg.setName("slave_1");
hostGroups.add(hg);
return hostGroups;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.
the class ComponentLocatorServiceTest method testGetComponentLocation.
@Test
void testGetComponentLocation() {
HostGroup master1 = new HostGroup();
master1.setName(MASTER_1);
InstanceGroup ig1 = new InstanceGroup();
InstanceMetaData imd1 = new InstanceMetaData();
imd1.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
imd1.setDiscoveryFQDN(MASTER1_FQDN);
ig1.setInstanceMetaData(Set.of(imd1));
master1.setInstanceGroup(ig1);
HostGroup master2 = new HostGroup();
master2.setName(MASTER_2);
InstanceGroup ig2 = new InstanceGroup();
InstanceMetaData imd2 = new InstanceMetaData();
imd2.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
imd2.setDiscoveryFQDN(MASTER2_FQDN);
ig2.setInstanceMetaData(Set.of(imd2));
master2.setInstanceGroup(ig2);
HostGroup master3 = new HostGroup();
master3.setName(MASTER_3);
InstanceGroup ig3 = new InstanceGroup();
InstanceMetaData imd3 = new InstanceMetaData();
imd3.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
imd3.setDiscoveryFQDN(MASTER3_FQDN);
ig3.setInstanceMetaData(Set.of(imd3));
master3.setInstanceGroup(ig3);
HostGroup executor = new HostGroup();
executor.setName(EXECUTOR);
InstanceGroup ig4 = new InstanceGroup();
Set<InstanceMetaData> imd4 = EXECUTOR_FQDNS.stream().map(fqdn -> {
InstanceMetaData imd = new InstanceMetaData();
imd.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
imd.setDiscoveryFQDN(fqdn);
return imd;
}).collect(Collectors.toSet());
ig4.setInstanceMetaData(imd4);
executor.setInstanceGroup(ig4);
HostGroup coordinator = new HostGroup();
coordinator.setName(COORDINATOR);
InstanceGroup ig5 = new InstanceGroup();
Set<InstanceMetaData> imd5 = COORDINATOR_FQDNS.stream().map(fqdn -> {
InstanceMetaData imd = new InstanceMetaData();
imd.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
imd.setDiscoveryFQDN(fqdn);
return imd;
}).collect(Collectors.toSet());
ig5.setInstanceMetaData(imd5);
coordinator.setInstanceGroup(ig5);
Set<HostGroup> hostGroups = new LinkedHashSet<>(List.of(master1, master2, master3, executor, coordinator));
when(blueprintTextProcessor.getComponentsInHostGroup(MASTER_1)).thenReturn(MASTER1_COMPONENTS);
when(blueprintTextProcessor.getComponentsInHostGroup(MASTER_2)).thenReturn(MASTER2_COMPONENTS);
when(blueprintTextProcessor.getComponentsInHostGroup(MASTER_3)).thenReturn(MASTER3_COMPONENTS);
when(blueprintTextProcessor.getComponentsInHostGroup(EXECUTOR)).thenReturn(EXECUTOR_COMPONENTS);
when(blueprintTextProcessor.getComponentsInHostGroup(COORDINATOR)).thenReturn(COORDINATOR_COMPONENTS);
when(hostGroupService.getByCluster(CLUSTER_ID)).thenReturn(hostGroups);
Map<String, List<String>> result = underTest.getComponentLocation(CLUSTER_ID, blueprintTextProcessor, COMPONENT_NAMES);
assertEquals(1, result.get(NAMENODE).size());
assertEquals(MASTER1_FQDN, result.get(NAMENODE).get(0));
assertEquals(3, result.get(KUDU_MASTER).size());
assertEquals(1, result.get(SPARK_YARN_HISTORY_SERVER).size());
assertEquals(6, result.size());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.
the class ClusterRepairServiceTest method testCanRepairPrewarmedGatewayWithRepairPossibleBasedOnDBSetup.
@Test
public void testCanRepairPrewarmedGatewayWithRepairPossibleBasedOnDBSetup() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
HostGroup hostGroup1 = new HostGroup();
hostGroup1.setName("hostGroup1");
hostGroup1.setRecoveryMode(RecoveryMode.MANUAL);
InstanceMetaData host1 = getHost("host1", hostGroup1.getName(), InstanceStatus.SERVICES_HEALTHY, InstanceGroupType.GATEWAY);
hostGroup1.setInstanceGroup(host1.getInstanceGroup());
when(hostGroupService.getByCluster(eq(1L))).thenReturn(Set.of(hostGroup1));
when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack);
when(componentConfigProviderService.getImage(stack.getId())).thenReturn(mock(Image.class));
com.sequenceiq.cloudbreak.cloud.model.catalog.Image image = mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class);
when(image.isPrewarmed()).thenReturn(true);
when(imageCatalogService.getImage(any(), any(), any())).thenReturn(StatedImage.statedImage(image, "catalogUrl", "catalogName"));
when(clusterDBValidationService.isGatewayRepairEnabled(cluster)).thenReturn(true);
when(freeipaService.checkFreeipaRunning(stack.getEnvironmentCrn())).thenReturn(true);
when(environmentService.environmentStatusInDesiredState(stack, Set.of(EnvironmentStatus.AVAILABLE))).thenReturn(true);
when(stackStopRestrictionService.isInfrastructureStoppable(stack)).thenReturn(StopRestrictionReason.NONE);
Result result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.repairWithDryRun(stack.getId()));
assertTrue(result.isSuccess());
verifyNoInteractions(stackUpdater, flowManager, resourceService);
}
Aggregations