Search in sources :

Example 46 with EmrClusterDefinition

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

Example 47 with EmrClusterDefinition

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

Example 48 with EmrClusterDefinition

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;
}
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) NodeTag(org.finra.herd.model.api.xml.NodeTag) ArrayList(java.util.ArrayList) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) InstanceDefinitions(org.finra.herd.model.api.xml.InstanceDefinitions)

Example 49 with 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);
    }
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 50 with EmrClusterDefinition

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

Aggregations

EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)101 Test (org.junit.Test)94 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)40 EmrClusterCreateRequest (org.finra.herd.model.api.xml.EmrClusterCreateRequest)39 EmrCluster (org.finra.herd.model.api.xml.EmrCluster)25 InstanceDefinition (org.finra.herd.model.api.xml.InstanceDefinition)24 MasterInstanceDefinition (org.finra.herd.model.api.xml.MasterInstanceDefinition)23 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)20 AbstractDaoTest (org.finra.herd.dao.AbstractDaoTest)18 NodeTag (org.finra.herd.model.api.xml.NodeTag)12 EmrClusterDefinitionKey (org.finra.herd.model.api.xml.EmrClusterDefinitionKey)9 InstanceDefinitions (org.finra.herd.model.api.xml.InstanceDefinitions)8 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)7 ArrayList (java.util.ArrayList)6 RunJobFlowRequest (com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest)5 HashMap (java.util.HashMap)5 EmrClusterDefinitionInformation (org.finra.herd.model.api.xml.EmrClusterDefinitionInformation)5 EmrClusterAlternateKeyDto (org.finra.herd.model.dto.EmrClusterAlternateKeyDto)5 InvocationOnMock (org.mockito.invocation.InvocationOnMock)5 EmrClusterDefinitionInstanceFleet (org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceFleet)4