Search in sources :

Example 16 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobEventRdbSearchTest method assertFindJobExecutionEventsWithPageSizeAndNumber.

@Test
public void assertFindJobExecutionEventsWithPageSizeAndNumber() {
    Result<JobExecutionEvent> result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, null, null, null));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(10));
    result = repository.findJobExecutionEvents(new Condition(50, 1, null, null, null, null, null));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(50));
    result = repository.findJobExecutionEvents(new Condition(100, 5, null, null, null, null, null));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(100));
    result = repository.findJobExecutionEvents(new Condition(100, 6, null, null, null, null, null));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(0));
}
Also used : Condition(com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition) JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) Test(org.junit.Test)

Example 17 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobEventRdbSearchTest method assertFindJobExecutionEventsWithTime.

@Test
public void assertFindJobExecutionEventsWithTime() {
    Date now = new Date();
    Date tenMinutesBefore = new Date(now.getTime() - 10 * 60 * 1000);
    Result<JobExecutionEvent> result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, tenMinutesBefore, null, null));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(10));
    result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, now, null, null));
    assertThat(result.getTotal(), is(0));
    assertThat(result.getRows().size(), is(0));
    result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, null, tenMinutesBefore, null));
    assertThat(result.getTotal(), is(0));
    assertThat(result.getRows().size(), is(0));
    result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, null, now, null));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(10));
    result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, tenMinutesBefore, now, null));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(10));
}
Also used : Condition(com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition) JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) Date(java.util.Date) Test(org.junit.Test)

Example 18 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobEventRdbSearchTest method assertFindJobExecutionEventsWithErrorPageSizeAndNumber.

@Test
public void assertFindJobExecutionEventsWithErrorPageSizeAndNumber() {
    Result<JobExecutionEvent> result = repository.findJobExecutionEvents(new Condition(-1, -1, null, null, null, null, null));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(10));
}
Also used : Condition(com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition) JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) Test(org.junit.Test)

Example 19 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobEventRdbSearchTest method assertFindJobExecutionEventsWithSort.

@Test
public void assertFindJobExecutionEventsWithSort() {
    Result<JobExecutionEvent> result = repository.findJobExecutionEvents(new Condition(10, 1, "jobName", "ASC", null, null, null));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(10));
    assertThat(result.getRows().get(0).getJobName(), is("test_job_1"));
    result = repository.findJobExecutionEvents(new Condition(10, 1, "jobName", "DESC", null, null, null));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(10));
    assertThat(result.getRows().get(0).getJobName(), is("test_job_99"));
}
Also used : Condition(com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition) JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) Test(org.junit.Test)

Example 20 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobEventRdbSearchTest method initStorage.

private static void initStorage() {
    for (int i = 1; i <= 500; i++) {
        JobExecutionEvent startEvent = new JobExecutionEvent("fake_task_id", "test_job_" + i, ExecutionSource.NORMAL_TRIGGER, 0);
        storage.addJobExecutionEvent(startEvent);
        if (i % 2 == 0) {
            JobExecutionEvent successEvent = startEvent.executionSuccess();
            storage.addJobExecutionEvent(successEvent);
        }
        storage.addJobStatusTraceEvent(new JobStatusTraceEvent("test_job_" + i, "fake_failed_failover_task_id", "fake_slave_id", Source.LITE_EXECUTOR, ExecutionType.FAILOVER, "0", State.TASK_FAILED, "message is empty."));
    }
}
Also used : JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) JobStatusTraceEvent(com.dangdang.ddframe.job.event.type.JobStatusTraceEvent)

Aggregations

JobExecutionEvent (com.dangdang.ddframe.job.event.type.JobExecutionEvent)24 Test (org.junit.Test)20 Condition (com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition)8 Date (java.util.Date)2 HashMap (java.util.HashMap)2 ShardingContext (com.dangdang.ddframe.job.api.ShardingContext)1 TestJobEventConfiguration (com.dangdang.ddframe.job.event.fixture.TestJobEventConfiguration)1 JobExecutionEventThrowable (com.dangdang.ddframe.job.event.type.JobExecutionEventThrowable)1 JobStatusTraceEvent (com.dangdang.ddframe.job.event.type.JobStatusTraceEvent)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 LinkedList (java.util.LinkedList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1