Search in sources :

Example 36 with Criteria

use of org.ow2.proactive.utils.Criteria in project scheduling by ow2-proactive.

the class SchedulerDBManagerTest method assertTaskStatePage.

private void assertTaskStatePage(Page<TaskState> page, TaskFilterCriteria criterias) {
    int nbTaskStates = page.getList().size();
    for (TaskState taskState : page.getList()) {
        String tag = criterias.getTag();
        if (tag != null)
            assertEquals("Tag is incorrect", tag, taskState.getTag());
        // from
        long from = criterias.getFrom();
        if (from != 0)
            assertEquals("startTime is incorrect", from, taskState.getStartTime());
        // to
        long to = criterias.getTo();
        if (to != 0)
            assertEquals("finishedTime is incorrect", to, taskState.getFinishedTime());
        // pagination
        int pageSize = criterias.getLimit() - criterias.getOffset();
        if (pageSize > 0) {
            assertTrue("Page size is incorrect", pageSize >= nbTaskStates);
        }
        // user
        String expectedUser = criterias.getUser();
        String actualUser = taskState.getTaskInfo().getJobInfo().getJobOwner();
        if (expectedUser != null && "".compareTo(expectedUser) != 0) {
            assertEquals("user is incorrect", expectedUser, actualUser);
        }
        // the corresponding criteria should be true
        switch(taskState.getStatus()) {
            case SUBMITTED:
            case PENDING:
            case NOT_STARTED:
                assertTrue("Task status is incorrect", criterias.isPending());
                break;
            case PAUSED:
            case RUNNING:
            case WAITING_ON_ERROR:
            case WAITING_ON_FAILURE:
                assertTrue("Task status is incorrect", criterias.isRunning());
                break;
            case FAILED:
            case NOT_RESTARTED:
            case ABORTED:
            case FAULTY:
            case FINISHED:
            case SKIPPED:
                assertTrue("Task status is incorrect", criterias.isFinished());
                break;
            default:
                fail("Incoherent task status");
        }
    }
}
Also used : TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Aggregations

Criteria (org.ow2.proactive.utils.Criteria)25 NodeSet (org.ow2.proactive.utils.NodeSet)23 Test (org.junit.Test)16 Node (org.objectweb.proactive.core.node.Node)9 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)7 ArrayList (java.util.ArrayList)7 RMCore (org.ow2.proactive.resourcemanager.core.RMCore)6 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)6 CredData (org.ow2.proactive.authentication.crypto.CredData)5 Credentials (org.ow2.proactive.authentication.crypto.Credentials)5 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)5 Client (org.ow2.proactive.resourcemanager.authentication.Client)4 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)4 LinkedList (java.util.LinkedList)3 RMAuthentication (org.ow2.proactive.resourcemanager.authentication.RMAuthentication)3 RMState (org.ow2.proactive.resourcemanager.common.RMState)3 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)3 PublicKey (java.security.PublicKey)2 HashMap (java.util.HashMap)2 List (java.util.List)2