Search in sources :

Example 1 with ProgressData

use of ubic.gemma.core.job.progress.ProgressData in project Gemma by PavlidisLab.

the class TaskRunningTest method testFailedRun.

@Test
public final void testFailedRun() throws Exception {
    // goes to the progress page...handleRequest
    TaskCommand taskCommand = new TaskCommand();
    // we use this for 'die' in this test.
    taskCommand.setPersistJobDetails(false);
    String taskId = mockLongJobController.runJob(taskCommand);
    assertNotNull(taskId);
    // wait for job to run
    ProgressData lastResult = null;
    long timeout = 5000;
    long startTime = System.currentTimeMillis();
    wait: while (true) {
        Thread.sleep(500);
        List<ProgressData> result = progressStatusService.getProgressStatus(taskId);
        if (result.size() > 0) {
            for (ProgressData lr : result) {
                lastResult = lr;
                if (lr.isFailed()) {
                    // yay
                    return;
                }
                if (lr.isDone())
                    break wait;
            }
        }
        log.info("Waiting ..");
        if (System.currentTimeMillis() - startTime > timeout)
            fail("Test timed out");
    }
    assertNotNull(lastResult);
    assertTrue(lastResult.isFailed());
}
Also used : List(java.util.List) TaskCommand(ubic.gemma.core.job.TaskCommand) ProgressData(ubic.gemma.core.job.progress.ProgressData) Test(org.junit.Test) BaseSpringWebTest(ubic.gemma.web.util.BaseSpringWebTest)

Example 2 with ProgressData

use of ubic.gemma.core.job.progress.ProgressData in project Gemma by PavlidisLab.

the class TaskRunningTest method testSuccessfulRun.

@Test
public final void testSuccessfulRun() throws Exception {
    TaskCommand taskCommand = new TaskCommand();
    String taskId = mockLongJobController.runJob(taskCommand);
    // wait for job to run
    long timeout = 5000;
    ProgressData lastResult = null;
    long startTime = System.currentTimeMillis();
    wait: while (true) {
        Thread.sleep(500);
        List<ProgressData> result = progressStatusService.getProgressStatus(taskId);
        if (result.size() > 0) {
            for (ProgressData lr : result) {
                lastResult = lr;
                if (lr.isDone())
                    break wait;
            }
        }
        log.info("Waiting ..");
        if (System.currentTimeMillis() - startTime > timeout)
            fail("Test timed out");
    }
    assertNotNull(lastResult);
    assertTrue(!lastResult.isFailed());
}
Also used : List(java.util.List) TaskCommand(ubic.gemma.core.job.TaskCommand) ProgressData(ubic.gemma.core.job.progress.ProgressData) Test(org.junit.Test) BaseSpringWebTest(ubic.gemma.web.util.BaseSpringWebTest)

Aggregations

List (java.util.List)2 Test (org.junit.Test)2 TaskCommand (ubic.gemma.core.job.TaskCommand)2 ProgressData (ubic.gemma.core.job.progress.ProgressData)2 BaseSpringWebTest (ubic.gemma.web.util.BaseSpringWebTest)2