Search in sources :

Example 36 with InstanceGroup

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.

the class StackStatusCheckerJobTest method internalTestInstanceSyncStopStart.

private void internalTestInstanceSyncStopStart(String instanceHgName, InstanceStatus instanceStatus, DetailedStackStatus expected) throws JobExecutionException {
    setupForCM();
    Set<HealthCheck> healthChecks = Sets.newHashSet(new HealthCheck(HealthCheckType.HOST, HealthCheckResult.UNHEALTHY, Optional.empty()), new HealthCheck(HealthCheckType.CERT, HealthCheckResult.UNHEALTHY, Optional.empty()));
    ExtendedHostStatuses extendedHostStatuses = new ExtendedHostStatuses(Map.of(HostName.hostName("host1"), healthChecks));
    when(clusterStatusService.getExtendedHostStatuses(any())).thenReturn(extendedHostStatuses);
    when(instanceMetaData.getInstanceStatus()).thenReturn(instanceStatus);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.datahub()).thenReturn(regionAwareInternalCrnGenerator);
    when(instanceMetaData.getDiscoveryFQDN()).thenReturn("host1");
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setGroupName(instanceHgName);
    when(instanceMetaData.getInstanceGroup()).thenReturn(instanceGroup);
    when(clusterApiConnectors.getConnector(stack)).thenReturn(clusterApi);
    when(clusterApi.clusterStatusService()).thenReturn(clusterStatusService);
    when(stackUtil.stopStartScalingEntitlementEnabled(any())).thenReturn(true);
    Set<String> computeGroups = new HashSet<>();
    computeGroups.add("compute");
    when(cmTemplateProcessor.getComputeHostGroups(any())).thenReturn(computeGroups);
    underTest.executeTracedJob(jobExecutionContext);
    verify(clusterOperationService, times(1)).reportHealthChange(any(), any(), anySet());
    verify(stackInstanceStatusChecker).queryInstanceStatuses(eq(stack), any());
    verify(clusterService, times(1)).updateClusterCertExpirationState(stack.getCluster(), true);
    verify(clusterService, times(1)).updateClusterStatusByStackId(stack.getId(), expected);
}
Also used : ExtendedHostStatuses(com.sequenceiq.cloudbreak.cluster.status.ExtendedHostStatuses) HealthCheck(com.sequenceiq.cloudbreak.common.type.HealthCheck) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) HashSet(java.util.HashSet)

Example 37 with InstanceGroup

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.

the class DatalakeRecoverySetupNewInstancesHandlerTest method setupInstanceGroup.

private InstanceGroup setupInstanceGroup(Long id) {
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setId(id);
    instanceGroup.setInitialNodeCount(0);
    instanceGroup.setGroupName("group" + id);
    return instanceGroup;
}
Also used : InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 38 with InstanceGroup

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.

the class StackCreationServiceTest method getStackContext.

private StackContext getStackContext(String volumeType, String cloudPlatform, TemporaryStorage tempStorage) {
    Stack stack = new Stack();
    stack.setType(StackType.WORKLOAD);
    InstanceGroup group = new InstanceGroup();
    Template template = new Template();
    template.setInstanceType("vm.type");
    template.setTemporaryStorage(tempStorage);
    VolumeTemplate volumeTemplate = new VolumeTemplate();
    volumeTemplate.setVolumeType(volumeType);
    template.setVolumeTemplates(new HashSet<>(Set.of(volumeTemplate)));
    group.setTemplate(template);
    stack.setInstanceGroups(Set.of(group));
    stack.setCloudPlatform(cloudPlatform);
    CloudContext cloudContext = CloudContext.Builder.builder().withPlatform(cloudPlatform).build();
    return new StackContext(null, stack, cloudContext, null, null);
}
Also used : StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) VolumeTemplate(com.sequenceiq.cloudbreak.domain.VolumeTemplate) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) VolumeTemplate(com.sequenceiq.cloudbreak.domain.VolumeTemplate) Template(com.sequenceiq.cloudbreak.domain.Template)

Example 39 with InstanceGroup

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.

the class StackUpscaleServiceTest method testGetInstanceCountToCreateWhenRepair.

@Test
public void testGetInstanceCountToCreateWhenRepair() {
    InstanceGroup instanceGroup = new InstanceGroup();
    when(stackScalabilityCondition.isScalable(any(), eq("worker"))).thenReturn(Boolean.TRUE);
    when(instanceMetaDataService.unusedInstancesInInstanceGroupByName(eq(1L), eq("worker"))).thenReturn(Set.of(instanceMetaData(1L, 1L, InstanceStatus.CREATED, false, instanceGroup), instanceMetaData(2L, 1L, InstanceStatus.CREATED, false, instanceGroup)));
    int instanceCountToCreate = stackUpscaleService.getInstanceCountToCreate(TestUtil.stack(), "worker", 3, true);
    assertEquals(3, instanceCountToCreate);
}
Also used : InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 40 with InstanceGroup

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.

the class CmVersionQueryServiceTest method createStack.

private Stack createStack() {
    Stack stack = new Stack();
    stack.setId(1L);
    stack.setCluster(new Cluster());
    Orchestrator orchestrator = new Orchestrator();
    orchestrator.setType("salt");
    stack.setOrchestrator(orchestrator);
    Set<InstanceGroup> instanceGroups = new HashSet<>();
    stack.setInstanceGroups(instanceGroups);
    return stack;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) HashSet(java.util.HashSet)

Aggregations

InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)288 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)132 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)93 Test (org.junit.jupiter.api.Test)91 HashSet (java.util.HashSet)68 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)57 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)47 Template (com.sequenceiq.cloudbreak.domain.Template)45 Test (org.junit.Test)44 Json (com.sequenceiq.cloudbreak.common.json.Json)38 Set (java.util.Set)37 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)34 ArrayList (java.util.ArrayList)31 LinkedHashSet (java.util.LinkedHashSet)31 Map (java.util.Map)28 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)27 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)27 List (java.util.List)26 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)25 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)22