Search in sources :

Example 6 with NodeTag

use of org.finra.herd.model.api.xml.NodeTag 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 7 with NodeTag

use of org.finra.herd.model.api.xml.NodeTag 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 8 with NodeTag

use of org.finra.herd.model.api.xml.NodeTag 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)

Example 9 with NodeTag

use of org.finra.herd.model.api.xml.NodeTag 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 10 with NodeTag

use of org.finra.herd.model.api.xml.NodeTag 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)

Aggregations

NodeTag (org.finra.herd.model.api.xml.NodeTag)14 EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)12 Test (org.junit.Test)11 RunJobFlowRequest (com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest)5 ArrayList (java.util.ArrayList)5 InstanceDefinition (org.finra.herd.model.api.xml.InstanceDefinition)5 InstanceDefinitions (org.finra.herd.model.api.xml.InstanceDefinitions)5 MasterInstanceDefinition (org.finra.herd.model.api.xml.MasterInstanceDefinition)5 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)5 InvocationOnMock (org.mockito.invocation.InvocationOnMock)5 InstanceGroupConfig (com.amazonaws.services.elasticmapreduce.model.InstanceGroupConfig)2 JobFlowInstancesConfig (com.amazonaws.services.elasticmapreduce.model.JobFlowInstancesConfig)2 Tag (com.amazonaws.services.elasticmapreduce.model.Tag)2 List (java.util.List)2 EmrClusterDefinitionKey (org.finra.herd.model.api.xml.EmrClusterDefinitionKey)2 ClientConfiguration (com.amazonaws.ClientConfiguration)1 Application (com.amazonaws.services.elasticmapreduce.model.Application)1 BootstrapActionConfig (com.amazonaws.services.elasticmapreduce.model.BootstrapActionConfig)1 Configuration (com.amazonaws.services.elasticmapreduce.model.Configuration)1 InstanceFleetConfig (com.amazonaws.services.elasticmapreduce.model.InstanceFleetConfig)1