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