Skip to content

test: add Airflow 3 DAG versioning tests for Cosmos#2177

Merged
tatiana merged 7 commits into
astronomer:mainfrom
michal-mrazek:main
Jan 29, 2026
Merged

test: add Airflow 3 DAG versioning tests for Cosmos#2177
tatiana merged 7 commits into
astronomer:mainfrom
michal-mrazek:main

Conversation

@michal-mrazek
Copy link
Copy Markdown
Contributor

Description

This PR adds a test for Airflow 3 versioning. We verify that adding a model to DbtDag will change a dag version.

Related Issue(s)

#2131

Breaking Change?

Checklist

  • I have made corresponding changes to the documentation (if required)
  • I have added tests that prove my fix is effective or that my feature works

Copilot AI review requested due to automatic review settings December 2, 2025 20:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds integration tests for Airflow 3's DAG versioning system to verify that Cosmos correctly handles version tracking when dbt models are added or when DAGs remain unchanged.

Key Changes:

  • Added comprehensive test fixtures for DAG serialization, cleanup, and task instance creation
  • Implemented two integration tests verifying version increment behavior with structural changes and version stability without modifications

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_airflow_versioning.py Outdated
Comment thread tests/test_airflow_versioning.py Outdated
Comment thread tests/test_airflow_versioning.py Outdated
Comment thread tests/test_airflow_versioning.py Outdated
@pankajastro
Copy link
Copy Markdown
Contributor

Thank you so much for the work on this PR — I really appreciate the effort! 🙌

One quick note: Cosmos handles DAG versioning a bit differently. For context, Cosmos added DAG-versioning support in this PR: #1907

It might be more aligned with the Cosmos approach to structure the test like:

Curious to hear what you think — happy to collaborate on the approach!

@michal-mrazek
Copy link
Copy Markdown
Contributor Author

Thank you so much for the work on this PR — I really appreciate the effort! 🙌

One quick note: Cosmos handles DAG versioning a bit differently. For context, Cosmos added DAG-versioning support in this PR: #1907

It might be more aligned with the Cosmos approach to structure the test like:

Curious to hear what you think — happy to collaborate on the approach!

Thanks @pankajastro, I will adjust the PR 👍

@michal-mrazek
Copy link
Copy Markdown
Contributor Author

@pankajastro I started using the run_dag() as you suggested. I also switched from jaffle shop to simple dbt project, since we are actually running it and I didn't want it to take ages :)

If you have any other suggestions, happy to include them :)

@pankajastro
Copy link
Copy Markdown
Contributor

pankajastro commented Dec 11, 2025

@pankajastro I started using the run_dag() as you suggested. I also switched from jaffle shop to simple dbt project, since we are actually running it and I didn't want it to take ages :)

If you have any other suggestions, happy to include them :)

Thanks for addressing it. We run jaffle_shop in many tests, so it may be ok to run it. I have one more feedback otherwise looking good

Comment thread tests/test_airflow_versioning.py
@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 18, 2025

Deploy Preview for astronomer-cosmos canceled.

Name Link
🔨 Latest commit 13aba56
🔍 Latest deploy log https://app.netlify.com/projects/astronomer-cosmos/deploys/697b8c0cdbfa770008bc588d

@tatiana tatiana added this to the Cosmos 1.13.0 milestone Dec 18, 2025
@tatiana tatiana assigned pankajastro and pankajkoti and unassigned pankajastro Dec 22, 2025
Copy link
Copy Markdown
Contributor

@pankajkoti pankajkoti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing this valuable PR @michal-mrazek

A few tests are failing in the CI. Would you be able to investigate those, please?

Also, issue #2131 mentions in point 2 to also add a test for "changes that should not lead to DAG change, no new version". Do you think we can add that test as well as part of this PR?

@michal-mrazek
Copy link
Copy Markdown
Contributor Author

Hello @pankajkoti , hopefully I fixed the tests now :)

I did not find a scenarion when "changes that should not lead to DAG change, no new version". To by knowledge, all changes lead to a new version, or am I wrong here? :)

@tatiana
Copy link
Copy Markdown
Collaborator

tatiana commented Jan 29, 2026

@michal-mrazek, it feels we're really close to merging this PR. If you get a chance, please, fix the last failing checks. If we can do this before tomorrow, we can release it as part of 1.13.0, or we'll merge this after this release

@michal-mrazek
Copy link
Copy Markdown
Contributor Author

@tatiana I am on it right now, so we can merge it today :)

@michal-mrazek
Copy link
Copy Markdown
Contributor Author

I think the tests should pass now, if you can pls trigger it 🙏

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.12%. Comparing base (d04da62) to head (13aba56).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2177   +/-   ##
=======================================
  Coverage   98.12%   98.12%           
=======================================
  Files         100      100           
  Lines        6719     6719           
=======================================
  Hits         6593     6593           
  Misses        126      126           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@tatiana tatiana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests like this help us ensure Cosmos behaves as we expect. I know this PR went through many iterations and improvements. Thanks a lot @michal-mrazek for addressing each and every piece of feedback, and for your patience with our delays, and for bringing it to completion.

@tatiana tatiana merged commit fe7df6a into astronomer:main Jan 29, 2026
162 of 168 checks passed
@pankajastro pankajastro mentioned this pull request Jan 30, 2026
tatiana added a commit that referenced this pull request Jan 30, 2026
Features

* Support cross-referencing models across dbt projects using dbt-loom by
@pankajkoti in #2271
* Support use of YAML selectors when using ``LoadMode.DBT_MANIFEST`` by
@YourRoyalLinus in #2261
* Introduce ``ExecutionMode.WATCHER_KUBERNETES`` to use the watcher with
``KubernetesPodOperator`` by @tatiana in #2207
* Add support for StarRocks profile mapping by @kurkim0661 in #2256
* Allow pushing URIs as XComs for Cosmos tasks by @corsettigyg in #2275
* Support defining custom callbacks alongside the ``WATCHER_KUBERNETES``
callback by @johnhoran in #2307

Enhancements

* Refactor: remove duplicate ``_construct_dest_file_path`` by @jx2lee in
#2077
* Leverage Airflow ``::group::`` to group logs associated with DAG
parsing by @tatiana in #2235
* Refactor ``DbtConsumerWatcherSensor`` for reusability by @tatiana in
#2245
* Restore plain text output when using ``ExecutionMode.WATCHER`` by
@tiovader in #2241

Bug Fixes

* Fix running empty models or ephemeral nodes in
``ExecutionMode.WATCHER`` by @tatiana in #2279
* Improve watcher producer task priority in scheduling and the UI by
@tatiana in #2237
* Fix typos and formatting issues in documentation by @pankajkoti in
#2259
* Allow watcher producer retries without erroring by @tatiana in #2283
* Fix ``TestBehavior.AFTER_ALL`` is missing project_name information
when loading project using manifest file by @tuantran0910 in #2242
* Fix duplicate log lines in watcher subprocess execution and format
timestamps by @pankajkoti in #2301

Docs

* Add Watcher Kubernetes documentation by @tatiana in #2303
* Document newly added telemetry metrics in the privacy notice by
@pankajkoti in #2249
* Add compatibility policy document by @pankajastro in #2251
* Improve watcher documentation related to dbt threads by @tatiana in
#2273
* Fix link in watcher execution mode documentation by @jedcunningham in
#2277
* Update Apache Airflow minimum compatibility policy by @tatiana in
#2285
* Clarify Cosmos runtime support until "End of Basic Support" by
@jedcunningham in #2286
* Update watcher docs by @tatiana in #2298
* Update watcher kubernetes documentation by @tatiana in #2306

Others

* Add Airflow 3 DAG versioning tests for Cosmos by @michal-mrazek in
#2177
* Add dbt Core 1.11 to the test matrix by @tatiana in #2230
* Add integration tests using InvocationMode.SUBPROCESS and validate
output by @tatiana in #2287
* Fix main branch failing tests by @tatiana in #2296
* Update pre-commit hooks to the latest versions by @jedcunningham in
#2289
* Pre-commit autoupdates by @pre-commit in #2222, #2264, #2274 and #2290
* Dependabot updates by @dependabot in #2218, #2219, #2220, #2280 and
#2284
* Add Scarf metrics to understand Cosmos feature usage patterns
- Add telemetry tracking for dbt docs plugin usage by @pankajkoti in
#2240
- Add DAG run telemetry metrics for load mode, invocation, and
render_config parameters by @pankajkoti in #2223
  - Collect profile metrics for DAG runs by @pankajastro in #2228
- Compress telemetry metadata to reduce serialized DAG size by
@pankajkoti in #2252
- Skip storing telemetry metadata when emission is disabled by
@pankajkoti in #2278
- Hide telemetry metadata parameters from the Airflow trigger UI by
@pankajkoti in #2247

closes:
astronomer/oss-integrations-private#317

---------

Co-authored-by: Tatiana Al-Chueyr <tatiana.alchueyr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants