Search in sources :

Example 1 with ClouderaManagerProductV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response 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());
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) ClouderaManagerProductV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with ClouderaManagerProductV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response 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());
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) ClouderaManagerProductV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with ClouderaManagerProductV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response in project cloudbreak by hortonworks.

the class SdxServiceTest method testUpdateRuntimeVersionFromStackResponse.

@Test
public void testUpdateRuntimeVersionFromStackResponse() {
    SdxCluster sdxCluster = getSdxCluster();
    StackV4Response stackV4Response = new StackV4Response();
    ClusterV4Response clusterV4Response = new ClusterV4Response();
    ClouderaManagerV4Response cm = new ClouderaManagerV4Response();
    ClouderaManagerProductV4Response cdpResponse = new ClouderaManagerProductV4Response();
    cdpResponse.setName("CDH");
    cdpResponse.setVersion("7.2.1-1.32.123-123");
    cm.setProducts(Collections.singletonList(cdpResponse));
    clusterV4Response.setCm(cm);
    stackV4Response.setCluster(clusterV4Response);
    underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
    ArgumentCaptor<SdxCluster> sdxClusterArgumentCaptor = ArgumentCaptor.forClass(SdxCluster.class);
    verify(sdxClusterRepository, times(1)).save(sdxClusterArgumentCaptor.capture());
    assertEquals("7.2.1", sdxClusterArgumentCaptor.getValue().getRuntime());
    cdpResponse.setVersion("7.1.0");
    underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
    verify(sdxClusterRepository, times(2)).save(sdxClusterArgumentCaptor.capture());
    assertEquals("7.1.0", sdxClusterArgumentCaptor.getValue().getRuntime());
    cdpResponse.setVersion("7.0.2-valami");
    underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response);
    verify(sdxClusterRepository, times(3)).save(sdxClusterArgumentCaptor.capture());
    assertEquals("7.0.2", sdxClusterArgumentCaptor.getValue().getRuntime());
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) ClouderaManagerProductV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) ClouderaManagerV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 4 with ClouderaManagerProductV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response in project cloudbreak by hortonworks.

the class SdxUpgradeServiceTest method getStackV4Response.

private StackV4Response getStackV4Response() {
    ClouderaManagerProductV4Response cdp = new ClouderaManagerProductV4Response();
    cdp.setName("CDH");
    cdp.setVersion("7.2.1-1.cdh7.2.0.p0.3758356");
    ClouderaManagerProductV4Response cfm = new ClouderaManagerProductV4Response();
    cfm.setName("CFM");
    cfm.setVersion("2.0.0.0");
    ClouderaManagerProductV4Response spark3 = new ClouderaManagerProductV4Response();
    spark3.setName("SPARK3");
    spark3.setVersion("3.0.0.2.99.7110.0-18-1.p0.3525631");
    ClouderaManagerV4Response cm = new ClouderaManagerV4Response();
    cm.setProducts(List.of(cdp, cfm, spark3));
    ClusterV4Response clusterV4Response = new ClusterV4Response();
    clusterV4Response.setCm(cm);
    StackV4Response stackV4Response = new StackV4Response();
    stackV4Response.setName("test-sdx-cluster");
    stackV4Response.setCluster(clusterV4Response);
    return stackV4Response;
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) ClouderaManagerProductV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) ClouderaManagerV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response)

Example 5 with ClouderaManagerProductV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response in project cloudbreak by hortonworks.

the class SdxService method getCdpVersion.

private Optional<String> getCdpVersion(StackV4Response stack) {
    String stackName = stack.getName();
    ClusterV4Response cluster = stack.getCluster();
    if (cluster != null) {
        ClouderaManagerV4Response cm = cluster.getCm();
        if (cm != null) {
            LOGGER.info("Repository details are available for cluster: {}: {}", stackName, cm);
            List<ClouderaManagerProductV4Response> products = cm.getProducts();
            if (products != null && !products.isEmpty()) {
                Optional<ClouderaManagerProductV4Response> cdpOpt = products.stream().filter(p -> "CDH".equals(p.getName())).findFirst();
                if (cdpOpt.isPresent()) {
                    return getRuntimeVersionFromCdpVersion(cdpOpt.get().getVersion());
                }
            }
        }
    }
    return Optional.empty();
}
Also used : SecurityRuleV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.util.requests.SecurityRuleV4Request) AttachRecipeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.AttachRecipeV4Response) RangerRazEnabledV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.RangerRazEnabledV4Response) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException) StringUtils(org.apache.commons.lang3.StringUtils) AwsInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters) AwsInstanceTemplateV4SpotParameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4SpotParameters) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) Matcher(java.util.regex.Matcher) Pair(org.apache.commons.lang3.tuple.Pair) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) EnumSet(java.util.EnumSet) AzureStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters) SdxRecipe(com.sequenceiq.sdx.api.model.SdxRecipe) UpdateRecipesV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.UpdateRecipesV4Response) Set(java.util.Set) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) VersionComparator(com.sequenceiq.cloudbreak.util.VersionComparator) SdxClusterRequest(com.sequenceiq.sdx.api.model.SdxClusterRequest) Stream(java.util.stream.Stream) CertExpirationState(com.sequenceiq.common.api.type.CertExpirationState) SdxAzureBase(com.sequenceiq.sdx.api.model.SdxAzureBase) SdxClusterResizeRequest(com.sequenceiq.sdx.api.model.SdxClusterResizeRequest) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) OwnerAssignmentService(com.sequenceiq.authorization.service.OwnerAssignmentService) CollectionUtils(org.apache.commons.collections4.CollectionUtils) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) ArrayList(java.util.ArrayList) CUSTOM(com.sequenceiq.sdx.api.model.SdxClusterShape.CUSTOM) LinkedHashMap(java.util.LinkedHashMap) Value(org.springframework.beans.factory.annotation.Value) AWS(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AWS) CrnResourceDescriptor(com.sequenceiq.cloudbreak.auth.crn.CrnResourceDescriptor) SecurityGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.securitygroup.SecurityGroupV4Request) StackResponseEntries(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.StackResponseEntries) EnumUtils(org.apache.commons.lang3.EnumUtils) Service(org.springframework.stereotype.Service) CustomDomainSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.customdomain.CustomDomainSettingsV4Request) InstanceTemplateV4Base(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceTemplateV4Base) LinkedHashSet(java.util.LinkedHashSet) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) InstanceGroupV4Base(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceGroupV4Base) ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) SdxCustomClusterRequest(com.sequenceiq.sdx.api.model.SdxCustomClusterRequest) IOException(java.io.IOException) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) RecipeV4Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v4.recipes.RecipeV4Endpoint) DetachRecipeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.recipe.DetachRecipeV4Request) FileSystemType(com.sequenceiq.common.model.FileSystemType) ClouderaManagerProductV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) CompactViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.common.CompactViewV4Response) LoggerFactory(org.slf4j.LoggerFactory) FlowCancelService(com.sequenceiq.flow.service.FlowCancelService) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) CloudbreakInternalCrnClient(com.sequenceiq.cloudbreak.client.CloudbreakInternalCrnClient) AuthorizationResourceType(com.sequenceiq.authorization.resource.AuthorizationResourceType) SdxCloudStorageRequest(com.sequenceiq.sdx.api.model.SdxCloudStorageRequest) HierarchyAuthResourcePropertyProvider(com.sequenceiq.authorization.service.HierarchyAuthResourcePropertyProvider) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) ResourceWithId(com.sequenceiq.authorization.service.list.ResourceWithId) PayloadContext(com.sequenceiq.cloudbreak.common.event.PayloadContext) StackV4Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint) RecipeViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.recipes.responses.RecipeViewV4Responses) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) Collection(java.util.Collection) CDPConfigService(com.sequenceiq.datalake.configuration.CDPConfigService) Collectors(java.util.stream.Collectors) SdxAwsSpotParameters(com.sequenceiq.sdx.api.model.SdxAwsSpotParameters) RegionAwareInternalCrnGeneratorFactory(com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory) Json(com.sequenceiq.cloudbreak.common.json.Json) SdxStatusService(com.sequenceiq.datalake.service.sdx.status.SdxStatusService) List(java.util.List) AttachRecipeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.recipe.AttachRecipeV4Request) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) SdxInstanceGroupRequest(com.sequenceiq.sdx.api.model.SdxInstanceGroupRequest) Clock(com.sequenceiq.cloudbreak.common.service.Clock) ClouderaManagerV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response) DatalakeStatusEnum(com.sequenceiq.datalake.entity.DatalakeStatusEnum) SdxClusterShape(com.sequenceiq.sdx.api.model.SdxClusterShape) SdxReactorFlowManager(com.sequenceiq.datalake.flow.SdxReactorFlowManager) ImageCatalogService(com.sequenceiq.datalake.service.imagecatalog.ImageCatalogService) MDCBuilder(com.sequenceiq.cloudbreak.logger.MDCBuilder) HashMap(java.util.HashMap) SdxClusterRepository(com.sequenceiq.datalake.repository.SdxClusterRepository) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) HashSet(java.util.HashSet) Inject(javax.inject.Inject) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Nonnull(javax.annotation.Nonnull) NotFoundException.notFound(com.sequenceiq.cloudbreak.common.exception.NotFoundException.notFound) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) Logger(org.slf4j.Logger) Benchmark.measure(com.sequenceiq.cloudbreak.util.Benchmark.measure) PayloadContextProvider(com.sequenceiq.flow.core.PayloadContextProvider) RegionAwareCrnGenerator(com.sequenceiq.cloudbreak.auth.crn.RegionAwareCrnGenerator) EnvironmentClientService(com.sequenceiq.datalake.service.EnvironmentClientService) SdxAwsBase(com.sequenceiq.sdx.api.model.SdxAwsBase) ImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response) UpdateRecipesV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.recipe.UpdateRecipesV4Request) StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) DetachRecipeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.DetachRecipeV4Response) CrnParseException(com.sequenceiq.cloudbreak.auth.crn.CrnParseException) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) ResourceIdProvider(com.sequenceiq.flow.core.ResourceIdProvider) AZURE(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AZURE) ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) Comparator(java.util.Comparator) Collections(java.util.Collections) InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) ClouderaManagerProductV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response) ClouderaManagerV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response)

Aggregations

StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)5 ClouderaManagerProductV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response)5 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)3 ClouderaManagerV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)2 DisplayName (org.junit.jupiter.api.DisplayName)2 Test (org.junit.jupiter.api.Test)2 AuthorizationResourceType (com.sequenceiq.authorization.resource.AuthorizationResourceType)1 HierarchyAuthResourcePropertyProvider (com.sequenceiq.authorization.service.HierarchyAuthResourcePropertyProvider)1 OwnerAssignmentService (com.sequenceiq.authorization.service.OwnerAssignmentService)1 ResourceWithId (com.sequenceiq.authorization.service.list.ResourceWithId)1 CompactViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.common.CompactViewV4Response)1 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)1 ImageV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response)1 RecipeV4Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v4.recipes.RecipeV4Endpoint)1 RecipeViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.recipes.responses.RecipeViewV4Responses)1 StackV4Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint)1 InstanceGroupV4Base (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceGroupV4Base)1 InstanceTemplateV4Base (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceTemplateV4Base)1 StackResponseEntries (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.StackResponseEntries)1