use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class Ec2DaoTest method testGetLatestSpotPricesAssertConstructsCorrectDescribeSpotPriceHistoryRequest.
@Test
public void testGetLatestSpotPricesAssertConstructsCorrectDescribeSpotPriceHistoryRequest() {
// Initialize inputs.
String availabilityZone = "a";
Collection<String> instanceTypes = Arrays.asList("a", "b", "c");
Collection<String> productDescriptions = Arrays.asList("b", "c", "d");
// Set up mock.
mock(RetryPolicyFactory.class);
Ec2Operations ec2Operations = mock(Ec2Operations.class);
((Ec2DaoImpl) ec2Dao).setEc2Operations(ec2Operations);
DescribeSpotPriceHistoryResult describeSpotPriceHistoryResult = new DescribeSpotPriceHistoryResult();
when(ec2Operations.describeSpotPriceHistory(any(), any())).thenReturn(describeSpotPriceHistoryResult);
// Execute MUT.
ec2Dao.getLatestSpotPrices(availabilityZone, instanceTypes, productDescriptions, new AwsParamsDto());
// Verify that the dependency was called with the correct parameters.
verify(ec2Operations).describeSpotPriceHistory(any(), equalsDescribeSpotPriceHistoryRequest(availabilityZone, instanceTypes, productDescriptions));
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrHelperTest method testEmrAwsDtoBlankProxy.
/**
* 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);
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class CreateEmrClusterTest method terminateCluster.
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));
}
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoImplTest method testGetActiveEmrClusterByNameWhenClusterNameIsBlank.
@Test
public void testGetActiveEmrClusterByNameWhenClusterNameIsBlank() {
// Create an AWS parameters DTO.
AwsParamsDto awsParamsDto = new AwsParamsDto(AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT);
// Call the method under test.
ClusterSummary result = emrDaoImpl.getActiveEmrClusterByName(BLANK_TEXT, awsParamsDto);
// Verify the external calls.
verifyNoMoreInteractionsHelper();
// Validate the results.
assertNull(result);
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrPricingHelperTest method updateEmrClusterDefinitionWithBestPrice.
/**
* Creates a new EMR cluster definition using the specified parameters, updates it with best price algorithm, and returns the definition.
*
* @param subnetId Subnet ID. Optional.
* @param masterInstanceDefinition The master instance definition
* @param coreInstanceDefinition The core instance definition
* @param taskInstanceDefinition The task instance definition. Optional.
*
* @return Updated EMR cluster definition.
*/
private EmrClusterDefinition updateEmrClusterDefinitionWithBestPrice(String subnetId, MasterInstanceDefinition masterInstanceDefinition, InstanceDefinition coreInstanceDefinition, InstanceDefinition taskInstanceDefinition) {
EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition();
emrClusterDefinition.setSubnetId(subnetId);
InstanceDefinitions instanceDefinitions = new InstanceDefinitions();
instanceDefinitions.setMasterInstances(masterInstanceDefinition);
instanceDefinitions.setCoreInstances(coreInstanceDefinition);
instanceDefinitions.setTaskInstances(taskInstanceDefinition);
emrClusterDefinition.setInstanceDefinitions(instanceDefinitions);
emrPricingHelper.updateEmrClusterDefinitionWithBestPrice(new EmrClusterAlternateKeyDto(), emrClusterDefinition, new AwsParamsDto());
return emrClusterDefinition;
}
Aggregations