Integration test deflake attempt - #47096
Conversation
Signed-off-by: Raven Black <ravenblack@dropbox.com>
phlax
left a comment
There was a problem hiding this comment.
bot review ...
test/integration/http_integration.cc (~L515-520): the ordering guarantee is conditional on envoy.reloadable_features.connection_close_through_filter_manager. When that feature is enabled and the filter manager has pending data, filter_manager_.onConnectionClose(close_action) (connection_impl.cc L343) defers the close instead of reaching closeSocket() synchronously. Callbacks then fire in a later dispatcher iteration — but since Envoy only writes its own FIN via closeSocket(), the test's waitForDisconnect() still can't complete before the callback, so the fix remains correct; a comment noting this dependency would help future readers.
test/integration/fake_upstream.cc (~L502-518): halfCloseAndWaitForDisconnect relies on Envoy responding to the FIN with a full close. That's guaranteed only because upstream connections have enable_half_close_ false (connection_impl.cc L824-827 translates EOF into PostIoAction::Close). Any test enabling upstream half-close (e.g. tcp_proxy with idle_timeout/half-close support) would hang here — worth a comment or a guard.
Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
|
/retest |
Signed-off-by: Raven Black <ravenblack@dropbox.com>
|
/retest |
|
/retest |
Signed-off-by: Raven Black <ravenblack@dropbox.com>
|
/retest |
|
/retest #47167 attempts to deflake the unrelated flake that keeps failing here. |
|
/retest |
Commit Message: Integration test deflake attempt
Additional Description: The specific integration test this is targeting was
test/extensions/filters/http/on_demand:on_demand_integration_test, which is flaky about 1/1000. An example failure can be seen here or here.The theory of this fix is from a deep AI inspection using GPT Sol. I understand what the change is doing and have reviewed it, but I wouldn't bet heavily on it actually fixing the problem.
The explanation is,
cleanupUpstreamAndDownstream()previously waited only for the fake upstream’s local socket close. This did not guarantee that Envoy’s worker had received the FIN and removed the connection from its HTTP connection pool. A subsequent request could therefore briefly reuse the closed connection instead of creating a new one, causing waitForNextUpstreamConnection() to time out as the request never provokes a new connection.For TCP upstreams, this cleanup now half-closes the fake upstream and waits for Envoy to close the reverse direction, thereby proving Envoy observed the shutdown so it's really cleaned up. It then runs a worker-thread barrier that effectively drains the events in the dispatchers, to ensure Envoy’s connection-close callbacks have removed the old pool client, before cleanup returns.
HTTP/3 still retains the previous behavior because QUIC does not support half-close, so the same race-flake might still be available if any test uses HTTP/3 upstreams with a similar sequence of events.
For some cases where half-close isn't supported, the worker-barrier is still included, which may suffice to make even those cases less flaky, given that the flakiness this targets was already around a 1/1000 case.
Risk Level: Test-only.
Testing: Yes it is.
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a