use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity in project herd by FINRAOS.
the class EmrClusterDefinitionDaoTest method testGetEmrClusterDefinitionByAltKeyDefinitionNameNoExists.
/**
* Tests the scenario by providing a EMR Cluster name that doesn't exist.
*/
@Test
public void testGetEmrClusterDefinitionByAltKeyDefinitionNameNoExists() throws IOException {
// Create and persist an EMR Cluster definition entity.
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE), 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, EMR_CLUSTER_DEFINITION_NAME_2);
// Validate the results.
assertNull(emrClusterDefinitionEntityResult);
}
use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity in project herd by FINRAOS.
the class EmrClusterDefinitionDaoTestHelper method createEmrClusterDefinitionEntity.
/**
* Creates and persists a new EMR cluster definition entity.
*
* @param namespaceEntity the namespace entity
* @param definitionName the cluster definition name
* @param configurationXml the cluster configuration XML
*
* @return the newly created job definition entity
*/
public EmrClusterDefinitionEntity createEmrClusterDefinitionEntity(NamespaceEntity namespaceEntity, String definitionName, String configurationXml) {
EmrClusterDefinitionEntity emrClusterDefinitionEntity = new EmrClusterDefinitionEntity();
emrClusterDefinitionEntity.setNamespace(namespaceEntity);
emrClusterDefinitionEntity.setName(definitionName);
emrClusterDefinitionEntity.setConfiguration(configurationXml);
return emrClusterDefinitionDao.saveAndRefresh(emrClusterDefinitionEntity);
}
use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity in project herd by FINRAOS.
the class JobServiceTestHelper method createJobForCreateCluster.
/**
* Creates a job based on the specified Activiti XML classpath resource location and defines a EMR cluster definition.
*
* @param activitiXmlClasspathResourceName the Activiti XML classpath resource location.
* @param parameters the job parameters.
*
* @return the job.
* @throws Exception if any errors were encountered.
*/
public Job createJobForCreateCluster(String activitiXmlClasspathResourceName, List<Parameter> parameters, String amiVersion) throws Exception {
jobDefinitionServiceTestHelper.createJobDefinition(activitiXmlClasspathResourceName);
NamespaceEntity namespaceEntity = namespaceDao.getNamespaceByCd(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD);
String configXml = IOUtils.toString(resourceLoader.getResource(AbstractServiceTest.EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
emrClusterDefinition.setAmiVersion(amiVersion);
configXml = xmlHelper.objectToXml(emrClusterDefinition);
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, AbstractServiceTest.EMR_CLUSTER_DEFINITION_NAME, configXml);
Parameter parameter = new Parameter("emrClusterDefinitionName", emrClusterDefinitionEntity.getName());
parameters.add(parameter);
parameter = new Parameter("namespace", AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD);
parameters.add(parameter);
// Start the job synchronously.
return jobService.createAndStartJob(createJobCreateRequest(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD, AbstractServiceTest.TEST_ACTIVITI_JOB_NAME, parameters));
}
use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity in project herd by FINRAOS.
the class JobServiceTestHelper method createJobForCreateClusterForActivitiXml.
/**
* Creates a job based on the specified Activiti XML and defines a EMR cluster definition.
*
* @param activitiXml the Activiti XML.
* @param parameters the job parameters.
*
* @return the job.
* @throws Exception if any errors were encountered.
*/
public Job createJobForCreateClusterForActivitiXml(String activitiXml, List<Parameter> parameters) throws Exception {
jobDefinitionServiceTestHelper.createJobDefinitionForActivitiXml(activitiXml);
NamespaceEntity namespaceEntity = namespaceDao.getNamespaceByCd(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD);
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, AbstractServiceTest.EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(AbstractServiceTest.EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
Parameter parameter = new Parameter("namespace", namespaceEntity.getCode());
parameters.add(parameter);
parameter = new Parameter("emrClusterDefinitionName", emrClusterDefinitionEntity.getName());
parameters.add(parameter);
parameter = new Parameter("dryRun", null);
parameters.add(parameter);
parameter = new Parameter("contentType", null);
parameters.add(parameter);
parameter = new Parameter("emrClusterDefinitionOverride", null);
parameters.add(parameter);
// Start the job synchronously.
return jobService.createAndStartJob(createJobCreateRequest(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD, AbstractServiceTest.TEST_ACTIVITI_JOB_NAME, parameters));
}
use of org.finra.herd.model.jpa.EmrClusterDefinitionEntity 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);
}
Aggregations