Search in sources :

Example 11 with EmrClusterDefinitionEntity

use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity 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);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity) Test(org.junit.Test)

Example 12 with EmrClusterDefinitionEntity

use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity 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);
    });
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity) Test(org.junit.Test)

Example 13 with EmrClusterDefinitionEntity

use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity 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);
    });
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionUpdateRequest(org.finra.herd.model.api.xml.EmrClusterDefinitionUpdateRequest) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity) Test(org.junit.Test)

Example 14 with EmrClusterDefinitionEntity

use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity 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);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity) Test(org.junit.Test)

Example 15 with EmrClusterDefinitionEntity

use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity in project herd by FINRAOS.

the class EmrClusterDefinitionDaoTest method testGetEmrClusterDefinitionByAltKeyNamespaceNoExists.

/**
 * Tests the scenario by providing the wrong app name.
 */
@Test
public void testGetEmrClusterDefinitionByAltKeyNamespaceNoExists() throws IOException {
    // Create namespace database entities.
    NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE_2);
    // Create a EMR Cluster definition entity
    emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
    // Call the API to query the newly added entity by providing the app and a definition name that doesn't exist.
    EmrClusterDefinitionEntity emrClusterDefinitionEntityResult = emrClusterDefinitionDao.getEmrClusterDefinitionByAltKey(NAMESPACE_2, EMR_CLUSTER_DEFINITION_NAME_2);
    // Validate the results.
    assertNull(emrClusterDefinitionEntityResult);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity) Test(org.junit.Test)

Aggregations

EmrClusterDefinitionEntity (org.finra.herd.model.jpa.EmrClusterDefinitionEntity)31 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)24 Test (org.junit.Test)16 EmrClusterDefinitionKey (org.finra.herd.model.api.xml.EmrClusterDefinitionKey)14 EmrClusterDefinitionInformation (org.finra.herd.model.api.xml.EmrClusterDefinitionInformation)12 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)6 AmazonServiceException (com.amazonaws.AmazonServiceException)5 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)4 ClusterSummary (com.amazonaws.services.elasticmapreduce.model.ClusterSummary)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 Predicate (javax.persistence.criteria.Predicate)2 EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 EmrClusterAlternateKeyDto (org.finra.herd.model.dto.EmrClusterAlternateKeyDto)2 Cluster (com.amazonaws.services.elasticmapreduce.model.Cluster)1 ListInstanceFleetsResult (com.amazonaws.services.elasticmapreduce.model.ListInstanceFleetsResult)1 Step (com.amazonaws.services.elasticmapreduce.model.Step)1 StepSummary (com.amazonaws.services.elasticmapreduce.model.StepSummary)1 ArrayList (java.util.ArrayList)1 Tuple (javax.persistence.Tuple)1