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);
}
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);
}
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);
}
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());
}
}
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();
}
}
Aggregations