Fix flaky test caused by detector name collision in parallel CI jobs#417
Merged
Conversation
timmarkhuff
commented
Mar 18, 2026
| return gl | ||
|
|
||
|
|
||
| @pytest.fixture(name="retry_detector_name") |
Contributor
Author
There was a problem hiding this comment.
I renamed this local fixture to avoid collision with the detector_name fixture I created in conftest.py.
…oundlight/python-sdk into tim/fix-flaky-detector-name-collision
timmarkhuff
commented
Mar 18, 2026
| ) | ||
| assert completed_process.returncode == 0 | ||
| det_id_on_create = re.search("id='([^']+)'", completed_process.stdout).group(1) | ||
| match = re.search("id='([^']+)'", completed_process.stdout) |
Contributor
Author
There was a problem hiding this comment.
The Callable type annotation we added to this function promoted it from "untyped" to "typed" in mypy's eyes. Since check_untyped_defs is not enabled in our mypy config, mypy was previously skipping this function body entirely. The re.search().group() pattern was always unsafe, just invisible to the linter. Extracting the match and asserting it's not None satisfies mypy and also gives a clearer test failure message if the regex ever doesn't match.
timmarkhuff
commented
Mar 18, 2026
| ) | ||
| assert completed_process.returncode == 0 | ||
| det_id_on_get = re.search("id='([^']+)'", completed_process.stdout).group(1) | ||
| match = re.search("id='([^']+)'", completed_process.stdout) |
Contributor
Author
There was a problem hiding this comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Test detector names were generated with
f"Test {datetime.utcnow()}", which has second-level precision and is evaluated at module import time. When parallel CI matrix jobs imported the same module within the same second, they produced identical detector names. This causedget_or_create_detectorcalls to fail with aunique_undeleted_name_per_setconstraint violation. Additionally, we have a lot of duplicated code for creating detector names, which could benefit from centralization.Fix
Added a
detector_namepytest fixture inconftest.pythat returns a callable which appends a random UUID suffix to the timestamp, guaranteeing uniqueness across parallel runs. Replaced all inline detector name formatting across the test suite with calls to this fixture.