Airflow: CLI command for DAG level testing does not work

Created on 28 Sep 2020  路  6Comments  路  Source: apache/airflow

Apache Airflow version: 1.10.12

What happened:
$ airflow test [dag_id] [execution_date]
gives

usage: airflow test [-h] [-sd SUBDIR] [-dr] [-tp TASK_PARAMS] [-pm]
                    dag_id task_id execution_date

positional arguments:
  dag_id                The id of the dag
  task_id               The id of the task
  execution_date        The execution date of the DAG

optional arguments:
  -h, --help            show this help message and exit
  -sd SUBDIR, --subdir SUBDIR
                        File location or directory from which to look for the
                        dag. Defaults to '[AIRFLOW_HOME]/dags' where
                        [AIRFLOW_HOME] is the value you set for 'AIRFLOW_HOME'
                        config you set in 'airflow.cfg'
  -dr, --dry_run        Perform a dry run for each task. Only renders Template
                        Fields for each task, nothing else
  -tp TASK_PARAMS, --task_params TASK_PARAMS
                        Sends a JSON params dict to the task
  -pm, --post_mortem    Open debugger on uncaught exception

airflow test command error: the following arguments are required: execution_date, see help above.

What you expected to happen:

That test should be run on DAG level, i.e., each task, in accordance to documentation:

https://airflow.apache.org/docs/stable/tutorial.html#id2

How to reproduce it:

$ airflow test [dag_id] [execution_date]

bug

Most helpful comment

Doc's will be updated for next release.

All 6 comments

Thanks for opening your first issue here! Be sure to follow the issue template!

Not a bug.
Read the usage instructions again.
You're omitting the mandatory task_id.
Follow the tutorial, it includes task_id.

The same applies to airflow test [dag_id] [execution_date], but on a DAG level. It performs a single DAG run of the given DAG id. While it does take task dependencies into account, no state is registered in the database. It is convenient for locally testing a full run of your DAG, given that e.g. if one of your tasks expects data at some location, it is available.

This piece of documentation is invalid. Testing the entire DAG is a feature exclusive to Airflow 2.0

PR to update docs on the 1.10 release branch https://github.com/apache/airflow/pull/11191

Not a bug.
Read the usage instructions again.
You're omitting the mandatory task_id.
Follow the tutorial, it includes task_id.

I am following the documentation, but it is wrong. Thats my whole point...

Doc's will be updated for next release.

Was this page helpful?
0 / 5 - 0 ratings