test: resolve flaky TestGlobFiles by ignoring filesystem ordering#1849
Closed
maishivamhoo123 wants to merge 1 commit into
Closed
test: resolve flaky TestGlobFiles by ignoring filesystem ordering#1849maishivamhoo123 wants to merge 1 commit into
maishivamhoo123 wants to merge 1 commit into
Conversation
Signed-off-by: maishivamhoo123 <maishivamhoo@gmail.com>
cdesiniotis
reviewed
May 26, 2026
Contributor
cdesiniotis
left a comment
There was a problem hiding this comment.
Thanks for the contribution @maishivamhoo123. Can you update this so that the change is made to the right test method?
| root, _ := newRoot(containerRootDir) | ||
| got := root.hasPath(tc.path) | ||
| require.Equal(t, tc.expected, got) | ||
| require.ElementsMatch(t, tc.expected, got) |
Contributor
There was a problem hiding this comment.
@maishivamhoo123 did you mean to make this change in the TestGlobFiles method? Right now this is updating the TestHasPath method.
Contributor
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.
I looked into this, and the issue is a flaky test caused by filesystem ordering.
Operating systems and filesystems (like those typically used on Arch Linux) don't guarantee the order in which they return files when reading a directory. While the files are correctly found, TestGlobFiles uses require.Equal() at the end of the test, which strictly enforces the array index order, causing the mismatch.
To fix this without altering the actual tool's behavior, we just need to update the test assertion in cmd/nvidia-cdi-hook/cudacompat/container-root_test.go to ignore the order.
Changing require.Equal(t, tc.expected, got) to require.ElementsMatch(t, tc.expected, got) (or sorting got beforehand) resolves the flake.
I have a fix ready and will open a PR for this shortly!
Closes : #1847