Search in sources :

Example 1 with ClusterV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.

the class ClusterToClusterV4RequestConverterTest method testConvertSettingExecutorTypeToNull.

@Test
public void testConvertSettingExecutorTypeToNull() {
    ClusterV4Request result = underTest.convert(cluster);
    assertNotNull(result);
    assertNull(result.getExecutorType());
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) Test(org.junit.Test)

Example 2 with ClusterV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.

the class DistroXClusterToClusterConverterTest method testConvertWithoutEnvTheExecutionTypeShouldBeSetToDefault.

@Test
void testConvertWithoutEnvTheExecutionTypeShouldBeSetToDefault() {
    ClusterV4Request result = testConvertDistroXV1Request();
    assertNotNull(result);
    assertEquals(ExecutorType.DEFAULT, result.getExecutorType());
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) Test(org.junit.jupiter.api.Test)

Example 3 with ClusterV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.

the class ClusterToClusterV4RequestConverter method convert.

public ClusterV4Request convert(Cluster source) {
    ClusterV4Request clusterRequest = new ClusterV4Request();
    convertClusterManager(source, clusterRequest);
    clusterRequest.setBlueprintName(source.getBlueprint().getName());
    clusterRequest.setValidateBlueprint(null);
    clusterRequest.setUserName("");
    clusterRequest.setPassword("");
    if (source.getFileSystem() != null) {
        clusterRequest.setCloudStorage(cloudStorageConverter.fileSystemToRequest(source.getFileSystem()));
    }
    clusterRequest.setName(source.getName());
    if (source.getRdsConfigs() != null && !source.getRdsConfigs().isEmpty()) {
        Set<String> databaseNames = source.getRdsConfigs().stream().filter(rdsConfig -> rdsConfig.getStatus() == ResourceStatus.USER_MANAGED).map(RDSConfig::getName).collect(Collectors.toSet());
        clusterRequest.setDatabases(Collections.unmodifiableSet(databaseNames));
    }
    if (StringUtils.isNotEmpty(source.getProxyConfigCrn())) {
        clusterRequest.setProxyConfigCrn(source.getProxyConfigCrn());
    }
    if (source.getGateway() != null) {
        clusterRequest.setGateway(gatewayToGatewayV4RequestConverter.convert(source.getGateway()));
    }
    clusterRequest.setRangerRazEnabled(source.isRangerRazEnabled());
    return clusterRequest;
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)

Example 4 with ClusterV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.

the class StackCreatorService method determineImageCatalog.

private Future<StatedImage> determineImageCatalog(String stackName, String platformString, StackV4Request stackRequest, Blueprint blueprint, User user, Workspace workspace) {
    ClusterV4Request clusterRequest = stackRequest.getCluster();
    if (clusterRequest == null) {
        return null;
    }
    boolean shouldUseBaseCMImage = shouldUseBaseCMImage(clusterRequest, platformString);
    boolean baseImageEnabled = imageCatalogService.baseImageEnabled();
    Map<String, String> mdcContext = MDCBuilder.getMdcContextMap();
    CloudbreakUser cbUser = restRequestThreadLocalService.getCloudbreakUser();
    return executorService.submit(() -> {
        MDCBuilder.buildMdcContextFromMap(mdcContext);
        LOGGER.info("The stack with name {} has base images enabled: {} and should use base images: {}", stackName, baseImageEnabled, shouldUseBaseCMImage);
        StatedImage statedImage = ThreadBasedUserCrnProvider.doAs(user.getUserCrn(), () -> {
            try {
                restRequestThreadLocalService.setCloudbreakUser(cbUser);
                return imageService.determineImageFromCatalog(workspace.getId(), stackRequest.getImage(), platformString, stackRequest.getVariant(), blueprint, shouldUseBaseCMImage, baseImageEnabled, user, image -> true);
            } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) {
                throw new RuntimeException(e);
            }
        });
        MDCBuilder.cleanupMdc();
        return statedImage;
    });
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)

Example 5 with ClusterV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.

the class ClusterV4RequestToClusterConverterTest method testConvertClouderaManagerRequestWithNullRepo.

@Test
public void testConvertClouderaManagerRequestWithNullRepo() {
    ClusterV4Request request = new ClusterV4Request();
    request.setBlueprintName(BLUEPRINT);
    blueprint.setStackType(StackType.CDH.name());
    when(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq(BLUEPRINT), any())).thenReturn(blueprint);
    ClouderaManagerV4Request cm = new ClouderaManagerV4Request();
    ClouderaManagerProductV4Request cdp = new ClouderaManagerProductV4Request();
    cdp.setName("cdp");
    cdp.setParcel("cdp.parcel");
    cdp.setVersion("cdp.version");
    cdp.setCsd(List.of("cdp.csd"));
    ClouderaManagerProductV4Request cdf = new ClouderaManagerProductV4Request();
    cdf.setName("cdf");
    cdf.setParcel("cdf.parcel");
    cdf.setVersion("cdf.version");
    cdf.setCsd(List.of("cdf.csd"));
    List<ClouderaManagerProductV4Request> products = List.of(cdp, cdf);
    cm.setProducts(products);
    request.setCm(cm);
    Cluster cluster = underTest.convert(request);
    assertFalse(cluster.getComponents().isEmpty());
    assertEquals(2, cluster.getComponents().size());
    assertAll(cluster.getComponents().stream().map(component -> () -> assertEquals(ComponentType.CDH_PRODUCT_DETAILS, component.getComponentType())));
    List<Json> cdps = cluster.getComponents().stream().map(ClusterComponent::getAttributes).filter(attr -> attr.getValue().contains("cdp")).collect(Collectors.toList());
    Json cdpJson = new Json(cdp);
    assertAll(() -> assertEquals(1, cdps.size()), () -> assertEquals(cdpJson, cdps.iterator().next()));
    List<Json> cdfs = cluster.getComponents().stream().map(ClusterComponent::getAttributes).filter(attr -> attr.getValue().contains("cdf")).collect(Collectors.toList());
    Json cdfJson = new Json(cdf);
    assertAll(() -> assertEquals(1, cdfs.size()), () -> assertEquals(cdfJson, cdfs.iterator().next()));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) GatewayConvertUtil(com.sequenceiq.cloudbreak.converter.util.GatewayConvertUtil) ComponentType(com.sequenceiq.cloudbreak.common.type.ComponentType) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) ArgumentMatchers.nullable(org.mockito.ArgumentMatchers.nullable) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) CloudStorageConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.cluster.CloudStorageConverter) GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) Collections.singleton(java.util.Collections.singleton) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) RdsConfigService(com.sequenceiq.cloudbreak.service.rdsconfig.RdsConfigService) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Spy(org.mockito.Spy) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Assertions.assertAll(org.junit.jupiter.api.Assertions.assertAll) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) CloudStorageBase(com.sequenceiq.common.api.cloudstorage.CloudStorageBase) Set(java.util.Set) WorkspaceService(com.sequenceiq.cloudbreak.service.workspace.WorkspaceService) StackType(com.sequenceiq.cloudbreak.cloud.model.component.StackType) Collectors(java.util.stream.Collectors) GatewayV4RequestToGatewayConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.cluster.gateway.GatewayV4RequestToGatewayConverter) Test(org.junit.jupiter.api.Test) Json(com.sequenceiq.cloudbreak.common.json.Json) List(java.util.List) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) Matchers.is(org.hamcrest.Matchers.is) CloudStorageValidationUtil(com.sequenceiq.cloudbreak.converter.util.CloudStorageValidationUtil) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) Mockito.mock(org.mockito.Mockito.mock) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Mock(org.mockito.Mock) IdBrokerConverterUtil(com.sequenceiq.cloudbreak.converter.IdBrokerConverterUtil) ClouderaManagerProductV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) InjectMocks(org.mockito.InjectMocks) ClouderaManagerRepositoryV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request) Collections.emptySet(java.util.Collections.emptySet) ClusterV4RequestToClusterConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.cluster.ClusterV4RequestToClusterConverter) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Mockito.verify(org.mockito.Mockito.verify) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) Mockito(org.mockito.Mockito) BlueprintService(com.sequenceiq.cloudbreak.service.blueprint.BlueprintService) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ClouderaManagerProductV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Json(com.sequenceiq.cloudbreak.common.json.Json) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) Test(org.junit.jupiter.api.Test)

Aggregations

ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)90 Test (org.junit.jupiter.api.Test)59 ClouderaManagerV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request)16 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 Test (org.junit.Test)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)12 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)10 SdxClusterRequest (com.sequenceiq.sdx.api.model.SdxClusterRequest)10 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)9 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)9 ClouderaManagerRepositoryV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request)8 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)8 SdxCloudStorageRequest (com.sequenceiq.sdx.api.model.SdxCloudStorageRequest)8 ClouderaManagerProductV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request)7 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)7 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)7 List (java.util.List)7 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)6