Create E2E test scripts for Airflow DAGs testing
Project description
airflow-e2e
This packages aims to set up the scripts to run Airflow DAGs E2E tests.
Installation
pip install airflow-e2e
Usage
Pre-requisites
Before generating and running the E2E test scripts, the following folders and files are required to be present in your repository:
- A folder that contains the Airflow DAGs under test
- A folder that contains the E2E test suite(s)
Optionally, we can have a requirements.txt
file at the root of your repository, which
contains all Python packages required by your Airflow scheduler and workers to perform
the tasks under tests.
In addition, we can optionally have a requirements-dev.txt
file at the root of your
repository, which contains all the Python packages required by the test runner to run
your E2E test suites.
Generating the test scripts
To generate the Airflow E2E test scripts, run the following command at the root of your repository:
Generating Airflow E2E test scripts without requirements.txt
and
requirements-dev.txt
:
airflow-e2e --dags dags/ --tests tests/e2e
If you have packages to be installed in the Airflow services:
airflow-e2e --dags dags/ --tests tests/e2e --with-custom-airflow-packages
If you have packages to be installed in the test runner service:
airflow-e2e --dags dags/ --tests tests/e2e --with-custom-test-packages
If you would like to have a MongoDB service to be set up together:
airflow-e2e --dags dags/ --tests tests/e2e --with-mongo
This will generate a docker
folder at the root of your repository, and it will
contain the following files:
<root_of_repository>
|- docker/
|- airflow_connections_and_variables_seeder/
| |- connections.yml
| |- variables.json
|- .envrc
|- docker-compose.yml
|- docker-compose-dev.yml
|- docker-compose-extras.yml
|- docker-compose-manual-testing.yml
|- docker-compose-tests.yml
In addition, for your convenience, the following make
commands are printed on
the console, should you be interested to use them:
clean:
source ./docker/.envrc && \
docker-compose \
-f ./docker/docker-compose.yml \
-f ./docker/docker-compose-dev.yml \
-f ./docker/docker-compose-tests.yml \
-f ./docker/docker-compose-extras.yml \
down --remove-orphans --volumes
dev: clean
source ./docker/.envrc && \
docker-compose \
-f ./docker/docker-compose.yml \
-f ./docker/docker-compose-dev.yml \
-f ./docker/docker-compose-extras.yml \
up -d
wait_for_airflow_web_to_be_healthy:
until [ $$(docker inspect -f '{{.State.Health.Status}}' airflow-web) = "healthy" ] ; do \
sleep 1 ; \
done
seeded_dev: dev wait_for_airflow_web_to_be_healthy
docker exec airflow-scheduler sh -c \
"airflow connections import /tmp/seed/connections.yaml && airflow variables import /tmp/seed/variables.json"
e2e:
source ./docker/.envrc && \
docker-compose \
-f ./docker/docker-compose.yml \
-f ./docker/docker-compose-tests.yml \
-f ./docker/docker-compose-extras.yml \
up --exit-code-from test-runner
Setting up the E2E tests
A .envrc
file is generated in the docker/
folder as well. Replace the values of
the fields with the placeholder <SECRET_STRING_TO_BE_FILLED_IN>
with actual values
of your choice. Please remember to add the following to your source code versioning
tool ignore file (.gitignore
for Git, for example):
.envrc*
Even though we may be using dummy credentials for our tests, we should still be vigilant when it comes to committing secrets.
Running the E2E tests
To run the E2E tests, you can run the following command:
source ./docker/.envrc && \
docker-compose \
-f ./docker/docker-compose.yml \
-f ./docker/docker-compose-tests.yml \
up --exit-code-from test-runner
Or, if you have copied the convenient make
command from before, you can run:
make e2e
License
GNU GENERAL PUBLIC LICENSE v3
Testing
To run the tests, run the following command at the root of the repository:
make test
Changelog
Refer to CHANGELOG.md
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file airflow-e2e-0.2.0.tar.gz
.
File metadata
- Download URL: airflow-e2e-0.2.0.tar.gz
- Upload date:
- Size: 27.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de4b8cf0c72d2d225faa4236f7d3f81612421f16dc244ee24bac0dded9cdc42d |
|
MD5 | 55c7084f19e2183412a67c01474f9f34 |
|
BLAKE2b-256 | 722d8a603664efef386976983ecd9dd0ccd75825fc58b67b5e5944d5bf0b69c0 |
File details
Details for the file airflow_e2e-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: airflow_e2e-0.2.0-py3-none-any.whl
- Upload date:
- Size: 40.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e0c204691615b6bb0ba754adf25d2363aebf4696a4b3cb42278484a9c19ff9e |
|
MD5 | 948d614de218d516da97c8b668a23cbd |
|
BLAKE2b-256 | e68c928ad2aea564a1ad917731308a0275bc8409866d77bfa9810d861fa393eb |