Search in sources :

Example 61 with HostGroup

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());
}
Also used : ApiHostList(com.cloudera.api.swagger.model.ApiHostList) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 62 with HostGroup

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;
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 63 with 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;
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) HashSet(java.util.HashSet)

Example 64 with HostGroup

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());
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) InjectMocks(org.mockito.InjectMocks) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) Mock(org.mockito.Mock) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) Mockito.when(org.mockito.Mockito.when) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) List(java.util.List) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Map(java.util.Map) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) LinkedHashSet(java.util.LinkedHashSet) LinkedHashSet(java.util.LinkedHashSet) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) List(java.util.List) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 65 with HostGroup

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);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Result(com.sequenceiq.cloudbreak.service.cluster.model.Result) 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