Search in sources :

Example 11 with EmrClusterDefinition

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

the class EmrRestControllerTest method testCreateEmrCluster.

@Test
public void testCreateEmrCluster() throws Exception {
    // Create an EMR cluster definition override.
    EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition();
    // Create an EMR cluster create request.
    EmrClusterCreateRequest emrClusterCreateRequest = new EmrClusterCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME, DRY_RUN, emrClusterDefinitionOverride);
    // Create an EMR cluster.
    EmrCluster emrCluster = new EmrCluster();
    emrCluster.setId(EMR_CLUSTER_ID);
    // Mock the external calls.
    when(emrService.createCluster(emrClusterCreateRequest)).thenReturn(emrCluster);
    // Call the method under test.
    EmrCluster result = emrRestController.createEmrCluster(emrClusterCreateRequest);
    // Verify the external calls.
    verify(emrService).createCluster(emrClusterCreateRequest);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(emrCluster, result);
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) EmrClusterCreateRequest(org.finra.herd.model.api.xml.EmrClusterCreateRequest) EmrCluster(org.finra.herd.model.api.xml.EmrCluster) Test(org.junit.Test)

Example 12 with EmrClusterDefinition

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

the class EmrClusterDefinitionRestControllerTest method testCreateEmrClusterDefinition.

@Test
public void testCreateEmrClusterDefinition() throws Exception {
    // Create an EMR cluster definition key.
    EmrClusterDefinitionKey emrClusterDefinitionKey = new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME);
    // Create an EMR cluster definition.
    EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition();
    // Create an EMR cluster definition create request.
    EmrClusterDefinitionCreateRequest emrClusterDefinitionCreateRequest = new EmrClusterDefinitionCreateRequest(emrClusterDefinitionKey, emrClusterDefinition);
    // Create an object that holds EMR cluster definition information.
    EmrClusterDefinitionInformation emrClusterDefinitionInformation = new EmrClusterDefinitionInformation(ID, emrClusterDefinitionKey, emrClusterDefinition);
    // Mock the external calls.
    when(emrClusterDefinitionService.createEmrClusterDefinition(emrClusterDefinitionCreateRequest)).thenReturn(emrClusterDefinitionInformation);
    // Call the method under test.
    EmrClusterDefinitionInformation result = emrClusterDefinitionRestController.createEmrClusterDefinition(emrClusterDefinitionCreateRequest);
    // Verify the external calls.
    verify(emrClusterDefinitionService).createEmrClusterDefinition(emrClusterDefinitionCreateRequest);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(emrClusterDefinitionInformation, result);
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionCreateRequest(org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) Test(org.junit.Test)

Example 13 with EmrClusterDefinition

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

the class EmrClusterDefinitionRestControllerTest method testDeleteEmrClusterDefinition.

@Test
public void testDeleteEmrClusterDefinition() throws Exception {
    // Create an EMR cluster definition key.
    EmrClusterDefinitionKey emrClusterDefinitionKey = new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME);
    // Create an EMR cluster definition.
    EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition();
    // Create an object that holds EMR cluster definition information.
    EmrClusterDefinitionInformation emrClusterDefinitionInformation = new EmrClusterDefinitionInformation(ID, emrClusterDefinitionKey, emrClusterDefinition);
    // Mock the external calls.
    when(emrClusterDefinitionService.deleteEmrClusterDefinition(emrClusterDefinitionKey)).thenReturn(emrClusterDefinitionInformation);
    // Call the method under test.
    EmrClusterDefinitionInformation result = emrClusterDefinitionRestController.deleteEmrClusterDefinition(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME);
    // Verify the external calls.
    verify(emrClusterDefinitionService).deleteEmrClusterDefinition(emrClusterDefinitionKey);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(emrClusterDefinitionInformation, result);
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) Test(org.junit.Test)

Example 14 with EmrClusterDefinition

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

the class EmrClusterDefinitionServiceTest method testCreateEmrClusterDefinitionDuplicateNodeTags.

@Test
public void testCreateEmrClusterDefinitionDuplicateNodeTags() throws Exception {
    // Try to perform a create with 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.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, 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) Test(org.junit.Test)

Example 15 with EmrClusterDefinition

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

the class EmrClusterDefinitionServiceTest method testCreateEmrClusterDefinitionMaxInstancesExceeded.

@Test
public void testCreateEmrClusterDefinitionMaxInstancesExceeded() throws Exception {
    final Integer TEST_MAX_EMR_INSTANCES_COUNT = 10;
    // Override configuration.
    Map<String, Object> overrideMap = new HashMap<>();
    overrideMap.put(ConfigurationValue.MAX_EMR_INSTANCES_COUNT.getKey(), TEST_MAX_EMR_INSTANCES_COUNT.toString());
    modifyPropertySourceInEnvironment(overrideMap);
    // Try to perform a create by specifying too many instances (TEST_MAX_EMR_INSTANCES_COUNT + 1).
    EmrClusterDefinition emrClusterDefinitionConfiguration = getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH);
    emrClusterDefinitionConfiguration.getInstanceDefinitions().getMasterInstances().setInstanceCount(TEST_MAX_EMR_INSTANCES_COUNT);
    emrClusterDefinitionConfiguration.getInstanceDefinitions().getCoreInstances().setInstanceCount(1);
    try {
        emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinitionConfiguration));
        fail("Should throw an IllegalArgumentException when total number of instances exceeds maximum allowed.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Total number of instances requested can not exceed : %d", TEST_MAX_EMR_INSTANCES_COUNT), e.getMessage());
    } finally {
        // Restore the property sources so we don't affect other tests.
        restorePropertySourceInEnvironment();
    }
}
Also used : EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) HashMap(java.util.HashMap) 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