use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class EmbeddedDatabaseServiceTest method createStack.
private Stack createStack(int volumeCount) {
Stack stack = new Stack();
InstanceGroup masterGroup = new InstanceGroup();
masterGroup.setInstanceGroupType(InstanceGroupType.GATEWAY);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setInstanceGroup(masterGroup);
instanceMetaData.setInstanceMetadataType(InstanceMetadataType.GATEWAY_PRIMARY);
masterGroup.setInstanceMetaData(Set.of(instanceMetaData));
Template template = new Template();
VolumeTemplate volumeTemplate = new VolumeTemplate();
volumeTemplate.setVolumeCount(volumeCount);
volumeTemplate.setUsageType(VolumeUsageType.DATABASE);
template.setVolumeTemplates(Set.of(volumeTemplate));
masterGroup.setTemplate(template);
stack.setInstanceGroups(Set.of(masterGroup));
stack.setCloudPlatform(CLOUDPLATFORM);
return stack;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class EmbeddedDatabaseServiceTest method createStackWithoutTemplate.
private Stack createStackWithoutTemplate() {
Stack stack = new Stack();
InstanceGroup masterGroup = new InstanceGroup();
masterGroup.setInstanceGroupType(InstanceGroupType.GATEWAY);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setInstanceGroup(masterGroup);
instanceMetaData.setInstanceMetadataType(InstanceMetadataType.GATEWAY_PRIMARY);
masterGroup.setInstanceMetaData(Set.of(instanceMetaData));
stack.setInstanceGroups(Set.of(masterGroup));
return stack;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class TelemetryAgentServiceTest method createStack.
private Stack createStack() {
Stack stack = new Stack();
stack.setId(1L);
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setInstanceMetaData(createInstanceMetadataSet());
instanceGroup.setTemplate(new Template());
stack.setInstanceGroups(Set.of(instanceGroup));
return stack;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class StackDecoratorTest method createInstanceGroups.
private Set<InstanceGroup> createInstanceGroups(InstanceGroupType... types) {
Set<InstanceGroup> groups = new LinkedHashSet<>(types.length);
int i = 0;
for (InstanceGroupType type : types) {
InstanceGroup group = mock(InstanceGroup.class);
when(group.getInstanceGroupType()).thenReturn(type);
when(group.getGroupName()).thenReturn("name" + i);
when(group.getNodeCount()).thenReturn(2);
groups.add(group);
}
return groups;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class MultiAzCalculatorServiceTest method testSubnetDistributionForWholeInstanceGroupWhenDeletedInstances.
@ParameterizedTest(name = "testSubnetDistributionForWholeInstanceGroupWhenDeletedInstances " + "with {0} platform when {1} subnets and {2} instances should result in {3} subnet counts")
@MethodSource("testSubnetDistributionForWholeInstanceGroupData")
public void testSubnetDistributionForWholeInstanceGroupWhenDeletedInstances(CloudPlatform cloudPlatform, int subnetCount, int instanceCount, List<Long> expectedCounts, boolean supported) {
if (supported) {
when(multiAzValidator.supportedForInstanceMetadataGeneration(any(InstanceGroup.class))).thenReturn(true);
}
InstanceGroup instanceGroup = instanceGroup(cloudPlatform, instanceCount, subnetCount);
Set<InstanceMetaData> deletedInstancesWithPrepopulatedSubnetId = new HashSet<>();
String subnetIdForDeletedInstances = cloudSubnetName(0);
String availabilityZoneForDeletedInstances = cloudSubnetAz(0);
if (subnetCount > 0) {
InstanceMetaData instanceWithTerminationDate = instanceMetaData(instanceCount, subnetIdForDeletedInstances, availabilityZoneForDeletedInstances, null);
instanceWithTerminationDate.setTerminationDate(1234L);
deletedInstancesWithPrepopulatedSubnetId.add(instanceWithTerminationDate);
deletedInstancesWithPrepopulatedSubnetId.add(instanceMetaData(instanceCount + 1, subnetIdForDeletedInstances, availabilityZoneForDeletedInstances, InstanceStatus.TERMINATED));
deletedInstancesWithPrepopulatedSubnetId.add(instanceMetaData(instanceCount + 2, subnetIdForDeletedInstances, availabilityZoneForDeletedInstances, InstanceStatus.DELETED_BY_PROVIDER));
deletedInstancesWithPrepopulatedSubnetId.add(instanceMetaData(instanceCount + 3, subnetIdForDeletedInstances, availabilityZoneForDeletedInstances, InstanceStatus.DELETED_ON_PROVIDER_SIDE));
}
instanceGroup.getAllInstanceMetaData().addAll(deletedInstancesWithPrepopulatedSubnetId);
underTest.calculateByRoundRobin(subnetAzPairs(subnetCount), instanceGroup);
List<Long> actualCounts = new ArrayList<>();
for (int i = 0; i < subnetCount; i++) {
int finalI = i;
actualCounts.add(instanceGroup.getAllInstanceMetaData().stream().filter(instance -> instance.getSubnetId().equals(cloudSubnetName(finalI))).filter(instance -> !deletedInstancesWithPrepopulatedSubnetId.contains(instance)).count());
}
Collections.sort(expectedCounts);
Collections.sort(actualCounts);
Assertions.assertEquals(expectedCounts, actualCounts);
deletedInstancesWithPrepopulatedSubnetId.forEach(instance -> {
assertThat(instance.getSubnetId()).isEqualTo(subnetIdForDeletedInstances);
assertThat(instance.getAvailabilityZone()).isEqualTo(availabilityZoneForDeletedInstances);
});
}
Aggregations