/** * Get the AWS Params DTO for the account Id if no account id is specified, use the default * * @param accountId account Id * * @return AwsParamsDto */ public AwsParamsDto getAwsParamsDtoByAccountId(String accountId) { AwsParamsDto awsParamsDto = getAwsParamsDto(); if (StringUtils.isNotBlank(accountId)) { updateAwsParamsForCrossAccountAccess(awsParamsDto, accountId.trim()); } return awsParamsDto; }
/** * Get the AWS Params DTO for the account Id if no account id is specified, use the default * * @param accountId account Id * * @return AwsParamsDto */ public AwsParamsDto getAwsParamsDtoByAccountId(String accountId) { AwsParamsDto awsParamsDto = getAwsParamsDto(); if (StringUtils.isNotBlank(accountId)) { updateAwsParamsForCrossAccountAccess(awsParamsDto, accountId.trim()); } return awsParamsDto; }
/** * This method tests the blank cluster id for finding cluster status */ @Test public void testGetEmrClusterStatusByIdWithBlank() throws Exception { // Send blank for cluster id, and this method returns null for describeClusterResult emrDao.getEmrClusterStatusById(EMR_CLUSTER_DEFINITION_NAME, emrHelper.getAwsParamsDto()); }
private void terminateCluster(String namespace, String clusterDefinitionName, String clusterName) { try { String fullClusterName = emrHelper.buildEmrClusterName(namespace, clusterDefinitionName, clusterName); AwsParamsDto awsParams = emrHelper.getAwsParamsDto(); emrDao.terminateEmrCluster(fullClusterName, true, awsParams); } catch (Exception e) { /* * Ignore the error. * Most of the cases the failures are because the cluster terminated by itself, in which case what this method was trying to achieve has been * accomplished. * If cluster termination legitimately fails, it is not part of this test suite. */ LOGGER.warn(String .format("Failed to terminate cluster namespace = %s, clusterDefinitionName = %s, clusterName = %s", namespace, clusterDefinitionName, clusterName)); } }
@Test public void testGetActiveEmrClusterByName() throws Exception { // Get the EMR cluster definition object String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()); EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml); // check cluster summary before creation ClusterSummary clusterSummary = emrDao.getActiveEmrClusterByName(MockEmrOperationsImpl.MOCK_CLUSTER_NAME, emrHelper.getAwsParamsDto()); assertNull(clusterSummary); // Create the cluster String clusterId = emrDao.createEmrCluster(MockEmrOperationsImpl.MOCK_CLUSTER_NAME, emrClusterDefinition, emrHelper.getAwsParamsDto()); // check cluster summary after creation clusterSummary = emrDao.getActiveEmrClusterByName(MockEmrOperationsImpl.MOCK_CLUSTER_NAME, emrHelper.getAwsParamsDto()); assertNotNull(clusterSummary); assertEquals(clusterId, clusterSummary.getId()); }
/** * This method tests the blank proxy details */ @Test public void testEmrAwsDtoBlankProxy() throws Exception { // Set the proxy as blank too to get the EMR client without proxy AwsParamsDto awsParamsDto = emrHelper.getAwsParamsDto(); awsParamsDto.setHttpProxyHost(""); emrDao.getEmrClient(awsParamsDto); }
/** * This method tests the blank EC2 tags */ @Test public void testCreateEmrClusterBlankTags() throws Exception { // Create the namespace entity. namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE); String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()); EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml); // Add new node tags. First tag does not contain any tag value; but contains node tag name NodeTag nodeTag1 = new NodeTag(); nodeTag1.setTagName("NO_TAG_VALUE"); // Second tag does not contain node tag name; but contains node tag value NodeTag nodeTag2 = new NodeTag(); nodeTag2.setTagValue("NO_TAG_NAME"); // Create the list and add the tags ArrayList<NodeTag> nodeTagList = new ArrayList<>(); nodeTagList.add(nodeTag1); nodeTagList.add(nodeTag2); // Set the tags emrClusterDefinition.setNodeTags(nodeTagList); emrDao.createEmrCluster(EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinition, emrHelper.getAwsParamsDto()); }
emrDao.addEmrStep(emrCluster.getId(), stepHelper.getEmrStepConfig(emrStep), emrHelper.getAwsParamsDto());
@Test public void testDeleteSourceFileFromS3() { // Create and persists entities required for testing. // Create source and target business object data entities. BusinessObjectDataEntity sourceBusinessObjectDataEntity = businessObjectDataDaoTestHelper .createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, INITIAL_DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.RE_ENCRYPTING); BusinessObjectDataEntity targetBusinessObjectDataEntity = businessObjectDataDaoTestHelper .createBusinessObjectDataEntity(NAMESPACE_2, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, INITIAL_FORMAT_VERSION, PARTITION_VALUE, INITIAL_DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.RE_ENCRYPTING); // Put a 1 KB file in S3. s3Operations.putObject( new PutObjectRequest(storageDaoTestHelper.getS3LoadingDockBucketName(), TARGET_S3_KEY, new ByteArrayInputStream(new byte[(int) FILE_SIZE_1_KB]), null), null); // Initialize parameters required to delete the S3 source file CompleteUploadSingleParamsDto completeUploadSingleParamsDto = new CompleteUploadSingleParamsDto(businessObjectDataHelper.getBusinessObjectDataKey(sourceBusinessObjectDataEntity), storageDaoTestHelper.getS3LoadingDockBucketName(), TARGET_S3_KEY, BusinessObjectDataStatusEntity.UPLOADING, BusinessObjectDataStatusEntity.RE_ENCRYPTING, businessObjectDataHelper.getBusinessObjectDataKey(targetBusinessObjectDataEntity), storageDaoTestHelper.getS3ExternalBucketName(), TARGET_S3_KEY, BusinessObjectDataStatusEntity.UPLOADING, BusinessObjectDataStatusEntity.RE_ENCRYPTING, MockS3OperationsImpl.MOCK_KMS_ID, emrHelper.getAwsParamsDto()); // Delete the source file from S3 uploadDownloadHelperService.deleteSourceFileFromS3(completeUploadSingleParamsDto); }
BusinessObjectDataStatusEntity.RE_ENCRYPTING, businessObjectDataHelper.getBusinessObjectDataKey(targetBusinessObjectDataEntity), storageDaoTestHelper.getS3ExternalBucketName(), TARGET_S3_KEY, BusinessObjectDataStatusEntity.UPLOADING, BusinessObjectDataStatusEntity.RE_ENCRYPTING, MockS3OperationsImpl.MOCK_KMS_ID, emrHelper.getAwsParamsDto());
BusinessObjectDataStatusEntity.RE_ENCRYPTING, businessObjectDataHelper.getBusinessObjectDataKey(targetBusinessObjectDataEntity), storageDaoTestHelper.getS3ExternalBucketName(), TARGET_S3_KEY, BusinessObjectDataStatusEntity.RE_ENCRYPTING, BusinessObjectDataStatusEntity.VALID, MockS3OperationsImpl.MOCK_KMS_ID, emrHelper.getAwsParamsDto());
BusinessObjectDataStatusEntity.RE_ENCRYPTING, businessObjectDataHelper.getBusinessObjectDataKey(targetBusinessObjectDataEntity), storageDaoTestHelper.getS3ExternalBucketName(), TARGET_S3_KEY, BusinessObjectDataStatusEntity.RE_ENCRYPTING, BusinessObjectDataStatusEntity.VALID, MockS3OperationsImpl.MOCK_KMS_ID, emrHelper.getAwsParamsDto());
BusinessObjectDataStatusEntity.RE_ENCRYPTING, businessObjectDataHelper.getBusinessObjectDataKey(targetBusinessObjectDataEntity), storageDaoTestHelper.getS3ExternalBucketName(), TARGET_S3_KEY, BusinessObjectDataStatusEntity.RE_ENCRYPTING, BusinessObjectDataStatusEntity.INVALID, MockS3OperationsImpl.MOCK_KMS_ID, emrHelper.getAwsParamsDto());
BusinessObjectDataStatusEntity.RE_ENCRYPTING, businessObjectDataHelper.getBusinessObjectDataKey(targetBusinessObjectDataEntity), EMPTY_S3_BUCKET_NAME, MockS3OperationsImpl.MOCK_S3_FILE_NAME_SERVICE_EXCEPTION, BusinessObjectDataStatusEntity.UPLOADING, BusinessObjectDataStatusEntity.RE_ENCRYPTING, MockS3OperationsImpl.MOCK_KMS_ID, emrHelper.getAwsParamsDto());
NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION), EMPTY_S3_BUCKET_NAME, MockS3OperationsImpl.MOCK_S3_FILE_NAME_SERVICE_EXCEPTION, BusinessObjectDataStatusEntity.UPLOADING, BusinessObjectDataStatusEntity.RE_ENCRYPTING, MockS3OperationsImpl.MOCK_KMS_ID, emrHelper.getAwsParamsDto()); uploadDownloadHelperServiceImpl.performFileMove(completeUploadSingleParamsDto);