Search in sources :

Example 31 with AwsParamsDto

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));
}
Also used : DescribeSpotPriceHistoryResult(com.amazonaws.services.ec2.model.DescribeSpotPriceHistoryResult) AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) Ec2DaoImpl(org.finra.herd.dao.impl.Ec2DaoImpl) Test(org.junit.Test)

Example 32 with AwsParamsDto

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);
}
Also used : AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 33 with 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));
    }
}
Also used : AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto)

Example 34 with AwsParamsDto

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);
}
Also used : AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) ClusterSummary(com.amazonaws.services.elasticmapreduce.model.ClusterSummary) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 35 with AwsParamsDto

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;
}
Also used : AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) EmrClusterAlternateKeyDto(org.finra.herd.model.dto.EmrClusterAlternateKeyDto) InstanceDefinitions(org.finra.herd.model.api.xml.InstanceDefinitions)

Aggregations

AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)67 Test (org.junit.Test)52 InvocationOnMock (org.mockito.invocation.InvocationOnMock)13 ClusterSummary (com.amazonaws.services.elasticmapreduce.model.ClusterSummary)11 ClientConfiguration (com.amazonaws.ClientConfiguration)9 ArrayList (java.util.ArrayList)9 ListClustersResult (com.amazonaws.services.elasticmapreduce.model.ListClustersResult)8 AbstractDaoTest (org.finra.herd.dao.AbstractDaoTest)8 EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)7 AmazonElasticMapReduceClient (com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduceClient)6 AmazonServiceException (com.amazonaws.AmazonServiceException)5 RunJobFlowRequest (com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest)5 NodeTag (org.finra.herd.model.api.xml.NodeTag)5 EmrClusterDefinitionEntity (org.finra.herd.model.jpa.EmrClusterDefinitionEntity)5 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)5 Cluster (com.amazonaws.services.elasticmapreduce.model.Cluster)4 DescribeClusterResult (com.amazonaws.services.elasticmapreduce.model.DescribeClusterResult)4 ListInstancesResult (com.amazonaws.services.elasticmapreduce.model.ListInstancesResult)4 List (java.util.List)4 InstanceDefinitions (org.finra.herd.model.api.xml.InstanceDefinitions)4