Search in sources :

Example 6 with EmrClusterDefinitionCreateRequest

use of org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest 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;
}
Also used : EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionCreateRequest(org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest)

Example 7 with EmrClusterDefinitionCreateRequest

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

the class EmrClusterDefinitionServiceTest method testCreateEmrClusterDefinitionCoreInstanceCount0AssertResponseCoreInstanceDefinitionIsNull.

/**
 * Asserts that when 0 is specified for core instance count, no validation exception is thrown.
 */
@Test
public void testCreateEmrClusterDefinitionCoreInstanceCount0AssertResponseCoreInstanceDefinitionIsNull() throws Exception {
    // Create and persist the namespace entity.
    namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    // Create an EMR cluster definition create request.
    EmrClusterDefinitionCreateRequest request = createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
    InstanceDefinition coreInstanceDefinition = new InstanceDefinition(0, "m1.medium", NO_EMR_CLUSTER_DEFINITION_EBS_CONFIGURATION, NO_INSTANCE_SPOT_PRICE, NO_INSTANCE_MAX_SEARCH_PRICE, NO_INSTANCE_ON_DEMAND_THRESHOLD);
    request.getEmrClusterDefinition().getInstanceDefinitions().setCoreInstances(coreInstanceDefinition);
    // Create an EMR cluster definition.
    EmrClusterDefinitionInformation emrClusterDefinitionInformation = emrClusterDefinitionService.createEmrClusterDefinition(request);
    assertNull(emrClusterDefinitionInformation.getEmrClusterDefinition().getInstanceDefinitions().getCoreInstances());
}
Also used : InstanceDefinition(org.finra.herd.model.api.xml.InstanceDefinition) EmrClusterDefinitionCreateRequest(org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) Test(org.junit.Test)

Example 8 with EmrClusterDefinitionCreateRequest

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

the class EmrClusterDefinitionServiceTest method testCreateEmrClusterDefinitionMaxInstancesSetToZero.

@Test
public void testCreateEmrClusterDefinitionMaxInstancesSetToZero() throws Exception {
    // Create and persist the namespace entity.
    namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    // Override configuration to set the maximum allowed number of EMR instances to zero.
    Map<String, Object> overrideMap = new HashMap<>();
    overrideMap.put(ConfigurationValue.MAX_EMR_INSTANCES_COUNT.getKey(), "0");
    modifyPropertySourceInEnvironment(overrideMap);
    try {
        // Create an EMR cluster definition create request.
        EmrClusterDefinitionCreateRequest request = createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
        // Create an EMR cluster definition.
        EmrClusterDefinitionInformation resultEmrClusterDefinition = emrClusterDefinitionService.createEmrClusterDefinition(request);
        // Validate the returned object.
        validateEmrClusterDefinition(null, NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), resultEmrClusterDefinition);
    } finally {
        // Restore the property sources so we don't affect other tests.
        restorePropertySourceInEnvironment();
    }
}
Also used : HashMap(java.util.HashMap) EmrClusterDefinitionCreateRequest(org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) Test(org.junit.Test)

Example 9 with EmrClusterDefinitionCreateRequest

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

the class EmrClusterDefinitionServiceTest method testCreateEmrClusterDefinitionTrimParameters.

@Test
public void testCreateEmrClusterDefinitionTrimParameters() throws Exception {
    // Create and persist the namespace entity.
    namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    // Create an EMR cluster definition create request by passing namespace and EMR cluster definition name with leading and trailing whitespace characters.
    EmrClusterDefinitionCreateRequest request = createEmrClusterDefinitionCreateRequest(addWhitespace(NAMESPACE), addWhitespace(EMR_CLUSTER_DEFINITION_NAME), getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
    // Create an EMR cluster definition.
    EmrClusterDefinitionInformation resultEmrClusterDefinition = emrClusterDefinitionService.createEmrClusterDefinition(request);
    // Validate the returned object.
    validateEmrClusterDefinition(null, NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), resultEmrClusterDefinition);
}
Also used : EmrClusterDefinitionCreateRequest(org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest) EmrClusterDefinitionInformation(org.finra.herd.model.api.xml.EmrClusterDefinitionInformation) Test(org.junit.Test)

Aggregations

EmrClusterDefinitionCreateRequest (org.finra.herd.model.api.xml.EmrClusterDefinitionCreateRequest)9 Test (org.junit.Test)8 EmrClusterDefinitionInformation (org.finra.herd.model.api.xml.EmrClusterDefinitionInformation)7 EmrClusterDefinitionKey (org.finra.herd.model.api.xml.EmrClusterDefinitionKey)2 InstanceDefinition (org.finra.herd.model.api.xml.InstanceDefinition)2 HashMap (java.util.HashMap)1 EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)1