use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxCreateMediumDutySdx720Runtime.
@Test
void testSdxCreateMediumDutySdx720Runtime() {
final String invalidRuntime = "7.2.0";
SdxClusterRequest sdxClusterRequest = createSdxClusterRequest(invalidRuntime, MEDIUM_DUTY_HA);
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("Provisioning a Medium Duty SDX shape is only valid for CM version greater than or equal to " + MEDIUM_DUTY_REQUIRED_VERSION + " and not " + invalidRuntime, badRequestException.getMessage());
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxResizeByAccountIdAndNameWhenSdxWithExistingDetachedSdx.
@Test
void testSdxResizeByAccountIdAndNameWhenSdxWithExistingDetachedSdx() {
SdxClusterResizeRequest sdxClusterResizeRequest = new SdxClusterResizeRequest();
sdxClusterResizeRequest.setClusterShape(MEDIUM_DUTY_HA);
sdxClusterResizeRequest.setEnvironment("environment");
SdxCluster sdxCluster = getSdxCluster();
sdxCluster.setClusterShape(LIGHT_DUTY);
sdxCluster.setDatabaseCrn(null);
sdxCluster.setDetached(true);
when(entitlementService.isDatalakeLightToMediumMigrationEnabled(anyString())).thenReturn(true);
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
when(sdxClusterRepository.findByAccountIdAndEnvCrnAndDeletedIsNullAndDetachedIsTrue(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.resizeSdx(USER_CRN, "sdxcluster", sdxClusterResizeRequest));
assertEquals("SDX which is detached already exists for the environment. SDX name: " + sdxCluster.getClusterName(), badRequestException.getMessage());
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxCreateMediumDutySdx710Runtime.
@Test
void testSdxCreateMediumDutySdx710Runtime() {
final String invalidRuntime = "7.1.0";
SdxClusterRequest sdxClusterRequest = createSdxClusterRequest(invalidRuntime, MEDIUM_DUTY_HA);
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("Provisioning a Medium Duty SDX shape is only valid for CM version greater than or equal to " + MEDIUM_DUTY_REQUIRED_VERSION + " and not " + invalidRuntime, badRequestException.getMessage());
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxCreateRazEnabled720Runtime.
@ParameterizedTest(name = "{0}")
@MethodSource("razCloudPlatform720DataProvider")
void testSdxCreateRazEnabled720Runtime(String testCaseName, CloudPlatform cloudPlatform, String expectedErrorMsg) {
SdxClusterRequest sdxClusterRequest = createSdxClusterRequest("7.2.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.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class SdxServiceTest method testDeleteSdxWhenSdxHasStoppedDataHubsShouldThrowBadRequest.
@Test
void testDeleteSdxWhenSdxHasStoppedDataHubsShouldThrowBadRequest() {
SdxCluster sdxCluster = getSdxCluster();
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNull(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
StackViewV4Response stackViewV4Response = new StackViewV4Response();
stackViewV4Response.setName("existingDistroXCluster");
stackViewV4Response.setStatus(Status.STOPPED);
mockCBCallForDistroXClusters(Sets.newHashSet(stackViewV4Response));
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.deleteSdx(USER_CRN, "sdx-cluster-name", false));
assertEquals("The following stopped Data Hubs clusters(s) must be terminated before SDX deleting [existingDistroXCluster]." + " Use --force to skip this check.", badRequestException.getMessage());
}
Aggregations