Search in sources :

Example 6 with InstanceGroup

use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.

the class StackStatusTest method setUp.

void setUp(int instanceCount) throws Exception {
    underTest.setLocalId(STACK_ID.toString());
    stack = new Stack();
    stack.setId(STACK_ID);
    StackStatus stackStatus = new StackStatus();
    stackStatus.setDetailedStackStatus(DetailedStackStatus.PROVISIONED);
    stack.setStackStatus(stackStatus);
    when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenReturn(stack);
    when(flowLogService.isOtherFlowRunning(STACK_ID)).thenReturn(false);
    InstanceGroup instanceGroup1 = new InstanceGroup();
    Set<InstanceMetaData> instances = new HashSet<>();
    if (instanceCount >= 1) {
        instances.add(createInstance(INSTANCE_1));
    }
    if (instanceCount >= 2) {
        instances.add(createInstance(INSTANCE_2));
    }
    if (instanceCount >= 3) {
        instances.add(createInstance(INSTANCE_3));
    }
    instanceGroup1.setInstanceMetaData(instances);
    stack.setInstanceGroups(Set.of(instanceGroup1));
    notTerminatedInstances = instances;
    when(instanceMetaDataService.findNotTerminatedForStack(STACK_ID)).thenReturn(notTerminatedInstances);
    rpcResponse = new RPCResponse<>();
    when(freeIpaInstanceHealthDetailsService.checkFreeIpaHealth(eq(stack), any())).thenReturn(rpcResponse);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) HashSet(java.util.HashSet)

Example 7 with InstanceGroup

use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.

the class FreeIpaStackHealthDetailsServiceTest method getDeletedStack.

private Stack getDeletedStack() {
    Stack stack = new Stack();
    stack.setResourceCrn(ENVIRONMENT_ID);
    InstanceGroup instanceGroup = new InstanceGroup();
    stack.getInstanceGroups().add(instanceGroup);
    instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
    InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceMetaData.setInstanceStatus(InstanceStatus.TERMINATED);
    instanceMetaData.setInstanceId(INSTANCE_ID1);
    instanceGroup.setInstanceMetaData(Sets.newHashSet(instanceMetaData));
    instanceMetaData.setDiscoveryFQDN(HOST1);
    return stack;
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Example 8 with InstanceGroup

use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.

the class FreeIpaStackHealthDetailsServiceTest method getStackTwoInstances.

private Stack getStackTwoInstances(InstanceMetaData im1, InstanceMetaData im2) {
    Stack stack = new Stack();
    stack.setResourceCrn(ENVIRONMENT_ID);
    InstanceGroup instanceGroup = new InstanceGroup();
    stack.getInstanceGroups().add(instanceGroup);
    instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
    instanceGroup.setInstanceMetaData(Set.of(im1, im2));
    return stack;
}
Also used : Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Example 9 with InstanceGroup

use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.

the class InstanceMetadataServiceComponentTest method saveInstanceAndGetUpdatedStack.

@Test
public void saveInstanceAndGetUpdatedStack() {
    DetailedEnvironmentResponse detailedEnvResponse = DetailedEnvironmentResponse.builder().withCrn(ENV_CRN).withNetwork(EnvironmentNetworkResponse.builder().withSubnetMetas(Map.of("sub1", cloudSubnet("az", "sub1"), "sub2", cloudSubnet("az", "sub2"), "sub3", cloudSubnet("az", "sub3"), "sub4", cloudSubnet("az1", "sub4"))).build()).build();
    Stack stack = new Stack();
    stack.setEnvironmentCrn(ENV_CRN);
    InstanceGroup workerInstanceGroup = new InstanceGroup();
    workerInstanceGroup.setGroupName("worker");
    InstanceGroupNetwork instanceGroupNetwork = new InstanceGroupNetwork();
    instanceGroupNetwork.setCloudPlatform("AWS");
    instanceGroupNetwork.setAttributes(new Json(Map.of(SUBNET_IDS, List.of("sub1", "sub2", "sub3", "sub4"))));
    workerInstanceGroup.setInstanceGroupNetwork(instanceGroupNetwork);
    stack.setInstanceGroups(Set.of(workerInstanceGroup));
    when(cachedEnvironmentClientService.getByCrn(ENV_CRN)).thenReturn(detailedEnvResponse);
    FreeIpa freeIpa = new FreeIpa();
    freeIpa.setHostname("hostname");
    freeIpa.setDomain("domain");
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    instanceMetaDataService.saveInstanceAndGetUpdatedStack(stack, cloudInstances(42));
    Map<String, List<InstanceMetaData>> groupBySub = workerInstanceGroup.getInstanceMetaDataSet().stream().collect(Collectors.groupingBy(InstanceMetaData::getSubnetId, Collectors.mapping(Function.identity(), Collectors.toList())));
    Map<String, List<InstanceMetaData>> groupByAz = workerInstanceGroup.getInstanceMetaDataSet().stream().collect(Collectors.groupingBy(InstanceMetaData::getAvailabilityZone, Collectors.mapping(Function.identity(), Collectors.toList())));
    Assertions.assertEquals(2, groupByAz.size());
    Assertions.assertEquals(21, groupByAz.get("az").size());
    Assertions.assertEquals(21, groupByAz.get("az1").size());
    Assertions.assertEquals(4, groupBySub.size());
    Assertions.assertEquals(7, groupBySub.get("sub1").size());
    Assertions.assertEquals(7, groupBySub.get("sub2").size());
    Assertions.assertEquals(7, groupBySub.get("sub3").size());
    Assertions.assertEquals(21, groupBySub.get("sub4").size());
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) ArrayList(java.util.ArrayList) List(java.util.List) Json(com.sequenceiq.cloudbreak.common.json.Json) InstanceGroupNetwork(com.sequenceiq.freeipa.entity.InstanceGroupNetwork) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with InstanceGroup

use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.

the class RepairInstancesServiceTest method init.

@BeforeAll
public static void init() {
    stack1 = new Stack();
    stack1.setResourceCrn(ENVIRONMENT_ID1);
    stack1.setEnvironmentCrn(ENVIRONMENT_ID1);
    InstanceGroup instanceGroup = new InstanceGroup();
    stack1.getInstanceGroups().add(instanceGroup);
    instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
    InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceGroup.setInstanceMetaData(Sets.newHashSet(instanceMetaData));
    instanceMetaData.setDiscoveryFQDN("host.domain");
    instanceMetaData.setInstanceId("instance_1");
    stack2 = new Stack();
    stack2.setResourceCrn(ENVIRONMENT_ID2);
    stack2.setEnvironmentCrn(ENVIRONMENT_ID2);
    instanceGroup = new InstanceGroup();
    stack2.getInstanceGroups().add(instanceGroup);
    instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
    instanceMetaData = new InstanceMetaData();
    instanceGroup.setInstanceMetaData(Sets.newHashSet(instanceMetaData));
    instanceMetaData.setDiscoveryFQDN("host1.domain");
    instanceMetaData.setInstanceId("instance_1");
    instanceMetaData = new InstanceMetaData();
    instanceGroup.getInstanceMetaData().add(instanceMetaData);
    instanceMetaData.setDiscoveryFQDN("host2.domain");
    instanceMetaData.setInstanceId("instance_2");
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) BeforeAll(org.junit.jupiter.api.BeforeAll)

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