use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class JobServiceTest method testDeleteJobAssertErrorDeleteReasonBlank.
/**
* Asserts that the deleteJob call will throw an error when delete reason is blank.
*
* @throws Exception
*/
@Test
public void testDeleteJobAssertErrorDeleteReasonBlank() throws Exception {
// Start a job that will wait in a receive task
jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_RECEIVE_TASK_WITH_CLASSPATH);
Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
// Create a job delete request
JobDeleteRequest jobDeleteRequest = new JobDeleteRequest();
jobDeleteRequest.setDeleteReason(BLANK_TEXT);
try {
jobService.deleteJob(job.getId(), jobDeleteRequest);
} catch (Exception e) {
assertEquals(IllegalArgumentException.class, e.getClass());
assertEquals("deleteReason must be specified", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class CheckEmrClusterTest method testCheckCluster.
@Test
public void testCheckCluster() throws Exception {
// Run a job with Activiti XML that will start cluster, check status and terminate.
Job job = jobServiceTestHelper.createJobForCreateCluster(ACTIVITI_XML_CHECK_CLUSTER_WITH_CLASSPATH, getParameters(true, "", "false"));
assertNotNull(job);
HistoricProcessInstance hisInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult();
Map<String, Object> variables = hisInstance.getProcessVariables();
// check to be sure fields exist. These should exist whether verbose is set or not
assertTrue(variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_ID));
assertTrue(variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_STATUS));
assertTrue(variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_CREATION_TIME));
assertTrue(variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_READY_TIME));
assertTrue(variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_END_TIME));
assertTrue(variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_STATUS_CHANGE_REASON_CODE));
assertTrue(variables.containsKey(taskName + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + CheckEmrCluster.VARIABLE_EMR_CLUSTER_STATUS_CHANGE_REASON_MESSAGE));
}
use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class CheckEmrClusterTest method testCheckClusterByClusterIdStepId.
/**
* This method tests the check EMR cluster activiti task with cluster Id and step Id specified
*/
@Test
public void testCheckClusterByClusterIdStepId() throws Exception {
List<FieldExtension> fieldExtensions = getOptionalFieldExtensions();
FieldExtension fieldExtension = new FieldExtension();
fieldExtension.setFieldName("emrStepId");
fieldExtension.setExpression("${addHiveStepServiceTask_emrStepId}");
fieldExtensions.add(fieldExtension);
// Run a job with Activiti XML that will start cluster, check status and terminate.
Job job = jobServiceTestHelper.createJobForCreateClusterForActivitiXml(getCheckClusterActivitiXml(fieldExtensions), getParameters(true, "false", "false"));
assertNotNull(job);
HistoricProcessInstance hisInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult();
Map<String, Object> variables = hisInstance.getProcessVariables();
String hiveStepId = (String) variables.get("addHiveStepServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "emrStepId");
String emrStepId = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "step_id");
assertEquals(hiveStepId, emrStepId);
String emrStepJarLocation = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "step_jarLocation");
assertNull(emrStepJarLocation);
String shellStepId = (String) variables.get("addShellStepServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "emrStepId");
assertNotNull(shellStepId);
String activeStepId = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "activeStep_id");
assertEquals(shellStepId, activeStepId);
String activeStepJarLocation = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "activeStep_jarLocation");
assertNull(activeStepJarLocation);
}
use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class CheckEmrClusterTest method testCheckClusterByClusterIdStepIdVerbose.
/**
* This method tests the check EMR cluster activiti task with cluster Id and step Id specified
*/
@Test
public void testCheckClusterByClusterIdStepIdVerbose() throws Exception {
// Run a job with Activiti XML that will start cluster, check status and terminate.
List<FieldExtension> fieldExtensions = getOptionalFieldExtensions();
FieldExtension fieldExtension = new FieldExtension();
fieldExtension.setFieldName("emrStepId");
fieldExtension.setExpression("${addHiveStepServiceTask_emrStepId}");
fieldExtensions.add(fieldExtension);
Job job = jobServiceTestHelper.createJobForCreateClusterForActivitiXml(getCheckClusterActivitiXml(fieldExtensions), getParameters(true, "true", "false"));
assertNotNull(job);
HistoricProcessInstance hisInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult();
Map<String, Object> variables = hisInstance.getProcessVariables();
String hiveStepId = (String) variables.get("addHiveStepServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "emrStepId");
assertNotNull(hiveStepId);
String emrStepId = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "step_id");
assertEquals(hiveStepId, emrStepId);
String emrStepJarLocation = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "step_jarLocation");
assertNotNull(emrStepJarLocation);
String shellStepId = (String) variables.get("addShellStepServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "emrStepId");
assertNotNull(shellStepId);
String activeStepId = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "activeStep_id");
assertEquals(shellStepId, activeStepId);
String activeStepJarLocation = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "activeStep_jarLocation");
assertNotNull(activeStepJarLocation);
}
use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class CheckEmrClusterTest method testCheckClusterByRetrieveInstanceFleets.
@Test
public void testCheckClusterByRetrieveInstanceFleets() throws Exception {
// Run a job with Activiti XML that will start cluster, check status and terminate.
List<FieldExtension> fieldExtensions = getOptionalFieldExtensions();
FieldExtension fieldExtension = new FieldExtension();
fieldExtension.setFieldName("emrStepId");
fieldExtension.setExpression("${addHiveStepServiceTask_emrStepId}");
fieldExtensions.add(fieldExtension);
Job job = jobServiceTestHelper.createJobForCreateClusterForActivitiXml(getCheckClusterActivitiXml(fieldExtensions), getParameters(true, "true", "true"));
assertNotNull(job);
HistoricProcessInstance hisInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult();
Map<String, Object> variables = hisInstance.getProcessVariables();
String emrClusterInstanceFleetJson = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "instance_fleets");
assertNotNull(emrClusterInstanceFleetJson);
}
Aggregations