use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrClusterDefinitionHelperTest method testValidateEmrClusterDefinitionConfigurationTaskInstanceDefinitionNotSpecified.
/**
* Tests case where validation is run against the definition generated by createValidEmrClusterDefinition() The task instance is not specified. The
* definition should be valid because task instance is optional.
*/
@Test
public void testValidateEmrClusterDefinitionConfigurationTaskInstanceDefinitionNotSpecified() {
EmrClusterDefinition emrClusterDefinition = createValidEmrClusterDefinition();
emrClusterDefinition.getInstanceDefinitions().setTaskInstances(null);
try {
emrClusterDefinitionHelper.validateEmrClusterDefinitionConfiguration(emrClusterDefinition);
} catch (Exception e) {
fail("expected no exception, but " + e.getClass() + " was thrown. " + e);
}
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrClusterDefinitionHelperTest method testValidateEmrClusterDefinitionConfigurationMasterMaxSearchPriceSpecifiedAndOnDemandThresholdNegative.
/**
* Tests case where validation is run against the definition generated by createValidEmrClusterDefinition() The master instance on-demand threshold is
* negative. The definition is not valid. All prices must be positive.
*/
@Test
public void testValidateEmrClusterDefinitionConfigurationMasterMaxSearchPriceSpecifiedAndOnDemandThresholdNegative() {
EmrClusterDefinition emrClusterDefinition = createValidEmrClusterDefinition();
emrClusterDefinition.getInstanceDefinitions().getMasterInstances().setInstanceMaxSearchPrice(BigDecimal.ONE);
emrClusterDefinition.getInstanceDefinitions().getMasterInstances().setInstanceOnDemandThreshold(BigDecimal.ONE.negate());
try {
emrClusterDefinitionHelper.validateEmrClusterDefinitionConfiguration(emrClusterDefinition);
fail("expected IllegalArgumentException, but no exception was thrown");
} catch (IllegalArgumentException e) {
assertEquals("Master instance on-demand threshold must be greater than 0", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrClusterDefinitionHelperTest method createValidEmrClusterDefinition.
/**
* Creates a EMR cluster definition which does not cause validateEmrClusterDefinitionConfiguration() to throw an exception.
* <p/>
* - One subnet is specified - Master, core, and task instances are specified - Instance count, and instance type are specified for each instance
* definition. - One node tag is specified
*
* @return A new instance of {@link EmrClusterDefinition}
*/
private EmrClusterDefinition createValidEmrClusterDefinition() {
EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition();
emrClusterDefinition.setSubnetId(MockEc2OperationsImpl.SUBNET_1);
InstanceDefinitions instanceDefinitions = new InstanceDefinitions();
MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
masterInstanceDefinition.setInstanceCount(1);
masterInstanceDefinition.setInstanceType(MockEc2OperationsImpl.INSTANCE_TYPE_1);
instanceDefinitions.setMasterInstances(masterInstanceDefinition);
InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
coreInstanceDefinition.setInstanceCount(1);
coreInstanceDefinition.setInstanceType(MockEc2OperationsImpl.INSTANCE_TYPE_1);
instanceDefinitions.setCoreInstances(coreInstanceDefinition);
InstanceDefinition taskInstanceDefinition = new InstanceDefinition();
taskInstanceDefinition.setInstanceCount(1);
taskInstanceDefinition.setInstanceType(MockEc2OperationsImpl.INSTANCE_TYPE_1);
instanceDefinitions.setTaskInstances(taskInstanceDefinition);
emrClusterDefinition.setInstanceDefinitions(instanceDefinitions);
List<NodeTag> nodeTags = new ArrayList<>();
{
nodeTags.add(new NodeTag("test_nodeTagName", "test_nodeTagValue"));
}
emrClusterDefinition.setNodeTags(nodeTags);
return emrClusterDefinition;
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrClusterDefinitionHelperTest method testValidateEmrClusterDefinitionConfigurationMasterSpotPriceSpecified.
/**
* Tests case where validation is run against the definition generated by createValidEmrClusterDefinition() The master instance spot price is specified The
* definition should be valid because spot price is allowed when max search price is not specified.
*/
@Test
public void testValidateEmrClusterDefinitionConfigurationMasterSpotPriceSpecified() {
EmrClusterDefinition emrClusterDefinition = createValidEmrClusterDefinition();
emrClusterDefinition.getInstanceDefinitions().getMasterInstances().setInstanceSpotPrice(BigDecimal.ONE);
try {
emrClusterDefinitionHelper.validateEmrClusterDefinitionConfiguration(emrClusterDefinition);
} catch (Exception e) {
fail("expected no exception, but " + e.getClass() + " was thrown. " + e);
}
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrClusterDefinitionHelperTest method testValidateEmrClusterDefinitionConfigurationSubnetListBlankElement.
/**
* Tests case where validation is run against the definition generated by createValidEmrClusterDefinition() The subnet is a list, and contains at least 1
* whitespace-only element The definition is not valid. All elements in subnet list must not be blank.
*/
@Test
public void testValidateEmrClusterDefinitionConfigurationSubnetListBlankElement() {
EmrClusterDefinition emrClusterDefinition = createValidEmrClusterDefinition();
emrClusterDefinition.setSubnetId(MockEc2OperationsImpl.SUBNET_1 + ", \r\t\n");
try {
emrClusterDefinitionHelper.validateEmrClusterDefinitionConfiguration(emrClusterDefinition);
fail("expected IllegalArgumentException, but no exception was thrown");
} catch (Exception e) {
assertEquals("thrown exception", IllegalArgumentException.class, e.getClass());
}
}
Aggregations