Skip to content

Fix test collection for Connection and Variables for non-db tests - #45249

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:make-microsoft-azure-non-db-tests-collection-works
Dec 27, 2024
Merged

Fix test collection for Connection and Variables for non-db tests#45249
potiuk merged 1 commit into
apache:mainfrom
potiuk:make-microsoft-azure-non-db-tests-collection-works

Conversation

@potiuk

@potiuk potiuk commented Dec 27, 2024

Copy link
Copy Markdown
Member

When Tests were collected for microsoft provider alone for non-db tests, Connection were used in "parametrized" to perameterize the tests. This was only working accidentally so far because all ORM models were loaded before in other tests - including Triggers -and then the connection objects did not trigger any DB operations. But when microsoft provider tests were run first (and in separation), the Triggers were not imported and Connection creation caused error:

When initializing mapper mapped class AssetModel->asset, expression
'Trigger' failed to locate a name ('Trigger') # Please enter the commit
message for your changes. Lines starting

This can be mitigated (as already advised in unit tests documentation) by replacing Connections with MagicMock.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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 newsfragments.

When Tests were collected for microsoft provider alone for non-db
tests, Connection were used in "parametrized" to perameterize the
tests. This was only working accidentally so far because all ORM
models were loaded before in other tests - including Triggers -and
then the connection objects did not trigger any DB operations. But
when microsoft provider tests were run first (and in separation),
the Triggers were not imported and Connection creation caused error:

> When initializing mapper mapped class AssetModel->asset, expression
  'Trigger' failed to locate a name ('Trigger') # Please enter the commit
  message for your changes. Lines starting

This can be mitigated (as already advised in unit tests documentation)
by replacing Connections with MagicMock.
@potiuk

potiuk commented Dec 27, 2024

Copy link
Copy Markdown
Member Author

Discovered when looking why #45249 has been failing - very interesting side-effect in our tests

@gopidesupavan gopidesupavan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting one :)

@potiuk

potiuk commented Dec 27, 2024

Copy link
Copy Markdown
Member Author

Interesting one :)

Indeed - we should likely improve some of the diagnostics there and fail "earlier" and with "clearer" message - but for now this one should be "good enough"

@potiuk
potiuk merged commit aab2b88 into apache:main Dec 27, 2024
@potiuk
potiuk deleted the make-microsoft-azure-non-db-tests-collection-works branch December 27, 2024 20:23
jason810496 pushed a commit to jason810496/airflow that referenced this pull request Dec 28, 2024
…ache#45249)

When Tests were collected for microsoft provider alone for non-db
tests, Connection were used in "parametrized" to perameterize the
tests. This was only working accidentally so far because all ORM
models were loaded before in other tests - including Triggers -and
then the connection objects did not trigger any DB operations. But
when microsoft provider tests were run first (and in separation),
the Triggers were not imported and Connection creation caused error:

> When initializing mapper mapped class AssetModel->asset, expression
  'Trigger' failed to locate a name ('Trigger') # Please enter the commit
  message for your changes. Lines starting

This can be mitigated (as already advised in unit tests documentation)
by replacing Connections with MagicMock.
HariGS-DB pushed a commit to HariGS-DB/airflow that referenced this pull request Jan 16, 2025
…ache#45249)

When Tests were collected for microsoft provider alone for non-db
tests, Connection were used in "parametrized" to perameterize the
tests. This was only working accidentally so far because all ORM
models were loaded before in other tests - including Triggers -and
then the connection objects did not trigger any DB operations. But
when microsoft provider tests were run first (and in separation),
the Triggers were not imported and Connection creation caused error:

> When initializing mapper mapped class AssetModel->asset, expression
  'Trigger' failed to locate a name ('Trigger') # Please enter the commit
  message for your changes. Lines starting

This can be mitigated (as already advised in unit tests documentation)
by replacing Connections with MagicMock.
got686-yandex pushed a commit to got686-yandex/airflow that referenced this pull request Jan 30, 2025
…ache#45249)

When Tests were collected for microsoft provider alone for non-db
tests, Connection were used in "parametrized" to perameterize the
tests. This was only working accidentally so far because all ORM
models were loaded before in other tests - including Triggers -and
then the connection objects did not trigger any DB operations. But
when microsoft provider tests were run first (and in separation),
the Triggers were not imported and Connection creation caused error:

> When initializing mapper mapped class AssetModel->asset, expression
  'Trigger' failed to locate a name ('Trigger') # Please enter the commit
  message for your changes. Lines starting

This can be mitigated (as already advised in unit tests documentation)
by replacing Connections with MagicMock.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants