Search in sources :

Example 41 with InstanceGroup

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());
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 42 with InstanceGroup

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));
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceGroupNetwork(com.sequenceiq.freeipa.entity.InstanceGroupNetwork) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 43 with InstanceGroup

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());
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 44 with InstanceGroup

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);
}
Also used : InstanceGroupNetwork(com.sequenceiq.freeipa.entity.InstanceGroupNetwork) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 45 with InstanceGroup

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);
}
Also used : InstanceGroupNetwork(com.sequenceiq.freeipa.entity.InstanceGroupNetwork) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

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