session.add(tr)
    session.add(TaskFail(ti))
    XCom.set(key="test", value="value", task_id=ti.task_id, dag_id=dag.dag_id, run_id=ti.run_id)
    session.commit()
    for table in [TaskFail, TaskInstanceNote, TaskReschedule, XCom]:
        assert session.query(table).count() == 1
    dr1.task_instance_scheduling_decisions(session)
    for table in [TaskFail, TaskInstanceNote, TaskReschedule, XCom]:
        assert session.query(table).count() == 0
def test_dagrun_with_note(dag_maker, session):
    with dag_maker():
        @task
        def the_task():
            print("Hi")
        the_task()
    dr: DagRun = dag_maker.create_dagrun()
    dr.note = "dag run with note"
    session.add(dr)
    session.commit()
    dr_note = session.query(DagRunNote).filter(DagRunNote.dag_run_id == dr.id).one()
    assert dr_note.content == "dag run with note"
    session.delete(dr)
    session.commit()
    assert session.query(DagRun).filter(DagRun.id == dr.id).one_or_none() is None
    assert session.query(DagRunNote).filter(DagRunNote.dag_run_id == dr.id).one_or_none() is None
@pytest.mark.parametrize(
    "dag_run_state, on_failure_fail_dagrun", [[DagRunState.SUCCESS, False], [DagRunState.FAILED, True]]
)
def test_teardown_failure_behaviour_on_dagrun(dag_maker, session, dag_run_state, on_failure_fail_dagrun):