You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make it easier and faster to iterate on task-sdk-integration-tests
There were a few of things that made task-sdk-tests iteration
a bit unobvious and slower. With this PR, we should be able
to iterate over task-sdk-integration-tests WAY faster and get
more contributors involved in contributing to those.
* It was not clear that prerequisite of running the tests was building
PROD image for Pyton 3.10. This is now clear in the documentation.
* PROD images can be built in two different modes - from sources
with --installation-method equal to . or from packages with
the --installatio-method equal to "apache-airflow". This was
not clearly communicated during build and it is now printed at
output
* It was not clear that when you build PROD images from sources,
you should first compile ui assets, because otehrwise the
assets are not added as part of the image. With this PR the
`breeze prod-image build` command checks if the .vite manifest
is present in the right `dist` folders and will error out,
suggesting to run `breeze compile-ui-assets` before.
* If the PROD image has not been built before, breeze will propose
to build it and even do it automatically if the answer is not
provided within 20 seconds.
* when building PROD images from sources, it is faster to rebuild
the images with `uv` than with `pip`. the --use-uv parameter now
defaults to False when building from packages and to True when
building from sources.
* There was an error in .dockerignore where generated dist files
were not added to context when PROD image was built from sources.
This resulted in "permission denied' when such PROD images were used
to run tests.
* The test compose had fallback of Airflow 3.0.3 which would be
misleading if it happened. Now, AIRFLOW_IMAGE_NAME is mandatory
* We are now mounting sources of Airflow to inside the image by default
and skip it in CI. This mounting happens in local environment where PROD
image is built usually from sources, and it is disabled in CI by using
--skip-mounting-local-volumes flag. We also do not stop docker compose
by default when runnig it locally in order to make fast iteration the
default.
* We pass host operating system when starting the compose, and we only
change ownership on Linux - this is a long running operation on MacOS
because mounted filesystem is slow, but it's also not needed on MacOS
because the file system also maps ownershipt and files created by
Airflow are created with local user id.
* We pass local user id to containers to make sure that the files
created on linux are created by the local user (logs and the like).
* We are now detecting whether docker-compose is running and when we run
with locally mounted sources, we reuse those running containers. When
we don't mount local sources, we shut-down the compose before running
to make sure we do not have sources mounted - and we close the compose
by default when we do not mount local sources.
* When sources are mounted we are only enabling DEV_MODE inside the containers
so that components are hot-reloading (new feature added in apache#57741
last weeks. This way you do not have to restart anything when sources
are changed and you can re-run the tests when docker compose is running.
* The environment are passsed now via .env file so that you can easily
reproduce docke compose command locally
* The docker compose files are not copied any more, they are moved directly
to the top of 'task-sdk-integraiton-tests' and used from there.
* A `--down` flag is added to breeze testing task-sdk-integration-tests
that tears down running docker compose.
* Additional diagnostics added to show what's going on.
* Handling verbose option from breeze by adding more debugging information
* Updated documentation about the tests to be more comprehensive about
the options, updated file structure etc.
* Small QOL immprovement - if expected dags are not yet parsed by dag file
processor, when test starts, getting their status will return 404 "Not
Found". In such case our tests implemented a short retry scheme with tenacity
Since you're already working in the Airflow repository, you can run Task SDK Integration Tests
94
-
directly:
141
+
Since you're already working in the Airflow repository, you can run Task SDK Integration Tests directly.
142
+
Make sure you have ``uv`` installed in your environment and make sure to run all these commands
143
+
in the ``task-sdk-integration-tests`` directory. You can also run ``uv sync`` in the directory
144
+
first to make sure that your virtual environment is up to date.
145
+
146
+
.. code-block::
147
+
148
+
# Navigate to task-sdk-integration-tests directory
149
+
cd task-sdk-integration-tests
150
+
151
+
# Sync dependencies
152
+
uv sync
153
+
154
+
All the ``uv`` and ``docker compose`` commands below should be run from within the
155
+
``task-sdk-integration-tests`` directory.
95
156
96
157
**Run Tests**
97
158
98
159
.. code-block:: bash
99
160
100
161
# Navigate to task-sdk-integration-tests directory and run tests
101
-
cd task-sdk-integration-tests/
102
162
uv run pytest -s
103
163
104
164
# Run specific test file
105
-
cd task-sdk-integration-tests/
106
165
uv run pytest tests/task_sdk_tests/test_task_sdk_health.py -s
107
166
108
-
# Keep containers running for debugging
109
-
cd task-sdk-integration-tests/
110
-
SKIP_DOCKER_COMPOSE_DELETION=1 uv run pytest -s
111
-
112
167
**Optional: Set Custom Docker Image**
113
168
114
169
.. code-block:: bash
115
170
116
171
# Use a different Airflow image for testing
117
-
cd task-sdk-integration-tests/
118
172
DOCKER_IMAGE=my-custom-airflow:latest uv run pytest -s
119
173
174
+
By default when you run your tests locally, the Docker Compose deployment is kept between the sessions,
175
+
your local sources are mounted into the containers and the Airflow services are restarted automatically with hot reloading when any Python sources change.
176
+
177
+
This allows for quick iterations without rebuilding the image or restarting the containers.
178
+
179
+
Generated .env file
180
+
...................
181
+
182
+
When you run the tests an .env file is generated in the task-sdk-integration-tests directory.
183
+
This file contains environment variables used by docker-compose to configure the services.
184
+
You can inspect or modify this file if you need to change any configurations so that you can
185
+
also debug issues by running ``docker compose`` commands directly.
186
+
187
+
When running the tests with ``VERBOSE=1`` environment variable set or ``--verbose`` flag passed to breeze command,
188
+
the docker-compose commands used to start the services are also printed to the console and you can copy
189
+
them to run them directly.
190
+
191
+
Stopping docker-compose
192
+
.......................
193
+
194
+
When you finish testing (or when you updated dependencies and rebuild your images),
195
+
you likely want to stop the running containers. You can stop the the running containers by running:
196
+
197
+
.. code-block:: bash
198
+
199
+
# Stop and remove containers
200
+
docker-compose down -v --remove-orphans
201
+
202
+
and with breeze:
203
+
204
+
205
+
.. code-block:: bash
206
+
207
+
# Using Breeze to stop docker compose
208
+
breeze testing task-sdk-integration-tests --down
209
+
210
+
Docker compose will be automatically started again next time you run the tests.
211
+
212
+
Running tests in the way CI does it
213
+
....................................
214
+
215
+
Our CI runs the tests in a clean environment every time without mounting local sources. This means that
216
+
any changes you have locally will not be visible inside the containers. You can reproduce it locally by adding
217
+
``--skip-mounting-local-volumes`` to breeze command or by setting ``SKIP_MOUNTING_LOCAL_VOLUMES=1`` in your
218
+
environment when running tests locally. Before that however make sure that your PROD image is rebuilt
219
+
using latest sources. When you disable mounting local volumes, the containers will be stopped by default
220
+
when the tests end, you can disable that by setting SKIP_DOCKER_COMPOSE_DELETION=1 in your environment
221
+
or passing --skip-docker-compose-deletion to breeze command.
0 commit comments