use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.
the class TagsUtilTest method addTestNameTagShouldAddTagToAbstractTestDtoWithTaggableRequest.
@Test
void addTestNameTagShouldAddTagToAbstractTestDtoWithTaggableRequest() {
SdxTestDto testDto = new SdxTestDto(mock(TestContext.class));
SdxClusterRequest request = new SdxClusterRequest();
testDto.setRequest(request);
when(testContext.getCloudPlatform()).thenReturn(CloudPlatform.MOCK);
underTest.addTestNameTag(testContext.getCloudPlatform(), testDto, TEST_NAME);
assertThat(request.getTags().get(TagsUtil.TEST_NAME_TAG)).isEqualTo(TEST_NAME);
}
use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testCreateSdxClusterWhenClusterWithSpecifiedNameAlreadyExistShouldThrowClusterAlreadyExistBadRequestException.
@Test
void testCreateSdxClusterWhenClusterWithSpecifiedNameAlreadyExistShouldThrowClusterAlreadyExistBadRequestException() {
SdxClusterRequest sdxClusterRequest = createSdxClusterRequest(null, MEDIUM_DUTY_HA);
SdxCluster existing = new SdxCluster();
existing.setEnvName("envir");
when(sdxClusterRepository.findByAccountIdAndEnvNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(Collections.singletonList(existing));
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null)));
assertEquals("SDX cluster exists for environment name: envir", badRequestException.getMessage());
}
use of com.sequenceiq.sdx.api.model.SdxClusterRequest 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.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testCreateNOTInternalSdxClusterFromLightDutyTemplateWhenLocationSpecifiedWithSlashShouldCreateAndSettedUpBaseLocationWithOUTSlash.
@Test
void testCreateNOTInternalSdxClusterFromLightDutyTemplateWhenLocationSpecifiedWithSlashShouldCreateAndSettedUpBaseLocationWithOUTSlash() throws IOException, TransactionExecutionException {
when(transactionService.required(isA(Supplier.class))).thenAnswer(invocation -> invocation.getArgument(0, Supplier.class).get());
String lightDutyJson = FileReaderUtils.readFileFromClasspath("/duties/7.1.0/aws/light_duty.json");
when(cdpConfigService.getConfigForKey(any())).thenReturn(JsonUtil.readValue(lightDutyJson, StackV4Request.class));
SdxClusterRequest sdxClusterRequest = createSdxClusterRequest(null, LIGHT_DUTY);
withCloudStorage(sdxClusterRequest);
long id = 10L;
when(sdxClusterRepository.save(any(SdxCluster.class))).thenAnswer(invocation -> {
SdxCluster sdxWithId = invocation.getArgument(0, SdxCluster.class);
sdxWithId.setId(id);
return sdxWithId;
});
mockEnvironmentCall(sdxClusterRequest, CloudPlatform.AWS, null);
Pair<SdxCluster, FlowIdentifier> result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null));
SdxCluster createdSdxCluster = result.getLeft();
assertEquals("s3a://some/dir", createdSdxCluster.getCloudStorageBaseLocation());
}
use of com.sequenceiq.sdx.api.model.SdxClusterRequest in project cloudbreak by hortonworks.
the class SdxServiceTest method testCcmV2JumpgateVersionChecker.
@ParameterizedTest(name = "Runtime {0} is compatible with CCMv2JumpGate = {1}")
@MethodSource("ccmV2JumpgateScenarios")
void testCcmV2JumpgateVersionChecker(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_JUMPGATE);
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_JUMPGATE_REQUIRED_VERSION));
} else {
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null));
}
}
Aggregations