Exemple #1
0
def enqueue(app_name, job_id, validate_queued=True):
    # initialize job
    api.maybe_add_subtask(app_name, job_id)
    api.maybe_add_subtask(app_name, job_id)
    # verify initial conditions
    if validate_queued:
        validate_one_queued_task(app_name, job_id)
Exemple #2
0
def test_readd_subtask(app1, job_id1, job_id2):
    # readding the same job twice should result in error and 1 queued job
    tt.validate_zero_queued_task(app1)
    api.readd_subtask(app1, job_id1)
    tt.validate_one_queued_task(app1, job_id1)
    with nt.assert_raises(JobAlreadyQueued):
        api.readd_subtask(app1, job_id1)
    tt.validate_one_queued_task(app1, job_id1)

    # setting task pending but not queueing it.
    api.maybe_add_subtask(app1, job_id2, queue=False)
    tt.validate_one_queued_task(app1, job_id1)
    # then queueing it.
    api.readd_subtask(app1, job_id2)
    tt.validate_n_queued_task(app1, job_id1, job_id2)
Exemple #3
0
def test_readd_subtask(app1, job_id1, job_id2):
    # readding the same job twice should result in error and 1 queued job
    tt.validate_zero_queued_task(app1)
    api.readd_subtask(app1, job_id1)
    tt.validate_one_queued_task(app1, job_id1)
    with nt.assert_raises(JobAlreadyQueued):
        api.readd_subtask(app1, job_id1)
    tt.validate_one_queued_task(app1, job_id1)

    # setting task pending but not queueing it.
    api.maybe_add_subtask(app1, job_id2, queue=False)
    tt.validate_one_queued_task(app1, job_id1)
    # then queueing it.
    api.readd_subtask(app1, job_id2)
    tt.validate_n_queued_task(app1, job_id1, job_id2)
Exemple #4
0
def test_maybe_add_subtask(app1, job_id1, job_id2, job_id3):
    # we don't queue anything if we request queue=False, but we create data for
    # this node if it doesn't exist
    tt.validate_zero_queued_task(app1)
    api.maybe_add_subtask(app1, job_id1, queue=False)
    tt.validate_zero_queued_task(app1)

    # data for this job_id exists, so it can't get queued
    api.maybe_add_subtask(app1, job_id1, priority=4)
    tt.validate_zero_queued_task(app1)

    api.maybe_add_subtask(app1, job_id2, priority=8)
    tt.validate_one_queued_task(app1, job_id2)
    api.maybe_add_subtask(app1, job_id3, priority=5)
    # this should have no effect because it's already queued with priority=5
    api.maybe_add_subtask(app1, job_id3, priority=9)

    job_id = tt.cycle_queue(app1)
    nt.assert_equal(job_id3, job_id)
Exemple #5
0
def test_maybe_add_subtask(app1, job_id1, job_id2, job_id3):
    # we don't queue anything if we request queue=False, but we create data for
    # this node if it doesn't exist
    tt.validate_zero_queued_task(app1)
    api.maybe_add_subtask(app1, job_id1, queue=False)
    tt.validate_zero_queued_task(app1)

    # data for this job_id exists, so it can't get queued
    api.maybe_add_subtask(app1, job_id1, priority=4)
    tt.validate_zero_queued_task(app1)

    api.maybe_add_subtask(app1, job_id2, priority=8)
    tt.validate_one_queued_task(app1, job_id2)
    api.maybe_add_subtask(app1, job_id3, priority=5)
    # this should have no effect because it's already queued with priority=5
    api.maybe_add_subtask(app1, job_id3, priority=9)

    job_id = tt.cycle_queue(app1)
    nt.assert_equal(job_id3, job_id)
Exemple #6
0
def test_maybe_add_subtask_priority_second(app1, job_id1, job_id2):
    api.maybe_add_subtask(app1, job_id1, priority=20)
    api.maybe_add_subtask(app1, job_id2, priority=10)
    nose.tools.assert_equal(consume_queue(app1), job_id2)
    nose.tools.assert_equal(consume_queue(app1), job_id1)
Exemple #7
0
def test_maybe_add_subtask_no_priority(app1, job_id1, job_id2):
    api.maybe_add_subtask(app1, job_id1)
    api.maybe_add_subtask(app1, job_id2)
    nose.tools.assert_equal(consume_queue(app1), job_id1)
    nose.tools.assert_equal(consume_queue(app1), job_id2)