test
Definition
Tests a task instance. This will run a task without checking for dependencies or recording its state in the database.
Usage
$ airflow tasks test [-h] [-n] [--env-vars ENV_VARS] [--map-index MAP_INDEX]
[-m] [-S SUBDIR] [-t TASK_PARAMS] [-v]
dag_id task_id [execution_date_or_run_id]
Arguments
| Parameter | Description |
|---|---|
dag_id |
ID of the DAG |
task_id |
ID of the task |
execution_date_or_run_id |
The |
-n, --dry-run |
Perform a dry run for each task. Only renders Template Fields for each task, nothing else |
--env-vars |
Set environment variable in both parsing time and runtime for each entry supplied in a JSON dictionary |
--map-index |
Mapped task index |
-m, --post-mortem |
Open debugger on uncaught exception |
-t, --task-params |
Send a JSON parameters dictionary to the task |
-S, --subdir |
File or directory location for DAGs. Defaults to |
-h, --help |
Print out the help manual for this command |
-v, --verbose |
Make logging output more verbose |
Examples
Example command for testing a task instance:
$ airflow tasks test tutorial print_date scheduled__2025-04-13T15:26:57.044494+00:00
Output example:
[2025-04-15T07:41:32.631+0000] {dagbag.py:541} INFO - Filling up the DagBag from /opt/airflow/dags
[2025-04-15T07:41:33.134+0000] {example_python_operator.py:90} WARNING - The virtalenv_python example task requires virtualenv, please install it.
[2025-04-15T07:41:33.729+0000] {tutorial_taskflow_api_virtualenv.py:29} WARNING - The tutorial_taskflow_api_virtualenv example DAG requires virtualenv, please install it.
[2025-04-15T07:41:34.220+0000] {taskinstance.py:1103} INFO - Dependencies all met for dep_context=non-requeueable deps ti=<TaskInstance: tutorial.print_date scheduled__2025-04-13T15:26:57.044494+00:00 [success]>
[2025-04-15T07:41:34.227+0000] {taskinstance.py:1103} INFO - Dependencies all met for dep_context=requeueable deps ti=<TaskInstance: tutorial.print_date scheduled__2025-04-13T15:26:57.044494+00:00 [success]>
[2025-04-15T07:41:34.227+0000] {taskinstance.py:1308} INFO - Starting attempt 2 of 2
[2025-04-15T07:41:34.232+0000] {taskinstance.py:1327} INFO - Executing <Task(BashOperator): print_date> on 2025-04-13 15:26:57.044494+00:00
[2025-04-15T07:41:34.281+0000] {taskinstance.py:1545} INFO - Exporting env vars: AIRFLOW_CTX_DAG_EMAIL='airflow@example.com' AIRFLOW_CTX_DAG_OWNER='airflow' AIRFLOW_CTX_DAG_ID='tutorial' AIRFLOW_CTX_TASK_ID='print_date' AIRFLOW_CTX_EXECUTION_DATE='2025-04-13T15:26:57.044494+00:00' AIRFLOW_CTX_TRY_NUMBER='2' AIRFLOW_CTX_DAG_RUN_ID='scheduled__2025-04-13T15:26:57.044494+00:00'
[2025-04-15T07:41:34.282+0000] {subprocess.py:63} INFO - Tmp dir root location: /tmp
[2025-04-15T07:41:34.283+0000] {subprocess.py:75} INFO - Running command: ['/bin/bash', '-c', 'date']
[2025-04-15T07:41:34.291+0000] {subprocess.py:86} INFO - Output:
[2025-04-15T07:41:34.293+0000] {subprocess.py:93} INFO - Tue Apr 15 07:41:34 UTC 2025
[2025-04-15T07:41:34.293+0000] {subprocess.py:97} INFO - Command exited with return code 0
[2025-04-15T07:41:34.307+0000] {taskinstance.py:1345} INFO - Marking task as SUCCESS. dag_id=tutorial, task_id=print_date, execution_date=20250413T152657, start_date=20250414T152712, end_date=20250415T074134