use of com.sequenceiq.sdx.api.model.SdxClusterResizeRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxResizeButEnvInFailedPhase.
@ParameterizedTest
@MethodSource("failedParamProvider")
void testSdxResizeButEnvInFailedPhase(EnvironmentStatus environmentStatus) {
SdxClusterResizeRequest sdxClusterResizeRequest = new SdxClusterResizeRequest();
sdxClusterResizeRequest.setClusterShape(MEDIUM_DUTY_HA);
sdxClusterResizeRequest.setEnvironment("environment");
SdxCluster sdxCluster = getSdxCluster();
sdxCluster.setClusterShape(LIGHT_DUTY);
sdxCluster.setDatabaseCrn(null);
when(entitlementService.isDatalakeLightToMediumMigrationEnabled(anyString())).thenReturn(true);
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
when(sdxClusterRepository.findByAccountIdAndEnvCrnAndDeletedIsNullAndDetachedIsTrue(anyString(), anyString())).thenReturn(Optional.empty());
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
detailedEnvironmentResponse.setName(sdxClusterResizeRequest.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.resizeSdx(USER_CRN, "sdxcluster", sdxClusterResizeRequest)), "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.SdxClusterResizeRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxResizeByAccountIdAndNameWhenSdxOnGcp.
@Test
void testSdxResizeByAccountIdAndNameWhenSdxOnGcp() {
SdxClusterResizeRequest sdxClusterResizeRequest = new SdxClusterResizeRequest();
sdxClusterResizeRequest.setClusterShape(MEDIUM_DUTY_HA);
sdxClusterResizeRequest.setEnvironment("environment");
SdxCluster sdxCluster = getSdxCluster();
sdxCluster.setClusterShape(LIGHT_DUTY);
sdxCluster.setCloudStorageFileSystemType(FileSystemType.GCS);
sdxCluster.setDatabaseCrn(null);
when(entitlementService.isDatalakeLightToMediumMigrationEnabled(anyString())).thenReturn(true);
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.resizeSdx(USER_CRN, "sdxcluster", sdxClusterResizeRequest));
assertTrue(badRequestException.getMessage().startsWith("Unsupported cloud provider GCP"));
}
use of com.sequenceiq.sdx.api.model.SdxClusterResizeRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxResizeByAccountIdAndNameWhenSdxWithSameShape.
@Test
void testSdxResizeByAccountIdAndNameWhenSdxWithSameShape() {
SdxClusterResizeRequest sdxClusterResizeRequest = new SdxClusterResizeRequest();
sdxClusterResizeRequest.setClusterShape(MEDIUM_DUTY_HA);
sdxClusterResizeRequest.setEnvironment("environment");
SdxCluster sdxCluster = getSdxCluster();
sdxCluster.setClusterShape(MEDIUM_DUTY_HA);
sdxCluster.setDatabaseCrn(null);
when(entitlementService.isDatalakeLightToMediumMigrationEnabled(anyString())).thenReturn(true);
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.resizeSdx(USER_CRN, "sdxcluster", sdxClusterResizeRequest));
assertEquals("SDX cluster already is of requested shape", badRequestException.getMessage());
}
use of com.sequenceiq.sdx.api.model.SdxClusterResizeRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxResizeClusterSuccess.
@Test
void testSdxResizeClusterSuccess() throws Exception {
final String runtime = "7.2.10";
SdxClusterResizeRequest sdxClusterResizeRequest = new SdxClusterResizeRequest();
sdxClusterResizeRequest.setClusterShape(MEDIUM_DUTY_HA);
sdxClusterResizeRequest.setEnvironment("environment");
SdxCluster sdxCluster = getSdxCluster();
sdxCluster.setId(1L);
sdxCluster.setClusterShape(LIGHT_DUTY);
sdxCluster.setDatabaseCrn(null);
sdxCluster.setRuntime(runtime);
sdxCluster.setCloudStorageBaseLocation("s3a://some/dir/");
when(entitlementService.isDatalakeLightToMediumMigrationEnabled(anyString())).thenReturn(true);
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
when(sdxClusterRepository.findByAccountIdAndEnvCrnAndDeletedIsNullAndDetachedIsTrue(anyString(), anyString())).thenReturn(Optional.empty());
mockEnvironmentCall(sdxClusterResizeRequest, CloudPlatform.AWS);
when(sdxReactorFlowManager.triggerSdxResize(anyLong(), any(SdxCluster.class))).thenReturn(new FlowIdentifier(FlowType.FLOW, "FLOW_ID"));
String mediumDutyJson = FileReaderUtils.readFileFromClasspath("/duties/7.2.10/aws/medium_duty_ha.json");
when(cdpConfigService.getConfigForKey(any())).thenReturn(JsonUtil.readValue(mediumDutyJson, StackV4Request.class));
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
StackV4Response stackV4Response = new StackV4Response();
stackV4Response.setStatus(Status.STOPPED);
when(stackV4Endpoint.get(anyLong(), anyString(), anySet(), anyString())).thenReturn(stackV4Response);
Pair<SdxCluster, FlowIdentifier> result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.resizeSdx(USER_CRN, sdxCluster.getClusterName(), sdxClusterResizeRequest));
SdxCluster createdSdxCluster = result.getLeft();
assertEquals(sdxCluster.getClusterName(), createdSdxCluster.getClusterName());
assertEquals(runtime, createdSdxCluster.getRuntime());
assertEquals("s3a://some/dir/", createdSdxCluster.getCloudStorageBaseLocation());
assertEquals("envir", createdSdxCluster.getEnvName());
}
use of com.sequenceiq.sdx.api.model.SdxClusterResizeRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxResizeByAccountIdAndNameWhenSdxDoesNotExist.
@Test
void testSdxResizeByAccountIdAndNameWhenSdxDoesNotExist() {
SdxClusterResizeRequest sdxClusterResizeRequest = new SdxClusterResizeRequest();
sdxClusterResizeRequest.setClusterShape(MEDIUM_DUTY_HA);
sdxClusterResizeRequest.setEnvironment("environment");
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(Optional.empty());
NotFoundException notFoundException = assertThrows(NotFoundException.class, () -> underTest.resizeSdx(USER_CRN, "sdxcluster", sdxClusterResizeRequest));
assertEquals("SDX cluster 'sdxcluster' not found.", notFoundException.getMessage());
}
Aggregations