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