use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class ClusterUpscaleServiceTest method newHostGroup.
private HostGroup newHostGroup(String name, InstanceMetaData... instances) {
HostGroup hostGroup = new HostGroup();
hostGroup.setName(name);
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setInstanceMetaData(Set.of(instances));
hostGroup.setInstanceGroup(instanceGroup);
return hostGroup;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class StackCreatorServiceTest method testFillInstanceMetadataWhenManager.
@Test
public void testFillInstanceMetadataWhenManager() {
Stack stack = new Stack();
InstanceGroup managerGroup = getARequestGroup("manager", 1, InstanceGroupType.GATEWAY);
InstanceGroup gatewayGroup = getARequestGroup("gateway", 2, InstanceGroupType.CORE);
InstanceGroup computeGroup = getARequestGroup("compute", 0, InstanceGroupType.CORE);
InstanceGroup workerGroup = getARequestGroup("worker", 3, InstanceGroupType.CORE);
InstanceGroup masterGroup = getARequestGroup("master", 2, InstanceGroupType.CORE);
stack.setInstanceGroups(Set.of(masterGroup, workerGroup, computeGroup, managerGroup, gatewayGroup));
when(multiAzCalculatorService.prepareSubnetAzMap(environmentResponse)).thenReturn(Map.of());
doNothing().when(multiAzCalculatorService).calculateByRoundRobin(anyMap(), any(InstanceGroup.class));
underTest.fillInstanceMetadata(environmentResponse, stack);
Map<String, Set<InstanceMetaData>> hostGroupInstances = stack.getInstanceGroups().stream().collect(Collectors.toMap(InstanceGroup::getGroupName, InstanceGroup::getAllInstanceMetaData));
long privateIdStart = 0L;
validateInstanceMetadataPrivateId("manager", 1, privateIdStart, hostGroupInstances.get("manager"));
validateInstanceMetadataSubnetAndAvailabilityZoneAndRackId("manager", 1, hostGroupInstances.get("manager"), null, null, null);
privateIdStart = 1L;
validateInstanceMetadataPrivateId("compute", 0, privateIdStart, hostGroupInstances.get("compute"));
validateInstanceMetadataSubnetAndAvailabilityZoneAndRackId("compute", 0, hostGroupInstances.get("compute"), null, null, null);
privateIdStart = 1L;
validateInstanceMetadataPrivateId("gateway", 2, privateIdStart, hostGroupInstances.get("gateway"));
validateInstanceMetadataSubnetAndAvailabilityZoneAndRackId("gateway", 2, hostGroupInstances.get("gateway"), null, null, null);
privateIdStart = 3L;
validateInstanceMetadataPrivateId("master", 2, privateIdStart, hostGroupInstances.get("master"));
validateInstanceMetadataSubnetAndAvailabilityZoneAndRackId("master", 2, hostGroupInstances.get("master"), null, null, null);
privateIdStart = 5L;
validateInstanceMetadataPrivateId("worker", 3, privateIdStart, hostGroupInstances.get("worker"));
validateInstanceMetadataSubnetAndAvailabilityZoneAndRackId("worker", 3, hostGroupInstances.get("worker"), null, null, null);
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class StackCreatorServiceTest method fillInstanceMetadataTestWhenSubnetAndAvailabilityZoneAndRackIdAndRoundRobin.
@ParameterizedTest(name = "{0}")
@MethodSource("fillInstanceMetadataTestWhenSubnetAndAvailabilityZoneAndRackIdAndRoundRobinDataProvider")
public void fillInstanceMetadataTestWhenSubnetAndAvailabilityZoneAndRackIdAndRoundRobin(String testCaseName, String subnetId, String availabilityZone) {
Stack stack = new Stack();
InstanceGroup workerGroup = getARequestGroup("worker", 3, InstanceGroupType.CORE);
stack.setInstanceGroups(Set.of(workerGroup));
Map<String, String> subnetAzPairs = Map.of();
when(multiAzCalculatorService.prepareSubnetAzMap(environmentResponse)).thenReturn(subnetAzPairs);
doAnswer(invocation -> {
InstanceGroup instanceGroup = invocation.getArgument(1, InstanceGroup.class);
instanceGroup.getAllInstanceMetaData().forEach(instanceMetaData -> {
instanceMetaData.setSubnetId(subnetId);
instanceMetaData.setAvailabilityZone(availabilityZone);
});
return null;
}).when(multiAzCalculatorService).calculateByRoundRobin(subnetAzPairs, workerGroup);
when(multiAzCalculatorService.determineRackId(subnetId, availabilityZone)).thenReturn("/fooRack");
underTest.fillInstanceMetadata(environmentResponse, stack);
Map<String, Set<InstanceMetaData>> hostGroupInstances = stack.getInstanceGroups().stream().collect(Collectors.toMap(InstanceGroup::getGroupName, InstanceGroup::getAllInstanceMetaData));
long privateIdStart = 0L;
validateInstanceMetadataPrivateId("worker", 3, privateIdStart, hostGroupInstances.get("worker"));
validateInstanceMetadataSubnetAndAvailabilityZoneAndRackId("worker", 3, hostGroupInstances.get("worker"), subnetId, availabilityZone, "/fooRack");
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class StackCreatorServiceTest method fillInstanceMetadataTestWhenSubnetAndAvailabilityZoneAndRackIdAndStackFallback.
@Test
public void fillInstanceMetadataTestWhenSubnetAndAvailabilityZoneAndRackIdAndStackFallback() {
Stack stack = new Stack();
InstanceGroup workerGroup = getARequestGroup("worker", 3, InstanceGroupType.CORE);
stack.setInstanceGroups(Set.of(workerGroup));
Network network = new Network();
network.setAttributes(Json.silent(Map.of("subnetId", "subnet-1")));
stack.setNetwork(network);
Map<String, String> subnetAzPairs = Map.of("subnet-1", "az-1");
when(multiAzCalculatorService.prepareSubnetAzMap(environmentResponse)).thenReturn(subnetAzPairs);
doNothing().when(multiAzCalculatorService).calculateByRoundRobin(subnetAzPairs, workerGroup);
when(multiAzCalculatorService.determineRackId("subnet-1", "az-1")).thenReturn("/fooRack");
underTest.fillInstanceMetadata(environmentResponse, stack);
Map<String, Set<InstanceMetaData>> hostGroupInstances = stack.getInstanceGroups().stream().collect(Collectors.toMap(InstanceGroup::getGroupName, InstanceGroup::getAllInstanceMetaData));
long privateIdStart = 0L;
validateInstanceMetadataPrivateId("worker", 3, privateIdStart, hostGroupInstances.get("worker"));
validateInstanceMetadataSubnetAndAvailabilityZoneAndRackId("worker", 3, hostGroupInstances.get("worker"), "subnet-1", "az-1", "/fooRack");
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class StopStartDownscaleDecommissionViaCMHandlerTest method getInstancesToDecommission.
private List<InstanceMetaData> getInstancesToDecommission(int count) {
List<InstanceMetaData> instances = new ArrayList<>(count);
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setGroupName(INSTANCE_GROUP_NAME);
for (int i = 0; i < count; i++) {
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setInstanceId(INSTANCE_ID_PREFIX + i);
instanceMetaData.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
instanceMetaData.setInstanceGroup(instanceGroup);
instanceMetaData.setDiscoveryFQDN(INSTANCE_ID_PREFIX + i);
instanceMetaData.setPrivateId((long) i);
instances.add(instanceMetaData);
}
return instances;
}
Aggregations