Difference between "airflow run" and "airflow test" in Airflow

Reading through the docs myself, I see how it can be confusing.

Airflow Run will run a task instance as if you had triggered it directly through the UI. Perhaps most importantly the state will be recorded in the database and that state will be reflected in the UI as if the task had run under automatic circumstances

Airflow Test will skip any dependency (task, concurrency, pool etc) checks that may otherwise occur through an automatic run and run the task without updating the database. This means that you can "test" a task multiple times and it will execute, but the state in the database will not reflect runs triggered through the test command.


According to the document information is as follows: Note that the airflow test command runs task instances locally, outputs their log to stdout (on screen), doesn’t bother with dependencies, and doesn’t communicate state (running, success, failed, . . . ) to the database. It simply allows testing a single task instance.


Before you run airflow command, source the virtual env and set AIRFLOW_HOME. airflow run is equivalent of running the task from UI. This means task run is recorded by the instance. The status is reflected in UI. It writes the log to the Log folder per the airflow configuration. Leaves an audit trail in DB.

airflow test lets you execute the task without any traces in the metadata DB. It does not record the status of this task instance in DB, so it will not reflect the task's status in UI. Mostly this method is used if you want to test a task multiple times and don't want to keep an audit trail in DB.

Tags:

Airflow