Search in sources :

Example 31 with Job

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());
    }
}
Also used : JobDeleteRequest(org.finra.herd.model.api.xml.JobDeleteRequest) Job(org.finra.herd.model.api.xml.Job) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AccessDeniedException(org.springframework.security.access.AccessDeniedException) Test(org.junit.Test)

Example 32 with Job

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));
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Job(org.finra.herd.model.api.xml.Job) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 33 with Job

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);
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Job(org.finra.herd.model.api.xml.Job) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 34 with Job

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);
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Job(org.finra.herd.model.api.xml.Job) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 35 with Job

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);
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Job(org.finra.herd.model.api.xml.Job) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Aggregations

Job (org.finra.herd.model.api.xml.Job)71 Test (org.junit.Test)60 Parameter (org.finra.herd.model.api.xml.Parameter)30 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)21 ArrayList (java.util.ArrayList)20 FieldExtension (org.activiti.bpmn.model.FieldExtension)11 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)11 Task (org.activiti.engine.task.Task)9 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)9 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)8 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)7 JobDeleteRequest (org.finra.herd.model.api.xml.JobDeleteRequest)7 JobSignalRequest (org.finra.herd.model.api.xml.JobSignalRequest)7 S3PropertiesLocation (org.finra.herd.model.api.xml.S3PropertiesLocation)7 AccessDeniedException (org.springframework.security.access.AccessDeniedException)7 JobAction (org.finra.herd.model.api.xml.JobAction)6 JobUpdateRequest (org.finra.herd.model.api.xml.JobUpdateRequest)6 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)6 ApplicationUser (org.finra.herd.model.dto.ApplicationUser)6 SecurityUserWrapper (org.finra.herd.model.dto.SecurityUserWrapper)6