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();
}
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();
}
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();
}
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();
}
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++;
}
}
Aggregations