You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/10/24 15:04:21 UTC
[GitHub] [airflow] ReadytoRocc commented on a change in pull request #19183: Clearing ti.next_method and ti.next_kwargs on task finish.
ReadytoRocc commented on a change in pull request #19183:
URL: https://github.com/apache/airflow/pull/19183#discussion_r735131688
##########
File path: tests/models/test_taskinstance.py
##########
@@ -481,18 +482,51 @@ def task_function(ti):
ti.refresh_from_db()
ti.state == state
- def test_task_retry_wipes_next_fields(self, session, dag_maker):
+ @pytest.mark.parametrize(
+ "state",
+ [State.FAILED, State.SKIPPED, State.SUCCESS, State.UP_FOR_RESCHEDULE, State.UP_FOR_RETRY],
+ )
+ def test_task_wipes_next_fields(self, session, state, dag_maker):
"""
Test that ensures that tasks wipe their next_method and next_kwargs
- fields when they are queued for retry after a failure.
+ when they go into a state of FAILED, SKIPPED, SUCCESS, UP_FOR_RESCHEDULE, or UP_FOR_RETRY.
"""
- with dag_maker('test_mark_failure_2'):
- task = BashOperator(
- task_id='test_retry_handling_op',
- bash_command='exit 1',
- retries=1,
- retry_delay=datetime.timedelta(seconds=2),
+ def failure():
+ raise AirflowException
+
+ def skip():
+ raise AirflowSkipException
+
+ def success():
+ return None
+
+ def reschedule():
+ reschedule_date = timezone.utcnow()
+ raise AirflowRescheduleException(reschedule_date)
+
+ _retries = 0
+ _retry_delay = datetime.timedelta(seconds=0)
+
+ if state == State.FAILED:
+ _python_callable = failure
+ elif state == State.SKIPPED:
+ _python_callable = skip
+ elif state == State.SUCCESS:
+ _python_callable = success
+ elif state == State.UP_FOR_RESCHEDULE:
+ _python_callable = reschedule
+ elif state in [State.FAILED, State.UP_FOR_RETRY]:
+ _python_callable = failure
+ _retries = 1
+ _retry_delay = datetime.timedelta(seconds=2)
+
+ with dag_maker("test_deferred_method_clear"):
+ task = PythonOperator(
+ task_id="test_deferred_method_clear_task",
+ python_callable=_python_callable,
Review comment:
@jedcunningham thanks for the the suggestions. Will do.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org