Fix flaky server access log test by matching entries instead of exact count#6211
Open
delthas wants to merge 2 commits into
Open
Fix flaky server access log test by matching entries instead of exact count#6211delthas wants to merge 2 commits into
delthas wants to merge 2 commits into
Conversation
Contributor
Hello delthas,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Contributor
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
|
❌ 1 Tests Failed:
View the full list of 1 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
Pure formatting pass with no behavior change, isolated into its own commit so the functional change that follows has a clean, reviewable diff. The file predated prettier adoption and had never been reformatted. Issue: CLDSRV-923 Claude-Session: https://claude.ai/code/session_01QtnfMnRoAwPDEAdqnzPzjj
2010786 to
3ae0c44
Compare
The serverAccessLogs tests asserted an exact entry count per operation while isolating tests by truncating the shared access-log file. That file is shared by the whole server process, and a request's line is written on the response 'close' event, which under HTTP keep-alive can fire much later, on socket teardown. A request from another suite (captured in CI: GetObject on buckettestgetobject, from test/object/get.js) can therefore have its line written during a serverAccessLogs test, landing inside the truncate window and inflating the count by one. The failing operation varied run to run because the victim was whichever test the foreign write happened to land in. Match each expected entry against the collected entries by its fields and ignore anything else, instead of asserting logEntries.length === totalExpected. Unordered groups are flattened and matched independently, so interleaved foreign entries are tolerated regardless of when they arrive. Issue: CLDSRV-923 Claude-Session: https://claude.ai/code/session_01QtnfMnRoAwPDEAdqnzPzjj
3ae0c44 to
03b105d
Compare
tcarmet
approved these changes
Jul 1, 2026
tcarmet
left a comment
Contributor
There was a problem hiding this comment.
Thanks for having a look at it, much appreciated.
Comment on lines
+48
to
+51
| const lines = content | ||
| .trim() | ||
| .split('\n') | ||
| .filter(line => line.length > 0); |
Contributor
There was a problem hiding this comment.
I'll leave up to you to review if you think a little helper for those line would be useful since I see the same pattern below.
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.
Symptom
testServerAccessLogFile.jsflakes withAssertionError: Expected N log entries, got N+1infile-ft-tests/file-ft-tests-null-compat, on a different operation each run.Root cause (captured in CI)
The tests asserted an exact access-log entry count per operation and isolated tests by truncating the shared access-log file. Instrumenting the assertion to dump the collected entries caught the extra one red-handed, in two independent failures:
The extra entry is a
GetObjectonbuckettestgetobject— a bucket owned bytest/object/get.js, a different suite. It has a uniquereq_id(so it is not an SDK-retry duplicate, contrary to the ticket's original hypothesis) and a foreign bucket/key.Access-log lines are written on the server's
res.on('close'), which under HTTP keep-alive can fire long after the response (on socket teardown). A request from another suite can therefore have its line written during a serverAccessLogs test, landing inside the truncate window. This is outside the test's control, so no count-based barrier in the test can fix it.Fix
Stop asserting an exact count. Match each expected entry against the collected entries by its fields (the same field semantics as
validateLogEntry) and ignore anything else. Unordered groups are flattened and matched independently, so interleaved foreign entries are tolerated regardless of when they arrive.The first commit is an isolated prettier pass on the file (it predated prettier adoption); the second is the functional change.
Issue: CLDSRV-923