Search in sources :

Example 1 with ClouderaManagerV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request 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)

Example 2 with ClouderaManagerV4Request

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

the class AutoTlsFlagPreparatoryTest method testAutoTlsSettingFromRequest.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
public void testAutoTlsSettingFromRequest(String value) {
    ClusterV4Request request = new ClusterV4Request();
    request.setCm(new ClouderaManagerV4Request());
    request.getCm().setEnableAutoTls(Boolean.valueOf(value));
    boolean result = underTest.provideAutoTlsFlag(request, new Stack(), Optional.empty());
    verifyNoInteractions(cloudPlatformConnectors);
    assertEquals(Boolean.valueOf(value), result);
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with ClouderaManagerV4Request

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

the class ClusterToClusterV4RequestConverterTest method testConvertWhenClouderaManagerConversionSuccessfulThenExpectedClouderaManagerV4RequestShouldPlacedIn.

@Test
public void testConvertWhenClouderaManagerConversionSuccessfulThenExpectedClouderaManagerV4RequestShouldPlacedIn() {
    ClouderaManagerV4Request expected = mock(ClouderaManagerV4Request.class);
    when(clouderaManagerV4RequestConverter.convert(cluster)).thenReturn(expected);
    ClusterV4Request result = underTest.convert(cluster);
    assertEquals(expected, result.getCm());
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) Test(org.junit.Test)

Example 4 with ClouderaManagerV4Request

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

the class StackCreatorServiceTest method testShouldUseBaseCMImageWithProductsAndCmRepoAndPlatformIsNotYarn.

@Test
public void testShouldUseBaseCMImageWithProductsAndCmRepoAndPlatformIsNotYarn() {
    ClusterV4Request clusterV4Request = new ClusterV4Request();
    ClouderaManagerV4Request cmRequest = new ClouderaManagerV4Request();
    ClouderaManagerProductV4Request cdpRequest = new ClouderaManagerProductV4Request();
    cdpRequest.setName("CDP");
    cdpRequest.setParcel("parcel");
    cdpRequest.setVersion("version");
    cdpRequest.setCsd(List.of("csd"));
    cmRequest.setProducts(List.of(cdpRequest));
    ClouderaManagerRepositoryV4Request cmRepoRequest = new ClouderaManagerRepositoryV4Request();
    cmRequest.setRepository(cmRepoRequest);
    clusterV4Request.setCm(cmRequest);
    boolean base = underTest.shouldUseBaseCMImage(clusterV4Request, AWS_PLATFORM);
    assertTrue(base);
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ClouderaManagerProductV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request) ClouderaManagerRepositoryV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with ClouderaManagerV4Request

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

the class StackCreatorServiceTest method testShouldUseBaseCMImageShouldReturnTrueWithCMImageWithCmRepoAndImageIsNotPresentAndPlatformIsYarn.

@Test
public void testShouldUseBaseCMImageShouldReturnTrueWithCMImageWithCmRepoAndImageIsNotPresentAndPlatformIsYarn() {
    ClusterV4Request clusterV4Request = new ClusterV4Request();
    ClouderaManagerV4Request cmRequest = new ClouderaManagerV4Request();
    ClouderaManagerRepositoryV4Request cmRepoRequest = new ClouderaManagerRepositoryV4Request();
    cmRequest.setRepository(cmRepoRequest);
    clusterV4Request.setCm(cmRequest);
    boolean base = underTest.shouldUseBaseCMImage(clusterV4Request, YARN_PLATFORM);
    assertTrue(base);
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ClouderaManagerRepositoryV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ClouderaManagerV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request)20 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)16 ClouderaManagerRepositoryV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request)10 Test (org.junit.jupiter.api.Test)10 ClouderaManagerProductV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)5 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)4 Json (com.sequenceiq.cloudbreak.common.json.Json)4 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 ComponentType (com.sequenceiq.cloudbreak.common.type.ComponentType)3 Set (java.util.Set)3 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)2 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)2 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)2 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)2 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)2 StackType (com.sequenceiq.cloudbreak.cloud.model.component.StackType)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)2 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)2