amoghrajesh opened a new pull request, #56139:
URL: https://github.com/apache/airflow/pull/56139
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
## Purpose
We introduced a test integration framework for task SDK through:
https://github.com/apache/airflow/pull/53332. This PR establishes the
foundational infrastructure for comprehensive integration testing so that the
current test suite can be expanded further.
Through this, I aim to creates reusable components and patterns to enable
will enable systematic validation of all potentially all execution API
endpoints used by the task SDK rest API client.
## What's being done?
### Core infrastructure
1. **JWT Authentication Plugin** (`jwt_plugin.py`) - Generates valid JWT
tokens for Execution API authentication using task instance IDs, with hourly
expiry.
2. **Session-Scoped Fixtures** (`conftest.py`) - Efficient test setup that
runs docker-compose once per session, triggers test DAG, and provides
authenticated clients as needed.
### Docker compose improvements
1. **DAG Processor Dependency** - Updated docker-compose to ensure proper
component startup order (dag-processor → scheduler). Earlier, the dag processor
didn't exist, created a minimal dag that runs for long enough and will be
useful for testing situations.
2. **Environment Configuration** - Proper JWT secret and API URL
configuration for test environment
### Test Refactoring
1. **Health Test Updated** - Refactored existing health check to use session
fixtures instead of per-test docker-compose
## Task SDK integration testing flow now
Session Start (Once):
1. Install Task SDK
2. Start docker-compose (postgres → init → dag-processor → scheduler →
api-server)
3. Get auth token from `SimpleAuthManager`
4. Auto-unpause test_dag
5. Trigger test_dag via Core API
6. Wait for task instances
7. Generate JWT token for task instance
8. Create authenticated SDK client
Individual Tests (Reuse session):
- Use pre-configured authenticated client
- Test specific Execution API endpoints
- Validate responses
Session End:
- Clean up docker-compose
## What's Next
This foundation enables adding tests for all Execution API endpoints. My
idea is that I will create a structure that can be extended easily to add some
tests based on expecatations defined in a future issue so that ANYONE can
contribute to it as needed.
**Community Contributions:**
The standardized patterns make it easy for community members to contribute
endpoint-specific tests following established templates.
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
for more information.
In case of fundamental code changes, an Airflow Improvement Proposal
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party
License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a
newsfragment file, named `{pr_number}.significant.rst` or
`{issue_number}.significant.rst`, in
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]