Search in sources :

Example 96 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.

the class JobEmailNotificationTest method createJob.

private InternalJob createJob(String userEmail) throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(JOB_NAME);
    if (userEmail != null) {
        job.addGenericInformation(JobEmailNotification.GENERIC_INFORMATION_KEY_EMAIL, userEmail);
    }
    JavaTask javaTask = new JavaTask();
    javaTask.setExecutableClassName(TestJavaTask.class.getName());
    javaTask.setName(TASK_NAME);
    job.addTask(javaTask);
    InternalJob internalJob = InternalJobFactory.createJob(job, null);
    internalJob.setOwner(DEFAULT_USER_NAME);
    return internalJob;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 97 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.

the class JobEmailNotificationTest method testJobRestartedFromError.

@Test
public void testJobRestartedFromError() throws Exception {
    InternalJob job = createJob(USER_EMAIL);
    job.setId(new JobIdImpl(123890, job.getName()));
    job.setStatus(JobStatus.RUNNING);
    Map<String, String> genericInfo = job.getGenericInformation();
    genericInfo.put("NOTIFICATION_EVENTS", "Job restarted from error");
    job.setGenericInformation(genericInfo);
    boolean sent = sendNotification(job, SchedulerEvent.JOB_RESTARTED_FROM_ERROR, stubbedSender);
    assertTrue(sent);
    verify(stubbedSender).sender(eq(USER_EMAIL), contains("ProActive Job 123890 : Job restarted from error"), contains("Status: Running"));
    verifyNoMoreInteractions(stubbedSender);
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Matchers.anyString(org.mockito.Matchers.anyString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 98 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.

the class JobEmailNotificationTest method testDisabled.

@Test
public void testDisabled() throws Exception {
    disableEmailNotifications();
    InternalJob job = createJob(USER_EMAIL);
    boolean sent = sendNotification(job, SchedulerEvent.JOB_RUNNING_TO_FINISHED, stubbedSender);
    assertFalse(sent);
    verifyNoMoreInteractions(stubbedSender);
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) Test(org.junit.Test)

Example 99 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.

the class JobEmailNotificationTest method testFinished.

@Test
public void testFinished() throws Exception {
    InternalJob job = createJob(USER_EMAIL);
    job.setId(new JobIdImpl(123890, job.getName()));
    job.setStatus(JobStatus.FINISHED);
    Map<String, String> genericInfo = job.getGenericInformation();
    genericInfo.put("NOTIFICATION_EVENTS", "Job running to finished");
    job.setGenericInformation(genericInfo);
    boolean sent = sendNotification(job, SchedulerEvent.JOB_RUNNING_TO_FINISHED, stubbedSender);
    assertTrue(sent);
    verify(stubbedSender).sender(eq(USER_EMAIL), contains("ProActive Job 123890 : Job running to finished"), contains("Status: Finished"));
    verifyNoMoreInteractions(stubbedSender);
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Matchers.anyString(org.mockito.Matchers.anyString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 100 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.

the class JobEmailNotificationTest method testJobSubmitted.

@Test
public void testJobSubmitted() throws Exception {
    InternalJob job = createJob(USER_EMAIL);
    job.setId(new JobIdImpl(123890, job.getName()));
    job.setStatus(JobStatus.PENDING);
    Map<String, String> genericInfo = job.getGenericInformation();
    genericInfo.put("NOTIFICATION_EVENTS", "Job submitted");
    job.setGenericInformation(genericInfo);
    boolean sent = sendNotification(job, SchedulerEvent.JOB_SUBMITTED, stubbedSender);
    assertTrue(sent);
    verify(stubbedSender).sender(eq(USER_EMAIL), contains("ProActive Job 123890 : Job submitted"), contains("Status: Pending"));
    verifyNoMoreInteractions(stubbedSender);
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Matchers.anyString(org.mockito.Matchers.anyString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

InternalJob (org.ow2.proactive.scheduler.job.InternalJob)166 Test (org.junit.Test)115 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)90 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)53 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)36 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)34 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)33 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)32 JobId (org.ow2.proactive.scheduler.common.job.JobId)28 ArrayList (java.util.ArrayList)27 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)26 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)19 RecoveredSchedulerState (org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState)19 Matchers.containsString (org.hamcrest.Matchers.containsString)16 Matchers.anyString (org.mockito.Matchers.anyString)16 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)15 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)13 SchedulerStateRecoverHelper (org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper)12 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)12 HashMap (java.util.HashMap)10