Skip to content

test/wasm: Deflake the buffered body integration tests - #49218

Closed
phlax wants to merge 1 commit into
envoyproxy:mainfrom
phlax:test-wasm-filter-body-deflake
Closed

phlax wants to merge 1 commit into
envoyproxy:mainfrom
phlax:test-wasm-filter-body-deflake

Conversation

@phlax

@phlax phlax commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

wasm_filter_integration_test sent the request body straight after the headers. Until the upstream connection is ready the upstream codec filter holds the headers, and when it resumes it is given whatever body an earlier filter has buffered so far (the buffer is shared by the filter chain, see #48660). When that happened between two chunks of the body, the upstream wasm filter that was buffering it no longer owned the buffered data and failed ASSERT(parent_.state_.latest_data_decoding_filter_ == this) on the next chunk.

Send the body once the request headers have reached the upstream, so that the codec filter is not waiting on the connection while the body arrives.

Seen in postsubmit CI on main (cto.noadmin, BodyBufferedMultipleChunksManipulation/upstream_v8_cpp_http1, aborted on the assert).

Testing: *BodyBufferedMultipleChunksManipulation/upstream* with --config=compile-time-options -c fastbuild --define admin_functionality=disabled on RBE, 2000 runs each:

failed
main (1ad62cc) 40
this change 0

All of the failures on main were the assert, with both HTTP/1 and HTTP/2 upstreams.

Risk Level: low (test only)

…ases

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Signed-off-by: Ryan Northey <[email protected]>
@phlax
phlax requested a review from kyessenov as a code owner November 13, 2026 00:09
@phlax phlax changed the title test/wasm: Deflake the wasm filter integration test's buffered body c… [WIP] test/wasm: Deflake the wasm filter integration test's buffered body c… Nov 13, 2026
@phlax
phlax requested a balanced review from Copilot November 13, 2026 00:09
@phlax
phlax marked this pull request as draft November 13, 2026 00:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the request-body ordering change.

No open issues 🎉

What changed in this PR

This PR reduces flakiness in the Wasm filter integration tests by delaying request-body transmission until the upstream stream is established, avoiding the shared-buffer timing issue described in #48660.

Changes:

  • Send body chunks after the upstream connection and request stream are available.
  • Add a comment explaining the buffering assertion this ordering avoids.
File Description
test/​extensions/​filters/​http/​wasm/​wasm_filter_integration_test.cc Reorders request-body transmission and documents the timing dependency.

Review effort: Balanced

@phlax phlax changed the title [WIP] test/wasm: Deflake the wasm filter integration test's buffered body c… [WIP] test/wasm: Deflake the buffered body integration tests Nov 13, 2026
@phlax phlax changed the title [WIP] test/wasm: Deflake the buffered body integration tests test/wasm: Deflake the buffered body integration tests Nov 13, 2026
@phlax
phlax marked this pull request as ready for review November 13, 2026 00:26
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
)

`wasm_filter_integration_test` sent the request body straight after the
headers. Until the upstream connection is ready the upstream codec
filter holds the headers, and when it resumes it is given whatever body
an earlier filter has buffered so far (the buffer is shared by the
filter chain, see envoyproxy#48660). When that happened between two chunks of the
body, the upstream wasm filter that was buffering it no longer owned the
buffered data and failed
`ASSERT(parent_.state_.latest_data_decoding_filter_ == this)` on the
next chunk.

Send the body once the request headers have reached the upstream, so
that the codec filter is not waiting on the connection while the body
arrives.

Backport note: picked from the pull request ahead of its merge to main.

Signed-off-by: Ryan Northey <[email protected]>
@phlax phlax added the backport/review Request to backport to stable releases label Nov 13, 2026
@ravenblackx

Copy link
Copy Markdown
Contributor

This makes me uncomfortable because the description sounds like a race that could potentially go that way in production too, so having the test just avoid the race, when the race causes undesirable behavior, seems like it might be papering over a real issue.

If it is a thing that can only happen because we're faking it in a test, then (given it's an integration test) the integration test framework should be fixed so it doesn't do something that won't happen in production, rather than just having this one test not do it.

@phlax

phlax commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Agreed, it looks like the real race rather than a test artefact: the shared per-stream buffer that #48660 replaces with per-filter buffers. Running the same deflake (*BodyBufferedMultipleChunksManipulation/upstream*, --config=compile-time-options -c fastbuild --define admin_functionality=disabled, 2000 runs) against #48660 now; if that comes back clean this PR should be closed in favour of it.

@phlax

phlax commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Against #48660 (merge f4e3eef into main 8ce942c): 2000 runs of *BodyBufferedMultipleChunksManipulation/upstream* with --config=compile-time-options -c fastbuild --define admin_functionality=disabled, all pass. Main had 40 failures in 2000 with the same setup, all on that assert. So #48660 fixes the underlying race, and this PR should be closed in favour of it.

@phlax phlax closed this Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/review Request to backport to stable releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants