Search in sources :

Example 11 with InstanceGroup

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;
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) Stack(com.sequenceiq.freeipa.entity.Stack) HashSet(java.util.HashSet) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Example 12 with InstanceGroup

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;
}
Also used : Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Example 13 with InstanceGroup

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;
}
Also used : Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Template(com.sequenceiq.freeipa.entity.Template)

Example 14 with InstanceGroup

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);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Template(com.sequenceiq.freeipa.entity.Template) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with InstanceGroup

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);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Test(org.junit.jupiter.api.Test)

Aggregations

InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)60 Stack (com.sequenceiq.freeipa.entity.Stack)32 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)31 Test (org.junit.jupiter.api.Test)30 Template (com.sequenceiq.freeipa.entity.Template)18 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)16 FreeIpaServerRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)11 Json (com.sequenceiq.cloudbreak.common.json.Json)10 InstanceGroupRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest)10 NetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)10 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)9 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)9 InstanceGroupNetwork (com.sequenceiq.freeipa.entity.InstanceGroupNetwork)9 HashSet (java.util.HashSet)9 AzureInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate)8 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)7 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)6 InstanceTemplateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest)6 HashMap (java.util.HashMap)6 CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)5