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 files are required to be present in your repository:
- 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 - A
requirements-dev.txt
file at the root of your repository, which contains all the Python pacakges required by the test runner to run you E2E test suite(s) - A folder that contains the Airflow DAGs under test
- A folder that contains the E2E test suite(s)
Generating the test scripts
To generate the Airflow E2E test scripts, run the following command at the root of your repository:
airflow-e2e --dags dags/ --tests tests/e2e
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-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 \
down --remove-orphans --volumes
dev: clean
source ./docker/.envrc && \
docker-compose \
-f ./docker/docker-compose.yml \
-f ./docker/docker-compose-dev.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 \
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.1.1.tar.gz
.
File metadata
- Download URL: airflow-e2e-0.1.1.tar.gz
- Upload date:
- Size: 22.2 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 | 379491a62870c8bb4385e904c61deb7f79601f44bfb46ce02859bd27920bb8bc |
|
MD5 | e053a6f822143c3c78c9a7f121597a8e |
|
BLAKE2b-256 | 1df20aa34c2067813b4958092bd9dcd54292a4fd6cb52a17004ab3fd7d935647 |
File details
Details for the file airflow_e2e-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: airflow_e2e-0.1.1-py3-none-any.whl
- Upload date:
- Size: 25.4 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 | b306fe54d5723765f382a037fd0502c7a37398ce7935ca6d8d5f846b309d6ca3 |
|
MD5 | 35ec0bfcd47e34ca1c7f7b83195298cf |
|
BLAKE2b-256 | cdbbb07df32ed3987f1bac1054d19b84546c707668b80822ce2cc46c1e7c027b |