Search in sources :

Example 1 with TaskThread

use of com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread in project elastic-job by dangdangdotcom.

the class TaskExecutorThreadTest method assertLaunchTaskWithWrongElasticJobClass.

@Test
public void assertLaunchTaskWithWrongElasticJobClass() {
    TaskInfo taskInfo = buildWrongElasticJobClass();
    TaskThread taskThread = new TaskExecutor().new TaskThread(executorDriver, taskInfo);
    try {
        taskThread.run();
    } catch (final JobSystemException ex) {
        assertTrue(ex.getMessage().startsWith("Elastic-Job: Class 'com.dangdang.ddframe.job.cloud.executor.TaskExecutorThreadTest' must implements ElasticJob interface."));
    }
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) TaskThread(com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException) Test(org.junit.Test)

Example 2 with TaskThread

use of com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread in project elastic-job by dangdangdotcom.

the class TaskExecutorThreadTest method assertLaunchTaskWithDaemonTaskAndJavaScriptJob.

@Test
public void assertLaunchTaskWithDaemonTaskAndJavaScriptJob() {
    TaskInfo taskInfo = buildSpringScriptTransientTaskInfo();
    TaskThread taskThread = new TaskExecutor().new TaskThread(executorDriver, taskInfo);
    taskThread.run();
    verify(executorDriver).sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(TaskState.TASK_RUNNING).build());
    verify(executorDriver).sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(Protos.TaskState.TASK_FINISHED).build());
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) TaskThread(com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread) Test(org.junit.Test)

Example 3 with TaskThread

use of com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread in project elastic-job by dangdangdotcom.

the class TaskExecutorThreadTest method assertLaunchTaskWithDaemonTaskAndJavaSimpleJob.

@Test
public void assertLaunchTaskWithDaemonTaskAndJavaSimpleJob() {
    TaskInfo taskInfo = buildJavaTransientTaskInfo();
    TaskThread taskThread = new TaskExecutor().new TaskThread(executorDriver, taskInfo);
    taskThread.run();
    verify(executorDriver).sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(TaskState.TASK_RUNNING).build());
    verify(executorDriver).sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(Protos.TaskState.TASK_FINISHED).build());
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) TaskThread(com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread) Test(org.junit.Test)

Example 4 with TaskThread

use of com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread in project elastic-job by dangdangdotcom.

the class TaskExecutorThreadTest method assertLaunchTaskWithTransientTaskAndSpringSimpleJob.

@Test
public void assertLaunchTaskWithTransientTaskAndSpringSimpleJob() {
    TaskInfo taskInfo = buildSpringDaemonTaskInfo();
    TaskThread taskThread = new TaskExecutor().new TaskThread(executorDriver, taskInfo);
    taskThread.run();
    verify(executorDriver).sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(TaskState.TASK_RUNNING).build());
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) TaskThread(com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread) Test(org.junit.Test)

Example 5 with TaskThread

use of com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread in project elastic-job by dangdangdotcom.

the class TaskExecutorThreadTest method assertLaunchTaskWithWrongClass.

@Test
public void assertLaunchTaskWithWrongClass() {
    TaskInfo taskInfo = buildWrongClass();
    TaskThread taskThread = new TaskExecutor().new TaskThread(executorDriver, taskInfo);
    try {
        taskThread.run();
    } catch (final JobSystemException ex) {
        assertTrue(ex.getMessage().startsWith("Elastic-Job: Class 'WrongClass' initialize failure, the error message is 'WrongClass'."));
    }
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) TaskThread(com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException) Test(org.junit.Test)

Aggregations

TaskThread (com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread)5 TaskInfo (org.apache.mesos.Protos.TaskInfo)5 Test (org.junit.Test)5 JobSystemException (com.dangdang.ddframe.job.exception.JobSystemException)2