Beispiel #1
0
def test_create_child_task_after_one_parent_completed(
        app1, app2, app3, job_id1, log, tasks_json_tmpfile, func_name):
    # if you modify the tasks.json file in the middle of processing the dag
    # modifications to the json file should be recognized

    # the child task should run if another parent completes
    # but otherwise should not run until it's manually queued

    injected_app = app3
    dct = {
        injected_app: {
            "depends_on": {"app_name": [app1, app2]},
        },
    }

    qb.set_state(
        app1, job_id1, completed=True)
    validate_one_completed_task(app1, job_id1)
    validate_zero_queued_task(injected_app)
    consume_queue(app2)
    qb.set_state(app2, job_id1, completed=True)

    with inject_into_dag(func_name, dct):
        validate_zero_queued_task(injected_app)
        qb.set_state(app2, job_id1, completed=True)
        validate_zero_queued_task(injected_app)
        qb.set_state(app1, job_id1, completed=True)
        validate_one_queued_task(injected_app, job_id1)

        run_code(log, tasks_json_tmpfile, injected_app, '--bash_cmd echo 123')
        validate_one_completed_task(injected_app, job_id1)
Beispiel #2
0
def test_create_parent_task_after_child_completed(app1, app3, job_id1,
                                                  func_name):
    # if you modify the tasks.json file in the middle of processing the dag
    # modifications to the json file should be recognized appropriately

    # we do not re-schedule the child unless parent is completed

    qb.set_state(app1, job_id1, completed=True)
    validate_one_completed_task(app1, job_id1)

    injected_app = app3
    child_injapp = 'test_stolos/%s/testX' % func_name
    dct = {
        injected_app: {
        },
        child_injapp: {
            "depends_on": {"app_name": [injected_app]}
        }
    }
    with inject_into_dag(func_name, dct):
        validate_zero_queued_task(injected_app)
        qb.set_state(injected_app, job_id1, completed=True)
        validate_one_completed_task(injected_app, job_id1)
        validate_one_queued_task(child_injapp, job_id1)