use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class StackV4RequestToGatewayConverter method convert.
public Gateway convert(StackV4Request source) {
Gateway gateway = new Gateway();
GatewayV4Request gatewayJson = source.getCluster().getGateway();
ValidationResult validationResult = gatewayJsonValidator.validate(gatewayJson);
if (validationResult.hasError()) {
throw new BadRequestException(validationResult.getFormattedErrors());
}
convertUtil.setBasicProperties(gatewayJson, gateway);
convertUtil.setTopologies(gatewayJson, gateway);
convertUtil.setGatewayPathAndSsoProvider(gatewayJson, gateway);
return gateway;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class GatewayTopologyV4RequestValidatorTest method testWithInvalidKnoxServiceAndNoTopologyName.
@Test
public void testWithInvalidKnoxServiceAndNoTopologyName() {
String invalidService = "INVALID_SERVICE";
GatewayTopologyV4Request gatewayTopologyJson = new GatewayTopologyV4Request();
gatewayTopologyJson.setExposedServices(Collections.singletonList(invalidService));
when(exposedServiceListValidator.validate(anyList())).thenReturn(new ValidationResultBuilder().error(invalidService).build());
ValidationResult result = underTest.validate(gatewayTopologyJson);
assertEquals(State.ERROR, result.getState());
assertEquals(2L, result.getErrors().size());
assertTrue(result.getErrors().get(0).contains(invalidService));
assertTrue(result.getErrors().get(1).contains("topologyName must be set in gateway topology."));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class GatewayV4RequestValidatorTest method testValidationWithMissingTopology.
@Test
public void testValidationWithMissingTopology() {
GatewayV4Request gatewayJson = new GatewayV4Request();
ValidationResult result = underTest.validate(gatewayJson);
assertEquals(State.ERROR, result.getState());
assertTrue(result.getFormattedErrors().contains("No topology is defined in gateway request."));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class HostMetadataSetupTest method testSetupNewHostMetadataWithMultiNonGatewayInstances.
@Test
@DisplayName("when multiple non-gateway instances are repaired and scaled we shouldn't make any changes")
public void testSetupNewHostMetadataWithMultiNonGatewayInstances() throws CloudbreakException, CloudbreakOrchestratorException {
Stack stack = mock(Stack.class);
InstanceMetaData im1 = createInstanceMetadata("id1", InstanceMetadataType.CORE, 1L, "10.0.0.1", "host1", false);
InstanceMetaData im2 = createInstanceMetadata("id2", InstanceMetadataType.CORE, 2L, "10.0.0.2", "host2", false);
when(instanceMetaDataService.getNotDeletedAndNotZombieInstanceMetadataByStackId(STACK_ID)).thenReturn(Set.of(im1, im2));
when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenReturn(stack);
when(hostOrchestrator.getMembers(any(), any())).thenReturn(Map.of("10.0.0.1", "host1", "10.0.0.2", "host2"));
hostMetadataSetup.setupNewHostMetadata(STACK_ID, List.of("10.0.0.1", "10.0.0.2"));
verify(instanceMetaDataService, times(0)).getLastTerminatedPrimaryGatewayInstanceMetadata(STACK_ID);
verify(instanceMetaDataService, times(1)).saveAll(instanceMetadataCaptor.capture());
Set<InstanceMetaData> actualIm = instanceMetadataCaptor.getValue();
InstanceMetaData expectedIm1 = createInstanceMetadata("id1", InstanceMetadataType.CORE, 1L, "10.0.0.1", "host1", false);
InstanceMetaData expectedIm2 = createInstanceMetadata("id2", InstanceMetadataType.CORE, 2L, "10.0.0.2", "host2", false);
assertMetadataEquals(expectedIm1, actualIm.stream().filter(im -> im.getPrivateId() == 1L).findFirst().get());
assertMetadataEquals(expectedIm2, actualIm.stream().filter(im -> im.getPrivateId() == 2L).findFirst().get());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class StackDecoratorTest method setUp.
@Before
public void setUp() {
String credentialName = "credentialName";
MockitoAnnotations.initMocks(this);
subject = new Stack();
subject.setEnvironmentCrn("envCrn");
Set<InstanceGroup> instanceGroups = createInstanceGroups(GATEWAY);
subject.setInstanceGroups(instanceGroups);
Cluster cluster = getCluster(instanceGroups);
subject.setCluster(cluster);
subject.setCloudPlatform("AZURE");
subject.setParameters(new HashMap<>());
when(cloudParameterCache.getPlatformParameters()).thenReturn(platformParametersMap);
when(platformParametersMap.get(any(Platform.class))).thenReturn(pps);
when(pps.specialParameters()).thenReturn(specialParameters);
when(specialParameters.getSpecialParameters()).thenReturn(specialParametersMap);
when(specialParametersMap.get(anyString())).thenReturn(false);
when(cloudParameterService.getOrchestrators()).thenReturn(platformOrchestrators);
when(platformOrchestrators.getDefaults()).thenReturn(defaultOrchestrator);
when(defaultOrchestrator.get(any(Platform.class))).thenReturn(orchestrator);
when(instanceGroupToInstanceGroupParameterRequestConverter.convert(any(InstanceGroup.class))).thenReturn(instanceGroupParameterRequest);
when(request.getCluster()).thenReturn(clusterRequest);
when(environmentSettingsRequest.getCredentialName()).thenReturn(credentialName);
when(sharedServiceValidator.checkSharedServiceStackRequirements(any(StackV4Request.class), any(Workspace.class))).thenReturn(validationResult);
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCredential(credentialResponse);
CompactRegionResponse crr = new CompactRegionResponse();
crr.setNames(Lists.newArrayList("region"));
environmentResponse.setRegions(crr);
EnvironmentNetworkResponse enr = new EnvironmentNetworkResponse();
Map<String, CloudSubnet> subnetmetas = Maps.newHashMap("subnet", new CloudSubnet("id", "name", "availabilityzone", "cidr"));
enr.setSubnetMetas(subnetmetas);
environmentResponse.setNetwork(enr);
environmentResponse.setAzure(AzureEnvironmentParameters.builder().withAzureResourceGroup(AzureResourceGroup.builder().withResourceGroupUsage(ResourceGroupUsage.SINGLE).withName("resource-group").build()).build());
when(request.getCloudPlatform()).thenReturn(CloudPlatform.AZURE);
when(environmentClientService.getByName(anyString())).thenReturn(environmentResponse);
when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
Credential credential = Credential.builder().cloudPlatform(CloudPlatform.MOCK.name()).build();
when(credentialClientService.getByCrn(anyString())).thenReturn(credential);
when(credentialClientService.getByName(anyString())).thenReturn(credential);
when(credentialConverter.convert(credentialResponse)).thenReturn(credential);
ExtendedCloudCredential extendedCloudCredential = mock(ExtendedCloudCredential.class);
when(extendedCloudCredentialConverter.convert(credential)).thenReturn(extendedCloudCredential);
}
Aggregations