The GitHub Actions job "Tests" on airflow.git has succeeded.
Run started by GitHub user potiuk (triggered by potiuk).

Head commit for run:
4145181b844b9746a36f577f4ef4965bef110dbf / Jarek Potiuk <[email protected]>
Fix cache_clear behaviour in all fixtures and tests

When running test with pytest-xdist, tests can be executed in random
order in multiple workers. This means that if a test leaves
a side-effect, it might affect another test - much more easily,
because you are not able to rely on the sequence of test
execution.

The `recalculate_patterns` fixture in "test_serde" had such a
side effect and caused #35699 to happen.

It was used in order to clear the cache BEFORE the test so that
it could reload the patterns using different configugration
provided by the test as new configuration.

The side effect of it was however such, that after the test completed,
the new configuration remained in the cache AFTER the test has been
completed - thus if THE SAME xdist WORKER started a test that relied on
the cache containting "regular" value  (and it did not use the same
fixtuere to clean it), it - surpisingly - got the value that was read
from the special configuration provided by the previous test.

This PR fixes it by clearing the cache also AFTER the test has
completed, which means that any other test running in the same
worker will refresh the test again - with the configuration
it is supposed to have. This is done with try/finally pattern,
because context manager / yield will not execute the post-yield
code when an exception is thrown, so if there is a failed
assertion, the cache_clear afer yield might not happen and such
`cache_clear` test that fails might still cause cache pollution.

Fixes: #35699

Report URL: https://github.com/apache/airflow/actions/runs/6923389568

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to