Search in sources :

Example 21 with SdxClusterRequest

use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.

the class SdxServiceTest method testCreateSdxClusterWithoutCloudStorageShouldNotThrownBadRequestExceptionInCaseOfInternal.

@Test
void testCreateSdxClusterWithoutCloudStorageShouldNotThrownBadRequestExceptionInCaseOfInternal() {
    SdxClusterRequest sdxClusterRequest = createSdxClusterRequest("7.2.1", CUSTOM);
    when(sdxClusterRepository.findByAccountIdAndEnvNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(new ArrayList<>());
    mockEnvironmentCall(sdxClusterRequest, CloudPlatform.AWS, null);
    StackV4Request stackV4Request = new StackV4Request();
    ClusterV4Request clusterV4Request = new ClusterV4Request();
    stackV4Request.setCluster(clusterV4Request);
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, stackV4Request));
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) SdxClusterRequest(com.sequenceiq.sdx.api.model.SdxClusterRequest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 22 with SdxClusterRequest

use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.

the class SdxServiceTest method testCcmV2VersionChecker.

@ParameterizedTest(name = "Runtime {0} is compatible with CCMv2 = {1}")
@MethodSource("ccmV2Scenarios")
void testCcmV2VersionChecker(String runtime, boolean compatible) throws IOException {
    SdxClusterRequest sdxClusterRequest = createSdxClusterRequest(runtime, LIGHT_DUTY);
    when(sdxClusterRepository.findByAccountIdAndEnvNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(new ArrayList<>());
    String lightDutyJson = FileReaderUtils.readFileFromClasspath("/duties/7.2.10/aws/light_duty.json");
    lenient().when(cdpConfigService.getConfigForKey(any())).thenReturn(JsonUtil.readValue(lightDutyJson, StackV4Request.class));
    mockEnvironmentCall(sdxClusterRequest, CloudPlatform.MOCK, Tunnel.CCMV2);
    if (!compatible) {
        assertThatThrownBy(() -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null))).isInstanceOf(BadRequestException.class).hasMessage(String.format("Runtime version %s does not support Cluster Connectivity Manager. " + "Please try creating a datalake with runtime version at least %s.", runtime, CCMV2_REQUIRED_VERSION));
    } else {
        ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null));
    }
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) SdxClusterRequest(com.sequenceiq.sdx.api.model.SdxClusterRequest) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 23 with SdxClusterRequest

use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.

the class SdxServiceTest method createSdxClusterRequest.

private SdxClusterRequest createSdxClusterRequest(String runtime, SdxClusterShape shape) {
    SdxClusterRequest sdxClusterRequest = new SdxClusterRequest();
    sdxClusterRequest.setRuntime(runtime);
    sdxClusterRequest.setClusterShape(shape);
    sdxClusterRequest.addTags(TAGS);
    sdxClusterRequest.setEnvironment("envir");
    return sdxClusterRequest;
}
Also used : SdxClusterRequest(com.sequenceiq.sdx.api.model.SdxClusterRequest)

Example 24 with SdxClusterRequest

use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.

the class SdxServiceTest method testCreateSdxClusterWithoutCloudStorageShouldThrownBadRequestException.

@Test
void testCreateSdxClusterWithoutCloudStorageShouldThrownBadRequestException() {
    SdxClusterRequest sdxClusterRequest = createSdxClusterRequest("7.2.1", LIGHT_DUTY);
    when(sdxClusterRepository.findByAccountIdAndEnvNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(new ArrayList<>());
    mockEnvironmentCall(sdxClusterRequest, CloudPlatform.AWS, null);
    BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null)));
    assertEquals("Cloud storage parameter is required.", badRequestException.getMessage());
}
Also used : SdxClusterRequest(com.sequenceiq.sdx.api.model.SdxClusterRequest) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 25 with SdxClusterRequest

use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.

the class SdxServiceTest method testSdxCreateRazEnabledNotAwsOrAzure.

@Test
void testSdxCreateRazEnabledNotAwsOrAzure() {
    SdxClusterRequest sdxClusterRequest = createSdxClusterRequest("7.2.2", LIGHT_DUTY);
    when(sdxClusterRepository.findByAccountIdAndEnvNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(new ArrayList<>());
    mockEnvironmentCall(sdxClusterRequest, CloudPlatform.YARN, null);
    sdxClusterRequest.setEnableRangerRaz(true);
    BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null)));
    assertEquals("Provisioning Ranger Raz is only valid for Amazon Web Services and Microsoft Azure.", badRequestException.getMessage());
}
Also used : SdxClusterRequest(com.sequenceiq.sdx.api.model.SdxClusterRequest) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

SdxClusterRequest (com.sequenceiq.sdx.api.model.SdxClusterRequest)37 Test (org.junit.jupiter.api.Test)26 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)20 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)17 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)16 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)14 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)13 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)11 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)10 SdxCloudStorageRequest (com.sequenceiq.sdx.api.model.SdxCloudStorageRequest)10 MethodSource (org.junit.jupiter.params.provider.MethodSource)10 Supplier (java.util.function.Supplier)9 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)8 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)7 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)7 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)5 RegionAwareInternalCrnGenerator (com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGenerator)5 RegionAwareInternalCrnGeneratorFactory (com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory)5 LoggingResponse (com.sequenceiq.common.api.telemetry.response.LoggingResponse)5