Search in sources :

Example 41 with EmrClusterDefinition

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

the class EmrServiceWithAccountIdTest method getNewEmrClusterCreateRequestWithAccountId.

/**
 * This method fills-up the parameters required for the EMR cluster create request, with overridden AWS account Id.
 */
private EmrClusterCreateRequest getNewEmrClusterCreateRequestWithAccountId() throws Exception {
    // Create the definition.
    EmrClusterCreateRequest request = new EmrClusterCreateRequest();
    // Fill in the parameters.
    request.setNamespace(NAMESPACE);
    request.setEmrClusterDefinitionName(EMR_CLUSTER_DEFINITION_NAME);
    request.setEmrClusterName("UT_EMR_CLUSTER-" + Math.random());
    EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition();
    request.setEmrClusterDefinitionOverride(emrClusterDefinitionOverride);
    emrClusterDefinitionOverride.setAccountId(AWS_ACCOUNT_ID);
    return request;
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) EmrClusterCreateRequest(org.finra.herd.model.api.xml.EmrClusterCreateRequest)

Example 42 with EmrClusterDefinition

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

the class EmrServiceWithAccountIdTest method testCreateEmrClusterWithAccountIdAccountNoExists.

@Test
public void testCreateEmrClusterWithAccountIdAccountNoExists() throws Exception {
    // Create the namespace entity.
    NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    String definitionXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream());
    EmrClusterDefinition expectedEmrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, definitionXml);
    emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, definitionXml);
    // Create a new EMR cluster create request and add an account id to the EMR cluster definition override.
    EmrClusterCreateRequest emrClusterCreateRequest = getNewEmrClusterCreateRequestWithAccountId();
    EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition();
    emrClusterCreateRequest.setEmrClusterDefinitionOverride(emrClusterDefinitionOverride);
    emrClusterDefinitionOverride.setAccountId(AWS_ACCOUNT_ID);
    // Try to create an EMR cluster using a non-existing AWS account.
    try {
        emrService.createCluster(emrClusterCreateRequest);
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Trusting AWS account with id \"%s\" doesn't exist.", AWS_ACCOUNT_ID), e.getMessage());
    }
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) EmrClusterCreateRequest(org.finra.herd.model.api.xml.EmrClusterCreateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Example 43 with EmrClusterDefinition

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

the class EmrHelperTest method testCreateEmrClusterBlankTags.

/**
 * This method tests the blank EC2 tags
 */
@Test
public void testCreateEmrClusterBlankTags() throws Exception {
    // Create the namespace entity.
    namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream());
    EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
    // Add new node tags. First tag does not contain any tag value; but contains node tag name
    NodeTag nodeTag1 = new NodeTag();
    nodeTag1.setTagName("NO_TAG_VALUE");
    // Second tag does not contain node tag name; but contains node tag value
    NodeTag nodeTag2 = new NodeTag();
    nodeTag2.setTagValue("NO_TAG_NAME");
    // Create the list and add the tags
    ArrayList<NodeTag> nodeTagList = new ArrayList<>();
    nodeTagList.add(nodeTag1);
    nodeTagList.add(nodeTag2);
    // Set the tags
    emrClusterDefinition.setNodeTags(nodeTagList);
    emrDao.createEmrCluster(EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinition, emrHelper.getAwsParamsDto());
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) NodeTag(org.finra.herd.model.api.xml.NodeTag) ArrayList(java.util.ArrayList) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 44 with EmrClusterDefinition

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

the class EmrClusterDefinitionHelperTest method testValidateEmrClusterDefinitionConfigurationMasterOnDemandThresholdSpecified.

/**
 * Tests case where validation is run against the definition generated by createValidEmrClusterDefinition() The master instance on-demand threshold is
 * specified. The definition is not valid. On-demand threshold is only allowed when max search price is specified.
 */
@Test
public void testValidateEmrClusterDefinitionConfigurationMasterOnDemandThresholdSpecified() {
    EmrClusterDefinition emrClusterDefinition = createValidEmrClusterDefinition();
    emrClusterDefinition.getInstanceDefinitions().getMasterInstances().setInstanceOnDemandThreshold(BigDecimal.ONE);
    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)

Example 45 with EmrClusterDefinition

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

the class EmrClusterDefinitionHelperTest method testValidateEmrClusterDefinitionConfigurationCoreInstancesNotSpecified.

@Test
public void testValidateEmrClusterDefinitionConfigurationCoreInstancesNotSpecified() {
    EmrClusterDefinition emrClusterDefinition = createValidEmrClusterDefinition();
    emrClusterDefinition.getInstanceDefinitions().setCoreInstances(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)

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