use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testGetEmrClusterDefinition.
@Test
public void testGetEmrClusterDefinition() 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 the EMR cluster definition.
EmrClusterDefinitionInformation resultEmrClusterDefinition = emrClusterDefinitionService.getEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, 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 testUpdateEmrClusterDefinitionUpperCaseParameters.
@Test
public void testUpdateEmrClusterDefinitionUpperCaseParameters() throws Exception {
// Create and persist the namespace entity with a lowercase name.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE.toLowerCase());
// Create and persist the EMR cluster definition entity with a lowercase name using minimal test XML configuration.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME.toLowerCase(), 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 upper case.
EmrClusterDefinitionInformation updatedEmrClusterDefinition = emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE.toUpperCase(), EMR_CLUSTER_DEFINITION_NAME.toUpperCase()), createEmrClusterDefinitionUpdateRequest(getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH)));
// Validate the returned object.
validateEmrClusterDefinition(emrClusterDefinitionEntity.getId(), NAMESPACE.toLowerCase(), EMR_CLUSTER_DEFINITION_NAME.toLowerCase(), 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 testUpdateEmrClusterDefinition.
@Test
public void testUpdateEmrClusterDefinition() throws Exception {
// Create and persist the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
// Create and persist the EMR cluster definition entity using minimal test XML configuration.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH));
// Create an EMR cluster definition update request using normal test XML configuration.
EmrClusterDefinitionUpdateRequest request = createEmrClusterDefinitionUpdateRequest(getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
executeWithoutLogging(EmrClusterDefinitionServiceImpl.class, () -> {
// Update the EMR cluster definition.
EmrClusterDefinitionInformation updatedEmrClusterDefinition = emrClusterDefinitionService.updateEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME), request);
// Validate the returned object.
validateEmrClusterDefinition(emrClusterDefinitionEntity.getId(), NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, 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 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());
}
}
use of org.finra.herd.model.api.xml.EmrClusterDefinitionKey in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testGetEmrClusterDefinitionUpperCaseParameters.
@Test
public void testGetEmrClusterDefinitionUpperCaseParameters() throws Exception {
// Create and persist the namespace entity with a lowercase name.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE.toLowerCase());
// Create and persist the EMR cluster definition entity with a lowercase name.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME.toLowerCase(), getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
// Get an EMR cluster definition by passing the EMR cluster definition name key parameters in upper case.
EmrClusterDefinitionInformation resultEmrClusterDefinition = emrClusterDefinitionService.getEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE.toUpperCase(), EMR_CLUSTER_DEFINITION_NAME.toUpperCase()));
// Validate the returned object.
validateEmrClusterDefinition(emrClusterDefinitionEntity.getId(), NAMESPACE.toLowerCase(), EMR_CLUSTER_DEFINITION_NAME.toLowerCase(), getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), resultEmrClusterDefinition);
}
Aggregations