use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class SdxRuntimeUpgradeServiceTest method testTriggerRuntimeUpgradeByNameWhenNotEnabledAndNoPatchUpgrades.
@Test
public void testTriggerRuntimeUpgradeByNameWhenNotEnabledAndNoPatchUpgrades() {
ImageInfoV4Response currentImageInfo = new ImageInfoV4Response();
currentImageInfo.setImageId(IMAGE_ID);
currentImageInfo.setCreated(1);
currentImageInfo.setComponentVersions(creatImageComponentVersions(MATCHING_TARGET_RUNTIME, MATCHING_TARGET_RUNTIME));
ImageInfoV4Response imageInfo = new ImageInfoV4Response();
imageInfo.setImageId(IMAGE_ID);
imageInfo.setCreated(1);
imageInfo.setComponentVersions(creatImageComponentVersions("7.2.0", "7.2.0"));
ImageInfoV4Response imageInfo2 = new ImageInfoV4Response();
imageInfo2.setImageId(IMAGE_ID_LAST);
imageInfo2.setCreated(2);
imageInfo2.setComponentVersions(creatImageComponentVersions("7.3.0", "7.3.0"));
List<ImageInfoV4Response> candidates = List.of(imageInfo, imageInfo2);
response.setCurrent(currentImageInfo);
response.setUpgradeCandidates(candidates);
SdxUpgradeResponse expectedResponse = new SdxUpgradeResponse(response.getCurrent(), List.of(), "Something went wrong", response.getFlowIdentifier());
when(entitlementService.runtimeUpgradeEnabled(any())).thenReturn(false);
when(stackV4Endpoint.checkForClusterUpgradeByName(anyLong(), anyString(), any(), anyString())).thenReturn(response);
when(sdxUpgradeClusterConverter.upgradeResponseToSdxUpgradeResponse(any(UpgradeV4Response.class))).thenReturn(expectedResponse);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
BadRequestException exception = assertThrows(BadRequestException.class, () -> underTest.triggerUpgradeByName(USER_CRN, STACK_NAME, sdxUpgradeRequest, ACCOUNT_ID));
assertTrue(exception.getMessage().contains("Something went wrong"));
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class SdxRuntimeUpgradeServiceTest method testNoImageFound.
@Test
public void testNoImageFound() {
when(sdxService.getByCrn(anyString(), anyString())).thenReturn(sdxCluster);
when(stackV4Endpoint.checkForClusterUpgradeByName(anyLong(), anyString(), any(), anyString())).thenReturn(response);
when(sdxUpgradeClusterConverter.upgradeResponseToSdxUpgradeResponse(response)).thenReturn(sdxUpgradeResponse);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
response.setUpgradeCandidates(new ArrayList<>());
sdxUpgradeResponse.setUpgradeCandidates(new ArrayList<>());
BadRequestException exception = assertThrows(BadRequestException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.triggerUpgradeByCrn(USER_CRN, STACK_CRN, sdxUpgradeRequest, ACCOUNT_ID)));
assertEquals("There is no compatible image to upgrade for stack " + sdxCluster.getClusterName(), exception.getMessage());
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class DiagnosticsCollectionValidatorTest method testWithCloudStorageWithDisabledLogging.
@Test
void testWithCloudStorageWithDisabledLogging() {
BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest();
request.setDestination(DiagnosticsDestination.CLOUD_STORAGE);
StackV4Response stackV4Response = new StackV4Response();
stackV4Response.setCrn(DATALAKE_CRN);
TelemetryResponse telemetry = new TelemetryResponse();
stackV4Response.setTelemetry(telemetry);
BadRequestException thrown = assertThrows(BadRequestException.class, () -> underTest.validate(request, stackV4Response));
assertTrue(thrown.getMessage().contains("Cloud storage logging is disabled for Data Lake"));
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class DiagnosticsCollectionValidatorTest method testWithEngDestinationAndDisabledLogCollection.
@Test
void testWithEngDestinationAndDisabledLogCollection() {
BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest();
request.setDestination(DiagnosticsDestination.ENG);
StackV4Response stackV4Response = new StackV4Response();
stackV4Response.setCrn(DATALAKE_CRN);
TelemetryResponse telemetry = new TelemetryResponse();
stackV4Response.setTelemetry(telemetry);
BadRequestException thrown = assertThrows(BadRequestException.class, () -> underTest.validate(request, stackV4Response));
assertTrue(thrown.getMessage().contains("Cluster log collection is not enabled for Data Lake"));
}
use of com.sequenceiq.cloudbreak.common.exception.BadRequestException in project cloudbreak by hortonworks.
the class SdxRepairSettingsTest method throwsExceptionWhenHostGroupAndNodeIdsAreSpecified.
@Test
void throwsExceptionWhenHostGroupAndNodeIdsAreSpecified() {
SdxRepairRequest request = new SdxRepairRequest();
request.setHostGroupName("hg1");
request.setNodesIds(List.of("node1", "node2"));
BadRequestException exception = assertThrows(BadRequestException.class, () -> SdxRepairSettings.from(request));
assertEquals("Please select one host group ('hostGroupName'), multiple host groups ('hostGroupNames'), or nodes ('nodesIds').", exception.getMessage());
}
Aggregations