use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method createEmrClusterDefinitionCreateRequest.
/**
* Creates a new EMR cluster definition create request.
*
* @param namespace the namespace
* @param emrClusterDefinitionName the EMR cluster definition name
* @param emrClusterDefinitionConfiguration the EMR cluster definition configuration
*
* @return the newly created EMR cluster definition create request
*/
private EmrClusterDefinitionCreateRequest createEmrClusterDefinitionCreateRequest(String namespace, String emrClusterDefinitionName, EmrClusterDefinition emrClusterDefinitionConfiguration) {
// Create a new ENR cluster definition create request.
EmrClusterDefinitionCreateRequest request = new EmrClusterDefinitionCreateRequest();
// Fill in the parameters.
request.setEmrClusterDefinitionKey(new EmrClusterDefinitionKey(namespace, emrClusterDefinitionName));
request.setEmrClusterDefinition(emrClusterDefinitionConfiguration);
return request;
}
use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testGetEmrClusterDefinitionTrimParameters.
@Test
public void testGetEmrClusterDefinitionTrimParameters() throws Exception {
// Create and persist the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
// Create and persist the EMR cluster definition entity.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
// Get an EMR cluster definition by passing namespace and EMR cluster definition name with leading and trailing whitespace characters.
EmrClusterDefinitionInformation resultEmrClusterDefinition = emrClusterDefinitionService.getEmrClusterDefinition(new EmrClusterDefinitionKey(addWhitespace(NAMESPACE), addWhitespace(EMR_CLUSTER_DEFINITION_NAME)));
// Validate the returned object.
validateEmrClusterDefinition(emrClusterDefinitionEntity.getId(), NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), resultEmrClusterDefinition);
}
use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testUpdateEmrClusterDefinitionLowerCaseParameters.
@Test
public void testUpdateEmrClusterDefinitionLowerCaseParameters() throws Exception {
// Create and persist the namespace entity with an uppercase name.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE.toUpperCase());
// Create and persist the EMR cluster definition entity with an uppercase name using minimal test XML configuration.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME.toUpperCase(), getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH));
executeWithoutLogging(EmrClusterDefinitionServiceImpl.class, () -> {
// Update an EMR cluster definition with the normal test XML configuration by passing the EMR cluster definition name key parameters in lower case.
EmrClusterDefinitionInformation updatedEmrClusterDefinition = emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE.toLowerCase(), EMR_CLUSTER_DEFINITION_NAME.toLowerCase()), createEmrClusterDefinitionUpdateRequest(getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH)));
// Validate the returned object.
validateEmrClusterDefinition(emrClusterDefinitionEntity.getId(), NAMESPACE.toUpperCase(), EMR_CLUSTER_DEFINITION_NAME.toUpperCase(), getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), updatedEmrClusterDefinition);
});
}
use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testDeleteEmrClusterDefinitionMissingRequiredParameters.
@Test
public void testDeleteEmrClusterDefinitionMissingRequiredParameters() throws Exception {
// Try to perform a delete without specifying a namespace.
try {
emrClusterDefinitionService.deleteEmrClusterDefinition(new EmrClusterDefinitionKey(BLANK_TEXT, EMR_CLUSTER_DEFINITION_NAME));
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 delete without specifying an EMR cluster definition name.
try {
emrClusterDefinitionService.deleteEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, BLANK_TEXT));
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());
}
}
use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testUpdateEmrClusterDefinitionMaxInstancesExceeded.
@Test
public void testUpdateEmrClusterDefinitionMaxInstancesExceeded() 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 an update 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.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), createEmrClusterDefinitionUpdateRequest(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