Search in sources :

Example 11 with InstanceGroupRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestValidatorTest method validateShouldContainErrorsWhenThereAreZeroNodes.

@Test
void validateShouldContainErrorsWhenThereAreZeroNodes() {
    CreateFreeIpaRequest request = new CreateFreeIpaRequest();
    InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
    instanceGroupRequest.setNodeCount(0);
    request.setInstanceGroups(List.of(instanceGroupRequest));
    ValidationResult result = underTest.validate(request);
    assertThat(result.hasError()).isTrue();
}
Also used : InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with InstanceGroupRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestValidatorTest method validateShouldNotContainErrors.

@Test
void validateShouldNotContainErrors() {
    CreateFreeIpaRequest request = new CreateFreeIpaRequest();
    InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
    instanceGroupRequest.setNodeCount(1);
    request.setInstanceGroups(List.of(instanceGroupRequest));
    ValidationResult result = underTest.validate(request);
    assertThat(result.hasError()).isFalse();
}
Also used : InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with InstanceGroupRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestValidatorTest method validateShouldNotContainErrorsForHA.

@Test
void validateShouldNotContainErrorsForHA() {
    CreateFreeIpaRequest request = new CreateFreeIpaRequest();
    InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
    instanceGroupRequest.setNodeCount(2);
    request.setInstanceGroups(List.of(instanceGroupRequest));
    ValidationResult result = underTest.validate(request);
    assertThat(result.hasError()).isFalse();
}
Also used : InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with InstanceGroupRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestValidatorTest method validateShouldContainErrorsWhenThereAreTooManyInstanceGroups.

@Test
void validateShouldContainErrorsWhenThereAreTooManyInstanceGroups() {
    CreateFreeIpaRequest request = new CreateFreeIpaRequest();
    InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
    instanceGroupRequest.setNodeCount(1);
    request.setInstanceGroups(List.of(instanceGroupRequest, instanceGroupRequest));
    ValidationResult result = underTest.validate(request);
    assertThat(result.hasError()).isTrue();
}
Also used : InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with InstanceGroupRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest in project cloudbreak by hortonworks.

the class InstanceGroupRequestToInstanceGroupConverterTest method testConvertWithNullTemplate.

@Test
public void testConvertWithNullTemplate() {
    int nodeCount = 2;
    InstanceGroupRequest request = new InstanceGroupRequest();
    request.setName(NAME);
    request.setType(InstanceGroupType.MASTER);
    request.setNodeCount(nodeCount);
    Template template = mock(Template.class);
    SecurityGroupRequest securityGroupRequest = mock(SecurityGroupRequest.class);
    SecurityGroup securityGroup = mock(SecurityGroup.class);
    request.setSecurityGroup(securityGroupRequest);
    Stack stack = new Stack();
    stack.setAccountId(ACCOUNT_ID);
    stack.setCloudPlatform(MOCK.name());
    stack.setName(NAME);
    FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
    freeIpaServerRequest.setHostname(HOSTNAME);
    freeIpaServerRequest.setDomain(DOMAINNAME);
    NetworkRequest networkRequest = new NetworkRequest();
    DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
    // GIVEN
    given(defaultInstanceGroupProvider.createDefaultTemplate(eq(MOCK), eq(ACCOUNT_ID), eq(null), eq(null), eq(null))).willReturn(template);
    given(securityGroupConverter.convert(eq(securityGroupRequest))).willReturn(securityGroup);
    // WHEN
    InstanceGroup result = underTest.convert(request, networkRequest, ACCOUNT_ID, stack, freeIpaServerRequest, detailedEnvironmentResponse, createAndGetCloudArgsForIgCoverterMap(null, null, null));
    // THEN
    assertThat(result).isNotNull();
    assertThat(result.getGroupName()).isEqualTo(NAME);
    assertThat(result.getInstanceGroupType()).isEqualTo(InstanceGroupType.MASTER);
    assertThat(result.getSecurityGroup()).isEqualTo(securityGroup);
    assertThat(result.getNodeCount()).isEqualTo(nodeCount);
    assertThat(result.getInstanceMetaData().size()).isEqualTo(nodeCount);
    int i = 0;
    for (InstanceMetaData instanceMetaData : result.getInstanceMetaData()) {
        assertThat(instanceMetaData.getInstanceGroup()).isEqualTo(result);
        assertThat(instanceMetaData.getDiscoveryFQDN()).startsWith(HOSTNAME + i);
        i++;
    }
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) SecurityGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.SecurityGroupRequest) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) SecurityGroup(com.sequenceiq.freeipa.entity.SecurityGroup) FreeIpaServerRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest) Template(com.sequenceiq.freeipa.entity.Template) AzureInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate) AwsInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

Aggregations

InstanceGroupRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest)19 Test (org.junit.jupiter.api.Test)16 FreeIpaServerRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)12 NetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)11 CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)10 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)10 Stack (com.sequenceiq.freeipa.entity.Stack)10 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)9 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)9 Template (com.sequenceiq.freeipa.entity.Template)9 AzureInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate)8 InstanceTemplateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest)8 Json (com.sequenceiq.cloudbreak.common.json.Json)5 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)5 StackAuthenticationRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.StackAuthenticationRequest)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)3 HashMap (java.util.HashMap)3 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)2 Backup (com.sequenceiq.freeipa.api.model.Backup)2