use of org.finra.herd.model.api.xml.InstanceDefinition in project herd by FINRAOS.
the class EmrPricingHelperTest method testBestPriceAlgorithmicMaxSearchPriceTooLow.
/**
* Tests algorithmic case when the max search price is lower than both spot and on-demand price. The update method should throw an error indicating that no
* subnets satisfied the given criteria.
* <p/>
* Test case reference ClusterSpotPriceAlgorithm 3
*/
@Test
public void testBestPriceAlgorithmicMaxSearchPriceTooLow() {
String subnetId = SUBNET_1;
MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
masterInstanceDefinition.setInstanceCount(1);
masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
masterInstanceDefinition.setInstanceMaxSearchPrice(SPOT_PRICE_LOW_LESS_ONE);
InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
coreInstanceDefinition.setInstanceCount(1);
coreInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
coreInstanceDefinition.setInstanceMaxSearchPrice(SPOT_PRICE_LOW_LESS_ONE);
InstanceDefinition taskInstanceDefinition = new InstanceDefinition();
taskInstanceDefinition.setInstanceCount(1);
taskInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
taskInstanceDefinition.setInstanceMaxSearchPrice(SPOT_PRICE_LOW_LESS_ONE);
// Try with both master, core, and task failing criteria
try {
updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
fail("Expected ObjectNotFoundException, but no exception was thrown");
} catch (Exception e) {
assertEquals("thrown exception", ObjectNotFoundException.class, e.getClass());
}
// Now try with only core and task failing criteria
masterInstanceDefinition.setInstanceMaxSearchPrice(ON_DEMAND);
try {
updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
fail("Expected ObjectNotFoundException, but no exception was thrown");
} catch (Exception e) {
assertEquals("thrown exception", ObjectNotFoundException.class, e.getClass());
}
// Try with only task failing criteria
coreInstanceDefinition.setInstanceMaxSearchPrice(ON_DEMAND);
try {
updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
fail("Expected ObjectNotFoundException, but no exception was thrown");
} catch (Exception e) {
assertEquals("thrown exception", ObjectNotFoundException.class, e.getClass());
}
}
use of org.finra.herd.model.api.xml.InstanceDefinition in project herd by FINRAOS.
the class EmrPricingHelperTest method testBestPriceMultipleRegions.
/**
* Tests case where subnet spans multiple regions, and one of the region has a cheaper price. The on-demand prices are identified by region, therefore this
* test case tests that the correct on-demand price is selected.
* <p/>
* Test case reference ClusterSpotPriceAlgorithm 14
*/
@Test
public void testBestPriceMultipleRegions() {
String subnetId = SUBNET_1 + "," + SUBNET_5;
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);
assertNull("master instance was not on-demand", emrClusterDefinition.getInstanceDefinitions().getMasterInstances().getInstanceSpotPrice());
assertNull("core instance was not on-demand", emrClusterDefinition.getInstanceDefinitions().getMasterInstances().getInstanceSpotPrice());
assertEquals("selected subnet", SUBNET_5, emrClusterDefinition.getSubnetId());
}
use of org.finra.herd.model.api.xml.InstanceDefinition in project herd by FINRAOS.
the class EmrPricingHelperTest method testBestPriceAlgorithmicSearchBelowOnDemandThresholdBelowOnDemand.
/**
* Tests case where max search price < on-demand, threshold < on-demand. The algorithm should select spot price because max search price is below
* on-demand.
* <p/>
* Test case reference ClusterSpotPriceAlgorithm 8
*/
@Test
public void testBestPriceAlgorithmicSearchBelowOnDemandThresholdBelowOnDemand() {
String subnetId = SUBNET_1;
MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
masterInstanceDefinition.setInstanceCount(1);
masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
masterInstanceDefinition.setInstanceMaxSearchPrice(ON_DEMAND_LESS_ONE);
masterInstanceDefinition.setInstanceOnDemandThreshold(ON_DEMAND_LESS_ONE.subtract(SPOT_PRICE_LOW));
InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
coreInstanceDefinition.setInstanceCount(1);
coreInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
coreInstanceDefinition.setInstanceMaxSearchPrice(ON_DEMAND_LESS_ONE);
coreInstanceDefinition.setInstanceOnDemandThreshold(ON_DEMAND_LESS_ONE.subtract(SPOT_PRICE_LOW));
InstanceDefinition taskInstanceDefinition = null;
EmrClusterDefinition emrClusterDefinition = updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
assertBestPriceCriteriaRemoved(emrClusterDefinition);
assertEquals("master instance bid price", ON_DEMAND_LESS_ONE, emrClusterDefinition.getInstanceDefinitions().getMasterInstances().getInstanceSpotPrice());
assertEquals("core instance bid price", ON_DEMAND_LESS_ONE, emrClusterDefinition.getInstanceDefinitions().getCoreInstances().getInstanceSpotPrice());
}
use of org.finra.herd.model.api.xml.InstanceDefinition in project herd by FINRAOS.
the class EmrPricingHelperTest method testBestPriceSubnetNotFound.
/**
* Tests case where at least one user specified subnet does not exist. This is a user error.
*/
@Test
public void testBestPriceSubnetNotFound() {
String subnetId = "I_DO_NOT_EXIST," + SUBNET_1;
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;
try {
updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
fail("expected ObjectNotFoundException, but no exception was thrown");
} catch (Exception e) {
assertEquals("thrown exception", ObjectNotFoundException.class, e.getClass());
}
}
use of org.finra.herd.model.api.xml.InstanceDefinition in project herd by FINRAOS.
the class EmrPricingHelperTest method testBestPriceAlgorithmicOnDemandOverMaxAndSpotGreaterThanOnDemand.
/**
* Tests 2 cases: Master spot is less than on-demand, max search price is less than on-demand, threshold is greater than on-demand. - Master should pick
* spot because even though on-demand is within the threshold, it is above the max Core spot > on-demand, max search price = spot - Core should pick
* on-demand since on-demand is cheaper
* <p/>
* Test case reference ClusterSpotPriceAlgorithm 4, 5
*/
@Test
public void testBestPriceAlgorithmicOnDemandOverMaxAndSpotGreaterThanOnDemand() {
String subnetId = SUBNET_1;
MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
masterInstanceDefinition.setInstanceCount(1);
masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
masterInstanceDefinition.setInstanceMaxSearchPrice(ON_DEMAND_LESS_ONE);
masterInstanceDefinition.setInstanceOnDemandThreshold(SPOT_PRICE_LOW_PLUS_ONE);
InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
coreInstanceDefinition.setInstanceCount(1);
coreInstanceDefinition.setInstanceType(INSTANCE_TYPE_3);
coreInstanceDefinition.setInstanceMaxSearchPrice(ON_DEMAND);
InstanceDefinition taskInstanceDefinition = null;
EmrClusterDefinition emrClusterDefinition = updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
assertBestPriceCriteriaRemoved(emrClusterDefinition);
assertEquals("master instance bid price", ON_DEMAND_LESS_ONE, emrClusterDefinition.getInstanceDefinitions().getMasterInstances().getInstanceSpotPrice());
assertNull("core instance was not on-demand", emrClusterDefinition.getInstanceDefinitions().getCoreInstances().getInstanceSpotPrice());
}
Aggregations