use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrPricingHelperTest method testCoreInstanceNullSubnetInMultipleAzAssertSuccess.
@Test
public void testCoreInstanceNullSubnetInMultipleAzAssertSuccess() throws Exception {
String subnetId = SUBNET_1 + "," + SUBNET_3;
MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
masterInstanceDefinition.setInstanceCount(1);
masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
InstanceDefinition coreInstanceDefinition = null;
InstanceDefinition taskInstanceDefinition = null;
EmrClusterDefinition emrClusterDefinition = updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
// we select the pricing randomly so either one can be chosen
assertTrue(Arrays.asList(SUBNET_1, SUBNET_3).contains(emrClusterDefinition.getSubnetId()));
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition 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;
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition 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());
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition 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);
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition 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());
}
Aggregations