use of org.finra.herd.model.api.xml.JobSignalRequest in project herd by FINRAOS.
the class JobServiceTest method testSignalJobNoParameters.
@Test
public void testSignalJobNoParameters() throws Exception {
jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_RECEIVE_TASK_WITH_CLASSPATH);
// Start the job.
Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
// Job should be waiting at Receive task.
Job jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.RUNNING, jobGet.getStatus());
assertEquals("receivetask1", jobGet.getCurrentWorkflowStep().getId());
// Signal job to continue.
JobSignalRequest jobSignalRequest = new JobSignalRequest(job.getId(), "receivetask1", null, null);
Job signalJob = jobService.signalJob(jobSignalRequest);
assertEquals(JobStatusEnum.RUNNING, signalJob.getStatus());
assertEquals("receivetask1", signalJob.getCurrentWorkflowStep().getId());
// Job should have been completed.
jobGet = jobService.getJob(job.getId(), true);
assertEquals(JobStatusEnum.COMPLETED, jobGet.getStatus());
}
use of org.finra.herd.model.api.xml.JobSignalRequest in project herd by FINRAOS.
the class JobServiceTest method testSignalJob.
@Test
public void testSignalJob() throws Exception {
jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_RECEIVE_TASK_WITH_CLASSPATH);
// Start the job.
Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
// Job should be waiting at Receive task.
Job jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.RUNNING, jobGet.getStatus());
assertEquals("receivetask1", jobGet.getCurrentWorkflowStep().getId());
// Signal job to continue.
List<Parameter> signalParameters = new ArrayList<>();
Parameter signalPameter1 = new Parameter("UT_SIGNAL_PARAM_1", "UT_SIGNAL_VALUE_1");
signalParameters.add(signalPameter1);
JobSignalRequest jobSignalRequest = new JobSignalRequest(job.getId(), "receivetask1", signalParameters, null);
Job signalJob = jobService.signalJob(jobSignalRequest);
assertEquals(JobStatusEnum.RUNNING, signalJob.getStatus());
assertEquals("receivetask1", signalJob.getCurrentWorkflowStep().getId());
assertTrue(signalJob.getParameters().contains(signalPameter1));
// Job should have been completed.
jobGet = jobService.getJob(job.getId(), true);
assertEquals(JobStatusEnum.COMPLETED, jobGet.getStatus());
assertTrue(jobGet.getParameters().contains(signalPameter1));
}
use of org.finra.herd.model.api.xml.JobSignalRequest in project herd by FINRAOS.
the class JobServiceTest method testSignalJobNoExists.
@Test
public void testSignalJobNoExists() throws Exception {
// Signal job with job id that does not exist.
try {
jobService.signalJob(new JobSignalRequest("job_does_not_exist", "receivetask1", null, null));
fail("Should throw an ObjectNotFoundException.");
} catch (ObjectNotFoundException ex) {
assertEquals(String.format("No job found for matching job id: \"%s\" and receive task id: \"%s\".", "job_does_not_exist", "receivetask1"), ex.getMessage());
}
// Signal job with receive task that does not exist.
jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_RECEIVE_TASK_WITH_CLASSPATH);
// Start the job.
Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
try {
// Job should be waiting at Receive task.
Job jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.RUNNING, jobGet.getStatus());
assertEquals("receivetask1", jobGet.getCurrentWorkflowStep().getId());
jobService.signalJob(new JobSignalRequest(job.getId(), "receivetask_does_not_exist", null, null));
fail("Should throw an ObjectNotFoundException.");
} catch (ObjectNotFoundException ex) {
assertEquals(String.format("No job found for matching job id: \"%s\" and receive task id: \"%s\".", job.getId(), "receivetask_does_not_exist"), ex.getMessage());
}
}
use of org.finra.herd.model.api.xml.JobSignalRequest in project herd by FINRAOS.
the class JobServiceTest method testSignalJobWithS3Properties.
/**
* Signals job with S3 properties set. Parameters should be populated from the properties.
*
* @throws Exception
*/
@Test
public void testSignalJobWithS3Properties() throws Exception {
jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_RECEIVE_TASK_WITH_CLASSPATH);
Parameter parameter = new Parameter("testName", "testValue");
S3PropertiesLocation s3PropertiesLocation = getS3PropertiesLocation("s3BucketName", "s3ObjectKey", parameter);
// Start the job.
Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
JobSignalRequest jobSignalRequest = new JobSignalRequest(job.getId(), "receivetask1", null, null);
jobSignalRequest.setS3PropertiesLocation(s3PropertiesLocation);
Job signalJob = jobService.signalJob(jobSignalRequest);
assertParameterEquals(parameter, signalJob.getParameters());
}
use of org.finra.herd.model.api.xml.JobSignalRequest in project herd by FINRAOS.
the class JobServiceTest method testSignalJobWithCheckEmrClusterTask.
@Test
public void testSignalJobWithCheckEmrClusterTask() throws Exception {
// Create EC2 on-demand pricing entities required for testing.
ec2OnDemandPricingDaoTestHelper.createEc2OnDemandPricingEntities();
// Create a list of parameters for the job.
List<Parameter> parameters = new ArrayList<>();
Parameter parameter = new Parameter("clusterName", EMR_CLUSTER_NAME);
parameters.add(parameter);
// Run a job with Activiti XML that will start cluster, check status, wait on receive task and terminate.
Job job = jobServiceTestHelper.createJobForCreateCluster(ACTIVITI_XML_CHECK_CLUSTER_AND_RECEIVE_TASK_WITH_CLASSPATH, parameters);
assertNotNull(job);
// Job should be waiting at receive task.
Job getJobResponse = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.RUNNING, getJobResponse.getStatus());
assertEquals("receiveTask", getJobResponse.getCurrentWorkflowStep().getId());
// Validate that create and check cluster tasks were successful.
assertTrue(getJobResponse.getParameters().contains(new Parameter("createClusterServiceTask_taskStatus", ActivitiRuntimeHelper.TASK_STATUS_SUCCESS)));
assertTrue(getJobResponse.getParameters().contains(new Parameter("checkClusterServiceTask_taskStatus", ActivitiRuntimeHelper.TASK_STATUS_SUCCESS)));
// Signal job to continue.
Parameter signalParameter = new Parameter(PARAMETER_NAME, PARAMETER_VALUE);
JobSignalRequest jobSignalRequest = new JobSignalRequest(job.getId(), "receiveTask", Collections.singletonList(signalParameter), null);
Job signalJobResponse = jobService.signalJob(jobSignalRequest);
// Validate the signal job response.
assertEquals(JobStatusEnum.RUNNING, signalJobResponse.getStatus());
assertEquals("receiveTask", signalJobResponse.getCurrentWorkflowStep().getId());
assertTrue(signalJobResponse.getParameters().contains(signalParameter));
// Validate the cluster status information.
Map<String, Parameter> jobParameters = jobServiceTestHelper.toMap(signalJobResponse.getParameters());
assertTrue(jobParameters.containsKey("checkClusterServiceTask_emrClusterStatus_creationTime"));
assertTrue(jobParameters.containsKey("checkClusterServiceTask_emrClusterStatus_readyTime"));
assertTrue(jobParameters.containsKey("checkClusterServiceTask_emrClusterStatus_endTime"));
// Job should have been completed.
getJobResponse = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.COMPLETED, getJobResponse.getStatus());
assertTrue(getJobResponse.getParameters().contains(signalParameter));
// Get the process variables.
HistoricProcessInstance historicProcessInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult();
Map<String, Object> processVariables = historicProcessInstance.getProcessVariables();
// Validate the cluster status information.
assertTrue(processVariables.containsKey("checkClusterServiceTask_emrClusterStatus_creationTime"));
assertNotNull(processVariables.get("checkClusterServiceTask_emrClusterStatus_creationTime"));
assertTrue(processVariables.containsKey("checkClusterServiceTask_emrClusterStatus_readyTime"));
assertNull(processVariables.get("checkClusterServiceTask_emrClusterStatus_readyTime"));
assertTrue(processVariables.containsKey("checkClusterServiceTask_emrClusterStatus_endTime"));
assertNull(processVariables.get("checkClusterServiceTask_emrClusterStatus_endTime"));
}
Aggregations