Search in sources :

Example 26 with MasterInstanceDefinition

use of org.finra.herd.model.api.xml.MasterInstanceDefinition in project herd by FINRAOS.

the class EmrPricingHelperTest method testBestPriceOnDemandNotFound.

/**
 * Tests case where spot price is found but no on-demand price was found for the specified subnet's region and instance type. This is a case where the
 * on-demand configuration table was not properly configured or the user specified invalid instance type.
 */
@Test
public void testBestPriceOnDemandNotFound() {
    String subnetId = SUBNET_5;
    MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
    masterInstanceDefinition.setInstanceCount(1);
    masterInstanceDefinition.setInstanceType(INVALID_VALUE);
    InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
    coreInstanceDefinition.setInstanceCount(1);
    coreInstanceDefinition.setInstanceType(INSTANCE_TYPE_2);
    InstanceDefinition taskInstanceDefinition = null;
    try {
        updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
        fail("expected ObjectNotFoundException, but no exception was thrown");
    } catch (Exception e) {
        assertEquals("thrown exception", ObjectNotFoundException.class, e.getClass());
    }
}
Also used : InstanceDefinition(org.finra.herd.model.api.xml.InstanceDefinition) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AmazonServiceException(com.amazonaws.AmazonServiceException) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 27 with MasterInstanceDefinition

use of org.finra.herd.model.api.xml.MasterInstanceDefinition in project herd by FINRAOS.

the class EmrPricingHelperTest method testBestPriceExplicitSpotAndOnDemand.

/**
 * Test cases where user sets instances to explicitly use spot for master and on-demand for core by setting the instanceSpotPrice property and not
 * specifying criteria, respectively.
 */
@Test
public void testBestPriceExplicitSpotAndOnDemand() {
    String subnetId = SUBNET_1;
    MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
    masterInstanceDefinition.setInstanceCount(1);
    masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
    masterInstanceDefinition.setInstanceSpotPrice(ON_DEMAND);
    InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
    coreInstanceDefinition.setInstanceCount(1);
    coreInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
    InstanceDefinition taskInstanceDefinition = null;
    EmrClusterDefinition emrClusterDefinition = updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
    assertBestPriceCriteriaRemoved(emrClusterDefinition);
    assertEquals("master instance bid price", ON_DEMAND, emrClusterDefinition.getInstanceDefinitions().getMasterInstances().getInstanceSpotPrice());
    assertNull("core instance was not on-demand", emrClusterDefinition.getInstanceDefinitions().getCoreInstances().getInstanceSpotPrice());
}
Also used : InstanceDefinition(org.finra.herd.model.api.xml.InstanceDefinition) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 28 with MasterInstanceDefinition

use of org.finra.herd.model.api.xml.MasterInstanceDefinition in project herd by FINRAOS.

the class EmrPricingHelperTest method testBestPriceSpotInstanceNotFoundBecauseSpotPriceIsNotAvailable.

/**
 * Tests case where instance type was not found in the spot list because AWS does not have a spot price for the given instance type in the given AZ. But
 * there is another AZ available for that does have a all spot prices available.
 */
@Test
public void testBestPriceSpotInstanceNotFoundBecauseSpotPriceIsNotAvailable() {
    String subnetId = SUBNET_1 + "," + SUBNET_5;
    MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
    masterInstanceDefinition.setInstanceCount(1);
    masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_3);
    InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
    coreInstanceDefinition.setInstanceCount(1);
    coreInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
    InstanceDefinition taskInstanceDefinition = null;
    EmrClusterDefinition emrClusterDefinition = updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
    assertBestPriceCriteriaRemoved(emrClusterDefinition);
}
Also used : InstanceDefinition(org.finra.herd.model.api.xml.InstanceDefinition) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 29 with MasterInstanceDefinition

use of org.finra.herd.model.api.xml.MasterInstanceDefinition in project herd by FINRAOS.

the class EmrPricingHelperTest method testBestPricePickMultipleInstancesSelectCheaperCoreAndTask.

/**
 * Tests case where instance count affect subnet selection. Tests case given - master instance is very expensive in one AZ but cheaper in the other - core
 * instance is very cheap in one AZ but more expensive in the other When - Enough instances are specified such that the AZ with the very cheap core is
 * selected.
 * <p/>
 * Even though the master is more expensive, the cores are cheap enough that it overtakes the master's expense.
 * <p/>
 * Test case reference ClusterSpotPriceAlgorithm 13
 */
@Test
public void testBestPricePickMultipleInstancesSelectCheaperCoreAndTask() {
    String subnetId = SUBNET_1 + "," + SUBNET_4;
    MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
    masterInstanceDefinition.setInstanceCount(1);
    masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_2);
    masterInstanceDefinition.setInstanceSpotPrice(SPOT_PRICE_VERY_HIGH);
    InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
    coreInstanceDefinition.setInstanceCount(2);
    coreInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
    coreInstanceDefinition.setInstanceSpotPrice(ON_DEMAND);
    InstanceDefinition taskInstanceDefinition = new InstanceDefinition();
    taskInstanceDefinition.setInstanceCount(3);
    taskInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
    taskInstanceDefinition.setInstanceSpotPrice(ON_DEMAND);
    EmrClusterDefinition emrClusterDefinition = updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
    assertBestPriceCriteriaRemoved(emrClusterDefinition);
    assertEquals("master instance bid price", SPOT_PRICE_VERY_HIGH, emrClusterDefinition.getInstanceDefinitions().getMasterInstances().getInstanceSpotPrice());
    assertEquals("core instance bid price", ON_DEMAND, emrClusterDefinition.getInstanceDefinitions().getCoreInstances().getInstanceSpotPrice());
    assertEquals("task instance bid price", ON_DEMAND, emrClusterDefinition.getInstanceDefinitions().getTaskInstances().getInstanceSpotPrice());
    assertEquals("selected subnet", SUBNET_4, emrClusterDefinition.getSubnetId());
}
Also used : InstanceDefinition(org.finra.herd.model.api.xml.InstanceDefinition) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 30 with MasterInstanceDefinition

use of org.finra.herd.model.api.xml.MasterInstanceDefinition in project herd by FINRAOS.

the class EmrPricingHelperTest method testBestPriceSubnetIsEmpty.

/**
 * Tests case where subnet is empty. This should default to searching all subnets.
 */
@Test
public void testBestPriceSubnetIsEmpty() {
    String subnetId = "";
    MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
    masterInstanceDefinition.setInstanceCount(1);
    masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
    InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
    coreInstanceDefinition.setInstanceCount(1);
    coreInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
    InstanceDefinition taskInstanceDefinition = null;
    EmrClusterDefinition emrClusterDefinition = updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
    assertBestPriceCriteriaRemoved(emrClusterDefinition);
    assertTrue("subnet was not selected", StringUtils.isNotBlank(emrClusterDefinition.getSubnetId()));
}
Also used : InstanceDefinition(org.finra.herd.model.api.xml.InstanceDefinition) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Aggregations

MasterInstanceDefinition (org.finra.herd.model.api.xml.MasterInstanceDefinition)37 InstanceDefinition (org.finra.herd.model.api.xml.InstanceDefinition)36 Test (org.junit.Test)32 AbstractDaoTest (org.finra.herd.dao.AbstractDaoTest)28 EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)23 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)8 InstanceDefinitions (org.finra.herd.model.api.xml.InstanceDefinitions)8 AmazonServiceException (com.amazonaws.AmazonServiceException)5 NodeTag (org.finra.herd.model.api.xml.NodeTag)5 InstanceGroupConfig (com.amazonaws.services.elasticmapreduce.model.InstanceGroupConfig)4 RunJobFlowRequest (com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest)4 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 BigDecimal (java.math.BigDecimal)3 ArrayList (java.util.ArrayList)3 EmrVpcPricingState (org.finra.herd.model.dto.EmrVpcPricingState)3 HashMap (java.util.HashMap)2 ClientConfiguration (com.amazonaws.ClientConfiguration)1 AvailabilityZone (com.amazonaws.services.ec2.model.AvailabilityZone)1 Subnet (com.amazonaws.services.ec2.model.Subnet)1