use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class RepairInstancesServiceTest method createStack.
private Stack createStack(Status stackStatus, List<InstanceStatus> instanceStatuses, int requestedInstancesWithoutInstanceIds) {
Stack stack = new Stack();
stack.setId(STACK_ID);
stack.setEnvironmentCrn(ENVIRONMENT_ID1);
StackStatus s = new StackStatus();
s.setStatus(stackStatus);
stack.setStackStatus(s);
int i = 1;
Set<InstanceMetaData> instanceMetaDataSet = new HashSet<>();
for (InstanceStatus instanceStatus : instanceStatuses) {
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setInstanceId("i-" + i);
instanceMetaData.setInstanceStatus(instanceStatus);
instanceMetaDataSet.add(instanceMetaData);
i++;
}
for (i = 0; i < requestedInstancesWithoutInstanceIds; i++) {
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setInstanceStatus(InstanceStatus.REQUESTED);
instanceMetaDataSet.add(instanceMetaData);
}
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setInstanceMetaData(instanceMetaDataSet);
instanceGroup.setNodeCount(instanceMetaDataSet.size());
stack.setInstanceGroups(Set.of(instanceGroup));
return stack;
}
use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class FreeIpaInstanceHealthDetailsServiceTest method getStack.
private Stack getStack(Set<InstanceMetaData> instanceMetaData) {
Stack stack = new Stack();
stack.setResourceCrn(ENVIRONMENT_ID);
InstanceGroup instanceGroup = new InstanceGroup();
stack.getInstanceGroups().add(instanceGroup);
instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
instanceGroup.setInstanceMetaData(instanceMetaData);
return stack;
}
use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class FreeIpaRecommendationServiceTest method createStack.
private Stack createStack(String instanceType) {
Stack stack = new Stack();
stack.setCloudPlatform("AWS");
stack.setRegion("eu-central-1");
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setGroupName("master");
Template template = new Template();
template.setInstanceType(instanceType);
instanceGroup.setTemplate(template);
stack.getInstanceGroups().add(instanceGroup);
return stack;
}
use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class FreeIpaNodeUtilServiceTest method before.
@BeforeEach
void before() {
Template template = new Template();
template.setInstanceType(INSTANCE_TYPE);
InstanceGroup ig = new InstanceGroup();
ig.setTemplate(template);
ig.setGroupName(GROUP_NAME);
im = new InstanceMetaData();
im.setPrivateIp(PRIVATE_IP);
im.setInstanceId(INSTANCE_ID);
im.setInstanceGroup(ig);
im.setDiscoveryFQDN(FQDN);
}
use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class InstanceMetaDataServiceTest method testSaveInstanceAndGetUpdatedStackWhenNoAvailabilityZoneDataAvailable.
@Test
public void testSaveInstanceAndGetUpdatedStackWhenNoAvailabilityZoneDataAvailable() {
Stack stack = initializeStackWithInstanceGroup();
InstanceGroup instanceGroup = stack.getInstanceGroups().stream().findFirst().get();
FreeIpa freeIpa = new FreeIpa();
freeIpa.setHostname("ipa");
freeIpa.setDomain("dom");
when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
InstanceTemplate template = mock(InstanceTemplate.class);
when(template.getGroupName()).thenReturn(GROUP_NAME);
when(template.getPrivateId()).thenReturn(INSTANCE_PRIVATE_ID_3);
List<CloudInstance> cloudInstances = List.of(new CloudInstance(INSTANCE_ID_3, template, null, "subnet-1", "az1"));
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
when(cachedEnvironmentClientService.getByCrn(ENVIRONMENT_ID)).thenReturn(environmentResponse);
Map<String, String> subnetAzMap = Map.of();
when(multiAzCalculatorService.prepareSubnetAzMap(environmentResponse)).thenReturn(subnetAzMap);
Map<String, Integer> subnetUsage = Map.of();
when(multiAzCalculatorService.calculateCurrentSubnetUsage(subnetAzMap, instanceGroup)).thenReturn(subnetUsage);
Stack actualStack = underTest.saveInstanceAndGetUpdatedStack(stack, cloudInstances);
verify(instanceMetaDataRepository).save(any());
assertEquals(3, actualStack.getAllInstanceMetaDataList().size());
InstanceGroup actualInstanceGroup = actualStack.getInstanceGroups().stream().filter(ig -> GROUP_NAME.equals(ig.getGroupName())).findFirst().get();
InstanceMetaData instanceMetaData = actualInstanceGroup.getInstanceMetaData().stream().filter(im -> INSTANCE_PRIVATE_ID_3 == im.getPrivateId()).findFirst().get();
assertEquals("ipa3.dom", instanceMetaData.getDiscoveryFQDN());
verify(multiAzCalculatorService, times(0)).filterSubnetByLeastUsedAz(actualInstanceGroup, subnetAzMap);
verify(multiAzCalculatorService, times(0)).updateSubnetIdForSingleInstanceIfEligible(subnetAzMap, subnetUsage, instanceMetaData, actualInstanceGroup);
}
Aggregations