Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: sort pytest params to guarantee identical ordering across workers #1602

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

james-garner-canonical
Copy link
Contributor

@james-garner-canonical james-garner-canonical commented Mar 3, 2025

This PR updates the scenario tests to sort any set parameters so that the ordering is guaranteed to be the same every time. This is necessary because pytest-xdist will error if workers have different (or differently ordered) tests, because it refers to tests by index.

each worker performs a standard collection, and sends the collected test ids (in order) back to the master node. The master node ensures every worker collected the same number of tests and in the same order, because the scheduler will from that point on send just the test indexes (not the entire node id) to each worker to tell them which test to execute. That's why the collection must be the same across all workers.

This resolves failures like this one.

_____________________________ ERROR collecting gw1 _____________________________
Different tests were collected between gw0 and gw1. The difference is:
--- gw0

+++ gw1

@@ -1246,13 +1246,13 @@

 testing/tests/test_consistency_checker.py::test_container_in_state_but_no_container_in_meta
 testing/tests/test_consistency_checker.py::test_container_not_in_state
 testing/tests/test_consistency_checker.py::test_evt_bad_container_name
+testing/tests/test_consistency_checker.py::test_evt_bad_relation_name[_relation_joined]
 testing/tests/test_consistency_checker.py::test_evt_bad_relation_name[_relation_changed]
-testing/tests/test_consistency_checker.py::test_evt_bad_relation_name[_relation_joined]
 testing/tests/test_consistency_checker.py::test_evt_bad_relation_name[_relation_created]
 testing/tests/test_consistency_checker.py::test_evt_bad_relation_name[_relation_departed]
 testing/tests/test_consistency_checker.py::test_evt_bad_relation_name[_relation_broken]
+testing/tests/test_consistency_checker.py::test_evt_no_relation[_relation_joined]
 testing/tests/test_consistency_checker.py::test_evt_no_relation[_relation_changed]
-testing/tests/test_consistency_checker.py::test_evt_no_relation[_relation_joined]
 testing/tests/test_consistency_checker.py::test_evt_no_relation[_relation_created]
 testing/tests/test_consistency_checker.py::test_evt_no_relation[_relation_departed]
 testing/tests/test_consistency_checker.py::test_evt_no_relation[_relation_broken]
To see why this happens see Known limitations in documentation

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.

2 participants