use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class MultiAzCalculatorServiceTest method testUpdateSubnetIdForSingleInstanceIfEligible.
@Test
public void testUpdateSubnetIdForSingleInstanceIfEligible() {
InstanceGroup instanceGroup = new InstanceGroup();
when(multiAzValidator.supportedForInstanceMetadataGeneration(instanceGroup)).thenReturn(Boolean.TRUE);
InstanceMetaData instanceMetaData = new InstanceMetaData();
underTest.updateSubnetIdForSingleInstanceIfEligible(SUBNET_AZ_PAIRS, new HashMap<>(Map.of(SUB_1, 2, SUB_2, 1)), instanceMetaData, instanceGroup);
assertEquals(SUB_2, instanceMetaData.getSubnetId());
}
use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class MultiAzCalculatorServiceTest method testCalculateCurrentSubnetUsage.
@Test
public void testCalculateCurrentSubnetUsage() {
InstanceGroupNetwork instanceGroupNetwork = new InstanceGroupNetwork();
instanceGroupNetwork.setAttributes(Json.silent(Map.of(SUBNET_IDS, List.of(SUB_1, SUB_2, "ONLYINIG"))));
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setInstanceGroupNetwork(instanceGroupNetwork);
InstanceMetaData deletedInstance = createInstanceMetadata(SUB_1);
deletedInstance.setInstanceStatus(InstanceStatus.TERMINATED);
instanceGroup.setInstanceMetaData(Set.of(createInstanceMetadata(SUB_1), createInstanceMetadata(SUB_1), createInstanceMetadata(SUB_2), createInstanceMetadata(null), createInstanceMetadata(" "), createInstanceMetadata("IGNORED"), deletedInstance));
Map<String, Integer> result = underTest.calculateCurrentSubnetUsage(SUBNET_AZ_PAIRS, instanceGroup);
assertEquals(2, result.size());
assertEquals(2, result.get(SUB_1));
assertEquals(1, result.get(SUB_2));
}
use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class MultiAzValidatorTest method testAwsWhenMultipleSubnetUsedShouldCauseValidationError.
@Test
public void testAwsWhenMultipleSubnetUsedShouldCauseValidationError() {
String variant = "AWS";
Set<InstanceGroup> instanceGroups = Set.of(instanceGroup(Set.of("subnet-123", "subnet-145")), instanceGroup(Set.of("subnet-123")));
BadRequestException actual = assertThrows(BadRequestException.class, () -> underTest.validateMultiAzForStack(variant, instanceGroups));
assertEquals("Multiple Availability Zone feature is not supported for AWS variant", actual.getMessage());
}
use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class MultiAzValidatorTest method testSupportedForInstanceMetadataGenerationWhenPlatformSupportedShouldReturnTrue.
@Test
public void testSupportedForInstanceMetadataGenerationWhenPlatformSupportedShouldReturnTrue() {
InstanceGroup instanceGroup = new InstanceGroup();
InstanceGroupNetwork instanceGroupNetwork = new InstanceGroupNetwork();
instanceGroupNetwork.setCloudPlatform(CloudPlatform.AWS.name());
instanceGroup.setInstanceGroupNetwork(instanceGroupNetwork);
boolean supported = underTest.supportedForInstanceMetadataGeneration(instanceGroup);
assertEquals(true, supported);
}
use of com.sequenceiq.freeipa.entity.InstanceGroup in project cloudbreak by hortonworks.
the class MultiAzValidatorTest method testNotSupportedForInstanceMetadataGenerationWhenPlatformSupportedShouldReturnFalse.
@Test
public void testNotSupportedForInstanceMetadataGenerationWhenPlatformSupportedShouldReturnFalse() {
InstanceGroup instanceGroup = new InstanceGroup();
InstanceGroupNetwork instanceGroupNetwork = new InstanceGroupNetwork();
instanceGroupNetwork.setCloudPlatform(CloudPlatform.AZURE.name());
instanceGroup.setInstanceGroupNetwork(instanceGroupNetwork);
boolean supported = underTest.supportedForInstanceMetadataGeneration(instanceGroup);
assertEquals(false, supported);
}
Aggregations