Skip to content

Fix serialization unit tests to avoid ORM side effects in --skip-db-tests mode#65206

Open
holmuk wants to merge 1 commit intoapache:mainfrom
holmuk:bugfix/remove-orm-from-non-db-tests
Open

Fix serialization unit tests to avoid ORM side effects in --skip-db-tests mode#65206
holmuk wants to merge 1 commit intoapache:mainfrom
holmuk:bugfix/remove-orm-from-non-db-tests

Conversation

@holmuk
Copy link
Copy Markdown
Contributor

@holmuk holmuk commented Apr 14, 2026

In airflow-core/tests/unit/serialization/test_serialized_objects.py, some ORM models (TaskInstance, DagRun, Connection) were instantiated at module import time. In --skip-db-tests mode, Airflow intentionally disables DB setup, so these import-time ORM side effects triggered SQLAlchemy mapper initialization and caused collection-time failures.

This PR resolves this issue:

  • Removed unused import-time ORM objects from test_serialized_objects.py to make --skip-db-tests deterministic
  • Replaced the global TaskInstance test payload in test_serialize_deserialize parameters with global TaskInstance datamodel
  • Moved Connection serialization coverage into dedicated @pytest.mark.db_test tests (test_serialize_deserialize_connection)
  • Marked test_backcompat_deserialize_connection as db_test because it creates ORM Connection class
Was generative AI tooling used to co-author this PR?

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@holmuk holmuk changed the title Fix serialization unit tests to avoid ORM side effects in --skip-db mode Fix serialization unit tests to avoid ORM side effects in --skip-db-tests mode Apr 14, 2026
@Dev-iL Dev-iL added the full tests needed We need to run full set of tests for this PR to merge label Apr 14, 2026
@Dev-iL
Copy link
Copy Markdown
Collaborator

Dev-iL commented Apr 14, 2026

To be safe, I added a tag to run more tests to make sure nothing unrelated broke as a result of these changes. These will run on the next rebase or after close/reopen.

@Dev-iL Dev-iL requested review from ashb, ephraimbuddy and uranusjr and removed request for uranusjr April 14, 2026 12:00
@holmuk holmuk force-pushed the bugfix/remove-orm-from-non-db-tests branch from ebd4aeb to 546eaa9 Compare April 14, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:DAG-processing full tests needed We need to run full set of tests for this PR to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants