Search in sources :

Example 16 with EmrClusterDefinition

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

the class EmrClusterDefinitionServiceTest method testUpdateEmrClusterDefinitionDuplicateNodeTags.

@Test
public void testUpdateEmrClusterDefinitionDuplicateNodeTags() throws Exception {
    // Try to perform an update by passing duplicate node tag names.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        for (int i = 0; i < 2; i++) {
            NodeTag nodeTag = new NodeTag();
            nodeTag.setTagName(ATTRIBUTE_NAME_1_MIXED_CASE);
            nodeTag.setTagValue(ATTRIBUTE_VALUE_1);
            emrClusterDefinitionConfiguration.getNodeTags().add(nodeTag);
        }
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when duplicate node tag names are specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Duplicate node tag \"%s\" is found.", ATTRIBUTE_NAME_1_MIXED_CASE), e.getMessage());
    }
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) NodeTag(org.finra.herd.model.api.xml.NodeTag) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) Test(org.junit.Test)

Example 17 with EmrClusterDefinition

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

the class EmrClusterDefinitionServiceTest method testUpdateEmrClusterDefinitionMissingRequiredParameters.

@Test
public void testUpdateEmrClusterDefinitionMissingRequiredParameters() throws Exception {
    // Try to perform an update without specifying a namespace.
    try {
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(BLANK_TEXT, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH)));
        fail("Should throw an IllegalArgumentException when namespace is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    // Try to perform an update without specifying an EMR cluster definition name.
    try {
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, BLANK_TEXT), createEmrClusterDefinitionUpdateRequest(getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH)));
        fail("Should throw an IllegalArgumentException when EMR cluster definition name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An EMR cluster definition name must be specified.", e.getMessage());
    }
    // Try to perform an update without specifying an EMR cluster definition configuration.
    try {
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(null));
        fail("Should throw an IllegalArgumentException when EMR cluster definition configuration is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An EMR cluster definition configuration must be specified.", e.getMessage());
    }
    // Try to perform an update without specifying both instance definitions and instance fleets.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.setInstanceDefinitions(null);
        emrClusterDefinitionConfiguration.setInstanceFleets(null);
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(emrClusterDefinitionConfiguration));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Instance group definitions or instance fleets must be specified.", e.getMessage());
    }
    // Try to perform an update without specifying master instances.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.getInstanceDefinitions().setMasterInstances(null);
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when master instances are not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("Master instances must be specified.", e.getMessage());
    }
    // Try to perform an update with instance count less than one for master instances.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.getInstanceDefinitions().getMasterInstances().setInstanceCount(0);
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when instance count is less than one for master instances.");
    } catch (IllegalArgumentException e) {
        assertEquals("At least 1 master instance must be specified.", e.getMessage());
    }
    // Try to perform an update without specifying instance type for master instances.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.getInstanceDefinitions().getMasterInstances().setInstanceType(BLANK_TEXT);
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when instance type for master instances is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An instance type for master instances must be specified.", e.getMessage());
    }
    // Try to perform an update with instance count less than 0 for core instances.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.getInstanceDefinitions().getCoreInstances().setInstanceCount(-1);
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when instance count is less than one for core instances.");
    } catch (IllegalArgumentException e) {
        assertEquals("At least 0 core instance must be specified.", e.getMessage());
    }
    // Try to perform an update without specifying instance type for core instances.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.getInstanceDefinitions().getCoreInstances().setInstanceType(BLANK_TEXT);
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when instance type for core instances is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An instance type for core instances must be specified.", e.getMessage());
    }
    // Try to perform an update without specifying node tags.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.setNodeTags(new ArrayList<NodeTag>());
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when node tags are not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("Node tags must be specified.", e.getMessage());
    }
    // Try to perform an update without specifying node tag name.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        NodeTag nodeTag = new NodeTag();
        nodeTag.setTagName(BLANK_TEXT);
        nodeTag.setTagValue(ATTRIBUTE_VALUE_1);
        emrClusterDefinitionConfiguration.getNodeTags().add(nodeTag);
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when node tag name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A node tag name must be specified.", e.getMessage());
    }
    // Try to perform an update without specifying node tag value.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        NodeTag nodeTag = new NodeTag();
        nodeTag.setTagName(ATTRIBUTE_NAME_1_MIXED_CASE);
        nodeTag.setTagValue(BLANK_TEXT);
        emrClusterDefinitionConfiguration.getNodeTags().add(nodeTag);
        emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when node tag value is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A node tag value must be specified.", e.getMessage());
    }
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) NodeTag(org.finra.herd.model.api.xml.NodeTag) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) Test(org.junit.Test)

Example 18 with EmrClusterDefinition

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

the class EmrClusterDefinitionServiceTest method testCreateEmrClusterDefinitionMissingRequiredParameters.

@Test
public void testCreateEmrClusterDefinitionMissingRequiredParameters() throws Exception {
    // Try to perform a create without specifying a namespace.
    try {
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(BLANK_TEXT, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH)));
        fail("Should throw an IllegalArgumentException when namespace is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    // Try to perform a create without specifying an EMR cluster definition name.
    try {
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, BLANK_TEXT, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH)));
        fail("Should throw an IllegalArgumentException when EMR cluster definition name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An EMR cluster definition name must be specified.", e.getMessage());
    }
    // Try to perform a create without specifying an EMR cluster definition configuration.
    try {
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, null));
        fail("Should throw an IllegalArgumentException when EMR cluster definition configuration is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An EMR cluster definition configuration must be specified.", e.getMessage());
    }
    // Try to perform a create without specifying both instance definitions and instance fleets.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.setInstanceDefinitions(null);
        emrClusterDefinitionConfiguration.setInstanceFleets(null);
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinitionConfiguration));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Instance group definitions or instance fleets must be specified.", e.getMessage());
    }
    // Try to perform a create without specifying master instances.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.getInstanceDefinitions().setMasterInstances(null);
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when master instances are not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("Master instances must be specified.", e.getMessage());
    }
    // Try to perform a create with instance count less than one for master instances.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.getInstanceDefinitions().getMasterInstances().setInstanceCount(0);
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when instance count is less than one for master instances.");
    } catch (IllegalArgumentException e) {
        assertEquals("At least 1 master instance must be specified.", e.getMessage());
    }
    // Try to perform a create without specifying instance type for master instances.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.getInstanceDefinitions().getMasterInstances().setInstanceType(BLANK_TEXT);
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when instance type for master instances is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An instance type for master instances must be specified.", e.getMessage());
    }
    // Try to perform a create with instance count less than 0 for core instances.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.getInstanceDefinitions().getCoreInstances().setInstanceCount(-1);
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when instance count is less than one for core instances.");
    } catch (IllegalArgumentException e) {
        assertEquals("At least 0 core instance must be specified.", e.getMessage());
    }
    // Try to perform a create without specifying instance type for core instances.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.getInstanceDefinitions().getCoreInstances().setInstanceType(BLANK_TEXT);
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when instance type for core instances is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An instance type for core instances must be specified.", e.getMessage());
    }
    // Try to perform a create without specifying node tags.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        emrClusterDefinitionConfiguration.setNodeTags(new ArrayList<NodeTag>());
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when node tags are not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("Node tags must be specified.", e.getMessage());
    }
    // Try to perform a create without specifying node tag name.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        NodeTag nodeTag = new NodeTag();
        nodeTag.setTagName(BLANK_TEXT);
        nodeTag.setTagValue(ATTRIBUTE_VALUE_1);
        emrClusterDefinitionConfiguration.getNodeTags().add(nodeTag);
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when node tag name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A node tag name must be specified.", e.getMessage());
    }
    // Try to perform a create without specifying node tag value.
    try {
        EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
        NodeTag nodeTag = new NodeTag();
        nodeTag.setTagName(ATTRIBUTE_NAME_1_MIXED_CASE);
        nodeTag.setTagValue(BLANK_TEXT);
        emrClusterDefinitionConfiguration.getNodeTags().add(nodeTag);
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when node tag value is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A node tag value must be specified.", e.getMessage());
    }
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) NodeTag(org.finra.herd.model.api.xml.NodeTag) Test(org.junit.Test)

Example 19 with EmrClusterDefinition

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

the class EmrServiceTest method testCreateEmrClusterInstanceNotDefined.

/**
 * This method tests the error cases for Illegal Arguments for Instances not defined properly
 */
@Test
public void testCreateEmrClusterInstanceNotDefined() throws Exception {
    // Create the namespace entity.
    NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    // Create the test EMR cluster definition entity with missing instance definitions.
    String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH).getInputStream());
    EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
    emrClusterDefinition.setInstanceDefinitions(null);
    configXml = xmlHelper.objectToXml(emrClusterDefinition);
    emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
    // Try to create a new EMR cluster using EMR cluster definition with missing both instance definitions and instance fleets.
    EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
    try {
        emrService.createCluster(request);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Instance group definitions or instance fleets must be specified.", 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) Test(org.junit.Test)

Example 20 with EmrClusterDefinition

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

the class EmrServiceTest method testCreateEmrClusterOverrideList.

@Test
public void testCreateEmrClusterOverrideList() 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
    EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
    EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition();
    emrClusterDefinitionOverride.setApplications(Collections.<EmrClusterDefinitionApplication>emptyList());
    expectedEmrClusterDefinition.setApplications(emrClusterDefinitionOverride.getApplications());
    emrClusterDefinitionOverride.setConfigurations(Collections.<EmrClusterDefinitionConfiguration>emptyList());
    expectedEmrClusterDefinition.setConfigurations(emrClusterDefinitionOverride.getConfigurations());
    emrClusterDefinitionOverride.setCustomBootstrapActionAll(Collections.<ScriptDefinition>emptyList());
    expectedEmrClusterDefinition.setCustomBootstrapActionAll(emrClusterDefinitionOverride.getCustomBootstrapActionAll());
    emrClusterDefinitionOverride.setCustomBootstrapActionMaster(Collections.<ScriptDefinition>emptyList());
    expectedEmrClusterDefinition.setCustomBootstrapActionMaster(emrClusterDefinitionOverride.getCustomBootstrapActionMaster());
    emrClusterDefinitionOverride.setDaemonConfigurations(Collections.<Parameter>emptyList());
    expectedEmrClusterDefinition.setDaemonConfigurations(emrClusterDefinitionOverride.getDaemonConfigurations());
    emrClusterDefinitionOverride.setHadoopConfigurations(Collections.<Serializable>emptyList());
    expectedEmrClusterDefinition.setHadoopConfigurations(emrClusterDefinitionOverride.getHadoopConfigurations());
    emrClusterDefinitionOverride.setHadoopJarSteps(Collections.<HadoopJarStep>emptyList());
    expectedEmrClusterDefinition.setHadoopJarSteps(emrClusterDefinitionOverride.getHadoopJarSteps());
    emrClusterDefinitionOverride.setAdditionalMasterSecurityGroups(Collections.emptyList());
    expectedEmrClusterDefinition.setAdditionalMasterSecurityGroups(emrClusterDefinitionOverride.getAdditionalMasterSecurityGroups());
    emrClusterDefinitionOverride.setAdditionalSlaveSecurityGroups(Collections.emptyList());
    expectedEmrClusterDefinition.setAdditionalSlaveSecurityGroups(emrClusterDefinitionOverride.getAdditionalSlaveSecurityGroups());
    List<NodeTag> nodeTags = expectedEmrClusterDefinition.getNodeTags();
    nodeTags.add(new NodeTag("testTag", "test"));
    emrClusterDefinitionOverride.setNodeTags(nodeTags);
    expectedEmrClusterDefinition.setNodeTags(nodeTags);
    request.setEmrClusterDefinitionOverride(emrClusterDefinitionOverride);
    EmrCluster emrCluster = emrService.createCluster(request);
    // Validate the returned object against the input.
    assertNotNull(emrCluster);
    assertTrue(emrCluster.getNamespace().equals(request.getNamespace()));
    assertTrue(emrCluster.getEmrClusterDefinitionName().equals(request.getEmrClusterDefinitionName()));
    assertTrue(emrCluster.getEmrClusterName().equals(request.getEmrClusterName()));
    assertNotNull(emrCluster.getId());
    assertNull(emrCluster.isDryRun());
    assertTrue(emrCluster.isEmrClusterCreated());
    assertNotNull(emrCluster.getEmrClusterDefinition());
    assertEquals(expectedEmrClusterDefinition, emrCluster.getEmrClusterDefinition());
    validateEmrClusterCreationLogUnique(emrCluster, expectedEmrClusterDefinition);
}
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) NodeTag(org.finra.herd.model.api.xml.NodeTag) EmrCluster(org.finra.herd.model.api.xml.EmrCluster) Test(org.junit.Test)

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