fix(test) fixes flaky es-index/alias race#7209
Open
Brennan-Chesley-FLP wants to merge 3 commits intomainfrom
Open
fix(test) fixes flaky es-index/alias race#7209Brennan-Chesley-FLP wants to merge 3 commits intomainfrom
Brennan-Chesley-FLP wants to merge 3 commits intomainfrom
Conversation
Contributor
Author
|
The tracebacks for these errors looked approximately like this (the test could change depending on how the race played out): |
albertisfu
requested changes
Apr 10, 2026
Contributor
albertisfu
left a comment
There was a problem hiding this comment.
Thanks @Brennan-Chesley-FLP, this looks pretty good. It’ll solve this long-time annoying flaky test.
Just a small suggestion before we merge it.
Comment on lines
+156
to
+158
| models = model if isinstance(model, list) else [model] | ||
| model_classes = [apps.get_model(m) for m in models] | ||
| for index in registry.get_indices(models=model_classes): |
Contributor
There was a problem hiding this comment.
This 3 lines are common in the 3 methods. Can we move them to a helper method like:
def _get_indices(cls, model):
models = model if isinstance(model, list) else [model]
model_classes = [apps.get_model(m) for m in models]
return registry.get_indices(models=model_classes)
And then just call it like:
for index in cls._get_indices(model):
index.create(ignore=[400])
To prevent duplicated code.
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.
Fixes
This fixes a race condition related to get_alias() in the django-elasticsearch-dsl, where deleting an index while getting a list of aliases without supplying
ignore_unavailable=Truewill throw an error. This migrates setup/teardown for a set of tests that were relying on the search_index command provided by that library to not use the particular codepath throwing the error.Repro for the curious: