use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackOperations method post.
public StackV4Response post(Long workspaceId, CloudbreakUser cloudbreakUser, @Valid StackV4Request request, boolean distroxRequest) {
LOGGER.info("Post for Stack in workspace {}.", workspaceId);
User user = userService.getOrCreate(cloudbreakUser);
LOGGER.info("Cloudbreak user for the requested stack is {}.", cloudbreakUser);
Workspace workspace = workspaceService.get(workspaceId, user);
StackV4Response stackV4Response = stackCommonService.createInWorkspace(request, user, workspace, distroxRequest);
LOGGER.info("Adding environment name and credential to the response.");
environmentServiceDecorator.prepareEnvironmentAndCredentialName(stackV4Response);
LOGGER.info("Adding SDX CRN and name to the response.");
sdxServiceDecorator.prepareSdxAttributes(stackV4Response);
return stackV4Response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverterTest method testConvert.
@Test
public void testConvert() throws CloudbreakImageNotFoundException {
Stack source = getSource();
// GIVEN
given(imageService.getImage(source.getId())).willReturn(mock(Image.class));
given(imageToStackImageV4ResponseConverter.convert(any(Image.class))).willReturn(new StackImageV4Response());
given(stackAuthenticationToStackAuthenticationV4ResponseConverter.convert(any(StackAuthentication.class))).willReturn(new StackAuthenticationV4Response());
given(stackToCustomDomainsSettingsV4Response.convert(any())).willReturn(new CustomDomainSettingsV4Response());
given(clusterToClusterV4ResponseConverter.convert(any())).willReturn(new ClusterV4Response());
given(networkToNetworkV4ResponseConverter.convert(any())).willReturn(new NetworkV4Response());
given(workspaceToWorkspaceResourceV4ResponseConverter.convert(any())).willReturn(new WorkspaceResourceV4Response());
given(cloudbreakDetailsToCloudbreakDetailsV4ResponseConverter.convert(any())).willReturn(new CloudbreakDetailsV4Response());
given(stackToPlacementSettingsV4ResponseConverter.convert(any())).willReturn(new PlacementSettingsV4Response());
given(telemetryConverter.convert(any())).willReturn(new TelemetryResponse());
given(instanceGroupToInstanceGroupV4ResponseConverter.convert(any())).willReturn(new InstanceGroupV4Response());
given(databaseAvailabilityTypeToDatabaseResponseConverter.convert(any(), any())).willReturn(new DatabaseResponse());
// WHEN
StackV4Response result = underTest.convert(source);
// THEN
assertAllFieldsNotNull(result, Arrays.asList("gcp", "mock", "openstack", "aws", "yarn", "azure", "environmentName", "credentialName", "credentialCrn", "telemetry", "flowIdentifier", "loadBalancers"));
verify(restRequestThreadLocalService).setWorkspace(source.getWorkspace());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxUpgradeServiceTest method testUpdateRuntimeVersionFromCloudbreakWithoutCDHVersion.
@Test
@DisplayName("Test if the runtime cannot be updated when there is no CDP version specified")
public void testUpdateRuntimeVersionFromCloudbreakWithoutCDHVersion() {
when(sdxService.getById(1L)).thenReturn(sdxCluster);
StackV4Response stackV4Response = getStackV4Response();
ClouderaManagerProductV4Response cdp = new ClouderaManagerProductV4Response();
cdp.setName("CDH");
stackV4Response.getCluster().getCm().setProducts(List.of(cdp));
when(stackV4Endpoint.get(eq(0L), eq("test-sdx-cluster"), eq(Set.of()), anyString())).thenReturn(stackV4Response);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
underTest.updateRuntimeVersionFromCloudbreak(1L);
verify(sdxService, times(0)).save(any());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxUpgradeServiceTest method testUpdateRuntimeVersionFromCloudbreakWithoutCDH.
@Test
@DisplayName("Test if the runtime cannot be updated when there is no CDH product installed")
public void testUpdateRuntimeVersionFromCloudbreakWithoutCDH() {
when(sdxService.getById(1L)).thenReturn(sdxCluster);
StackV4Response stackV4Response = getStackV4Response();
ClouderaManagerProductV4Response spark3 = new ClouderaManagerProductV4Response();
spark3.setName("SPARK3");
spark3.setVersion("3.0.0.2.99.7110.0-18-1.p0.3525631");
stackV4Response.getCluster().getCm().setProducts(List.of(spark3));
when(stackV4Endpoint.get(eq(0L), eq("test-sdx-cluster"), eq(Set.of()), anyString())).thenReturn(stackV4Response);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
underTest.updateRuntimeVersionFromCloudbreak(1L);
verify(sdxService, times(0)).save(any());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxUpgradeServiceTest method testUpdateRuntimeVersionFromCloudbreakWithoutCluster.
@Test
@DisplayName("Test if the runtime cannot be updated when there is no cluster")
public void testUpdateRuntimeVersionFromCloudbreakWithoutCluster() {
when(sdxService.getById(1L)).thenReturn(sdxCluster);
StackV4Response stackV4Response = getStackV4Response();
stackV4Response.setCluster(null);
when(stackV4Endpoint.get(eq(0L), eq("test-sdx-cluster"), eq(Set.of()), anyString())).thenReturn(stackV4Response);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
underTest.updateRuntimeVersionFromCloudbreak(1L);
verify(sdxService, times(0)).save(any());
}
Aggregations