use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testCreateMicroDutyNoEntitlement.
@Test
void testCreateMicroDutyNoEntitlement() {
final String runtime = "7.2.12";
SdxClusterRequest sdxClusterRequest = createSdxClusterRequest(runtime, MICRO_DUTY);
when(sdxClusterRepository.findByAccountIdAndEnvNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(new ArrayList<>());
mockEnvironmentCall(sdxClusterRequest, CloudPlatform.AZURE, null);
when(entitlementService.microDutySdxEnabled(anyString())).thenReturn(false);
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null)));
assertEquals(String.format("Provisioning a micro duty data lake cluster is not enabled for %s. ", CloudPlatform.AZURE.name()) + "Contact Cloudera support to enable CDP_MICRO_DUTY_SDX entitlement for the account.", badRequestException.getMessage());
}
use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxCreateRazEnabled710Runtime.
@ParameterizedTest(name = "{0}")
@MethodSource("razCloudPlatform710DataProvider")
void testSdxCreateRazEnabled710Runtime(String testCaseName, CloudPlatform cloudPlatform, String expectedErrorMsg) {
SdxClusterRequest sdxClusterRequest = createSdxClusterRequest("7.1.0", LIGHT_DUTY);
when(sdxClusterRepository.findByAccountIdAndEnvNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(new ArrayList<>());
mockEnvironmentCall(sdxClusterRequest, cloudPlatform, null);
sdxClusterRequest.setEnableRangerRaz(true);
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null)));
assertEquals(expectedErrorMsg, badRequestException.getMessage());
}
use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testCreateButEnvInFailedPhase.
@ParameterizedTest
@MethodSource("failedParamProvider")
void testCreateButEnvInFailedPhase(EnvironmentStatus environmentStatus) {
SdxClusterRequest sdxClusterRequest = createSdxClusterRequest(null, MEDIUM_DUTY_HA);
DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
detailedEnvironmentResponse.setName(sdxClusterRequest.getEnvironment());
detailedEnvironmentResponse.setCloudPlatform(CloudPlatform.AWS.name());
detailedEnvironmentResponse.setCrn(getCrn());
detailedEnvironmentResponse.setEnvironmentStatus(environmentStatus);
when(environmentClientService.getByName(anyString())).thenReturn(detailedEnvironmentResponse);
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null)), "BadRequestException should thrown");
assertEquals("The environment is in failed phase. Please fix the environment or create a new one first!", badRequestException.getMessage());
}
use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.
the class StorageValidationServiceTest method whenInvalidConfigIsProvidedThrowBadRequest.
@Test
public void whenInvalidConfigIsProvidedThrowBadRequest() {
SdxClusterRequest sdxClusterRequest = new SdxClusterRequest();
SdxCloudStorageRequest sdxCloudStorageRequest = new SdxCloudStorageRequest();
sdxCloudStorageRequest.setBaseLocation("s3a://example-path");
sdxClusterRequest.setCloudStorage(sdxCloudStorageRequest);
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("AWS");
BadRequestException exception = Assertions.assertThrows(BadRequestException.class, () -> underTest.validateCloudStorage(CloudPlatform.AWS.toString(), sdxCloudStorageRequest));
assertEquals(exception.getMessage(), "instance profile must be defined for S3");
}
use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.
the class CloudStorageManifesterTest method whenEnvironmentHasOnlyLoggingEnabledThenShouldApplyAsLogIdentity.
@Test
public void whenEnvironmentHasOnlyLoggingEnabledThenShouldApplyAsLogIdentity() {
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("AWS");
TelemetryResponse telemetryResponse = new TelemetryResponse();
LoggingResponse loggingResponse = new LoggingResponse();
S3CloudStorageV1Parameters s3CloudStorageV1Parameters = new S3CloudStorageV1Parameters();
s3CloudStorageV1Parameters.setInstanceProfile("logprofile");
loggingResponse.setS3(s3CloudStorageV1Parameters);
telemetryResponse.setLogging(loggingResponse);
environment.setTelemetry(telemetryResponse);
ClusterV4Request clusterV4Request = new ClusterV4Request();
clusterV4Request.setBlueprintName(exampleBlueprintName);
CloudStorageRequest cloudStorageConfigReq = underTest.initCloudStorageRequest(environment, clusterV4Request, null, new SdxClusterRequest());
assertEquals(1, cloudStorageConfigReq.getIdentities().size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.LOG)).collect(Collectors.toSet()).size());
assertEquals("logprofile", cloudStorageConfigReq.getIdentities().get(0).getS3().getInstanceProfile());
}
Aggregations