Skip to content

Make integration test metric matchers more flexible - #44864

Merged
agrawroh merged 9 commits into
envoyproxy:mainfrom
ravenblackx:gauge_matchers
May 7, 2026
Merged

agrawroh merged 9 commits into
envoyproxy:mainfrom
ravenblackx:gauge_matchers

Conversation

@ravenblackx

@ravenblackx ravenblackx commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Commit Message: Make integration test metric matchers more flexible
Additional Description: The meat of the change of this PR is in five files: mobile/test/common/integration/base_client_integration_test.h (and .cc), test/test_common/utility.h (and .cc), and test/integration/server.h - everything else is pretty much mechanically just replacing waitForCounterGe(..., n[, ...]) with waitForCounter(..., Ge(n)[, ...]) or the equivalent for Eq and Gauge, and adding using testing::Ge; etc. when necessary.

To make the change self-documenting to minimize disruption to external extensions calling these functions, I've included static assertions on the old function names directing to the new methods.

While it was an option to add the new flexible matcher and just implement the existing ones in terms of the new one, that would leave the test code in a state where your classic "copy code from another example" will keep perpetuating use of the inflexible model, and creation of new, similar inflexible models. Fully migrating to the better test helpers gives better future code cleanliness and maintainability (at the cost of a horrible one-time review).

To be clear, the benefits of this change are:

  1. there's only two functions [in each place] instead of four.
  2. Those functions also enable waitForCounter(someCounter, Le(1000)) which otherwise would require a custom implementation in a test, or adding a new shared helper function.

Risk Level: Test-only.
Testing: Yes it is.
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #44864 was opened by ravenblackx.

see: more, trace.

@ravenblackx

ravenblackx commented May 6, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request
Edit: it did not, so I did it.

phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…9300)

The in-place LDS tests wait for
`listener_manager.total_filter_chains_draining` to reach 1 and then 0,
but the gauge only stays up for the 1s drain time. A test thread
descheduled for longer than that under tsan never sees it rise and burns
the whole wait. The next QUIC connection then times out its handshake
straight away, because `QuicConnection` starts its handshake clock from
the test dispatcher's cached time, which went stale during that wait.
The tests now wait for `listener_create_success` to count one creation
per worker per update, which the main thread only does after
`inPlaceFilterChainUpdate()` has already started the drain, and then for
the gauge to reach 0.

Additional Description:
This hit `EnableAndDisableResumption/IPv4` under tsan. It's the same
timeout as envoyproxy#31183 (`EnableAndDisableEarlyData`) and envoyproxy#33453
(`ReloadConfigUpdateDefaultFilterChain`), both closed as stale.
`listener_in_place_updated` alone isn't enough to wait on, since it's
bumped when the update is accepted, before the new listener warms.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test //test/integration:quic_http_integration_test
--test_filter='*QuicInplaceLdsIntegrationTest*' --runs_per_test=20`:
200/200 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>

Backport note (release/v1.38): the helper uses this branch's `waitForCounterGe()`
and `waitForGaugeEq()`, as it has no matcher overloads (envoyproxy#44864), and
`EnableAndDisableResumption` is not on this branch.

(cherry picked from commit 8937718)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#49303)

`testTranscoding()` closes the fake upstream connection after each
request and waits for the fake side to disconnect, but nothing waits for
Envoy to process that close. Tests that call it more than once can have
the next request handed to the dead pooled HTTP/2 connection, so the
fake upstream never sees a new connection and `waitForHttpConnection()`
times out. The helper now waits for
`cluster.cluster_0.upstream_cx_active` to drop to 0 after the close.

Additional Description:
This hit `ServerStreamingGet/IPv4`, which sends three requests. It's the
same failure as envoyproxy#44427 on `DisableRequestValidation`, which envoyproxy#44510
worked around by splitting that test into single-request tests. About 25
other tests in the file make several calls and pick this up too. The
calls that pass `expect_connection_to_upstream=false` are local replies,
so the wait returns immediately for them.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test
//test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test`
passes
- same target with
`--test_filter='IpVersions/GrpcJsonTranscoderIntegrationTest.ServerStreaming*'
--runs_per_test=50`: 400/400 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>
Backport note (release/v1.38): with this branch's `waitForGaugeEq()`, as it has
no `waitForGauge()` matcher overload (envoyproxy#44864).

(cherry picked from commit b794d7a)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…9300)

The in-place LDS tests wait for
`listener_manager.total_filter_chains_draining` to reach 1 and then 0,
but the gauge only stays up for the 1s drain time. A test thread
descheduled for longer than that under tsan never sees it rise and burns
the whole wait. The next QUIC connection then times out its handshake
straight away, because `QuicConnection` starts its handshake clock from
the test dispatcher's cached time, which went stale during that wait.
The tests now wait for `listener_create_success` to count one creation
per worker per update, which the main thread only does after
`inPlaceFilterChainUpdate()` has already started the drain, and then for
the gauge to reach 0.

Additional Description:
This hit `EnableAndDisableResumption/IPv4` under tsan. It's the same
timeout as envoyproxy#31183 (`EnableAndDisableEarlyData`) and envoyproxy#33453
(`ReloadConfigUpdateDefaultFilterChain`), both closed as stale.
`listener_in_place_updated` alone isn't enough to wait on, since it's
bumped when the update is accepted, before the new listener warms.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test //test/integration:quic_http_integration_test
--test_filter='*QuicInplaceLdsIntegrationTest*' --runs_per_test=20`:
200/200 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>

Backport note (release/v1.38): the helper uses this branch's `waitForCounterGe()`
and `waitForGaugeEq()`, as it has no matcher overloads (envoyproxy#44864), and
`EnableAndDisableResumption` is not on this branch.

(cherry picked from commit 8937718)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#49303)

`testTranscoding()` closes the fake upstream connection after each
request and waits for the fake side to disconnect, but nothing waits for
Envoy to process that close. Tests that call it more than once can have
the next request handed to the dead pooled HTTP/2 connection, so the
fake upstream never sees a new connection and `waitForHttpConnection()`
times out. The helper now waits for
`cluster.cluster_0.upstream_cx_active` to drop to 0 after the close.

Additional Description:
This hit `ServerStreamingGet/IPv4`, which sends three requests. It's the
same failure as envoyproxy#44427 on `DisableRequestValidation`, which envoyproxy#44510
worked around by splitting that test into single-request tests. About 25
other tests in the file make several calls and pick this up too. The
calls that pass `expect_connection_to_upstream=false` are local replies,
so the wait returns immediately for them.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test
//test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test`
passes
- same target with
`--test_filter='IpVersions/GrpcJsonTranscoderIntegrationTest.ServerStreaming*'
--runs_per_test=50`: 400/400 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>
Backport note (release/v1.38): with this branch's `waitForGaugeEq()`, as it has
no `waitForGauge()` matcher overload (envoyproxy#44864).

(cherry picked from commit b794d7a)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…9300)

The in-place LDS tests wait for
`listener_manager.total_filter_chains_draining` to reach 1 and then 0,
but the gauge only stays up for the 1s drain time. A test thread
descheduled for longer than that under tsan never sees it rise and burns
the whole wait. The next QUIC connection then times out its handshake
straight away, because `QuicConnection` starts its handshake clock from
the test dispatcher's cached time, which went stale during that wait.
The tests now wait for `listener_create_success` to count one creation
per worker per update, which the main thread only does after
`inPlaceFilterChainUpdate()` has already started the drain, and then for
the gauge to reach 0.

Additional Description:
This hit `EnableAndDisableResumption/IPv4` under tsan. It's the same
timeout as envoyproxy#31183 (`EnableAndDisableEarlyData`) and envoyproxy#33453
(`ReloadConfigUpdateDefaultFilterChain`), both closed as stale.
`listener_in_place_updated` alone isn't enough to wait on, since it's
bumped when the update is accepted, before the new listener warms.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test //test/integration:quic_http_integration_test
--test_filter='*QuicInplaceLdsIntegrationTest*' --runs_per_test=20`:
200/200 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>

Backport note (release/v1.38): the helper uses this branch's `waitForCounterGe()`
and `waitForGaugeEq()`, as it has no matcher overloads (envoyproxy#44864), and
`EnableAndDisableResumption` is not on this branch.

(cherry picked from commit 8937718)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#49303)

`testTranscoding()` closes the fake upstream connection after each
request and waits for the fake side to disconnect, but nothing waits for
Envoy to process that close. Tests that call it more than once can have
the next request handed to the dead pooled HTTP/2 connection, so the
fake upstream never sees a new connection and `waitForHttpConnection()`
times out. The helper now waits for
`cluster.cluster_0.upstream_cx_active` to drop to 0 after the close.

Additional Description:
This hit `ServerStreamingGet/IPv4`, which sends three requests. It's the
same failure as envoyproxy#44427 on `DisableRequestValidation`, which envoyproxy#44510
worked around by splitting that test into single-request tests. About 25
other tests in the file make several calls and pick this up too. The
calls that pass `expect_connection_to_upstream=false` are local replies,
so the wait returns immediately for them.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test
//test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test`
passes
- same target with
`--test_filter='IpVersions/GrpcJsonTranscoderIntegrationTest.ServerStreaming*'
--runs_per_test=50`: 400/400 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>
Backport note (release/v1.38): with this branch's `waitForGaugeEq()`, as it has
no `waitForGauge()` matcher overload (envoyproxy#44864).

(cherry picked from commit b794d7a)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…9300)

The in-place LDS tests wait for
`listener_manager.total_filter_chains_draining` to reach 1 and then 0,
but the gauge only stays up for the 1s drain time. A test thread
descheduled for longer than that under tsan never sees it rise and burns
the whole wait. The next QUIC connection then times out its handshake
straight away, because `QuicConnection` starts its handshake clock from
the test dispatcher's cached time, which went stale during that wait.
The tests now wait for `listener_create_success` to count one creation
per worker per update, which the main thread only does after
`inPlaceFilterChainUpdate()` has already started the drain, and then for
the gauge to reach 0.

Additional Description:
This hit `EnableAndDisableResumption/IPv4` under tsan. It's the same
timeout as envoyproxy#31183 (`EnableAndDisableEarlyData`) and envoyproxy#33453
(`ReloadConfigUpdateDefaultFilterChain`), both closed as stale.
`listener_in_place_updated` alone isn't enough to wait on, since it's
bumped when the update is accepted, before the new listener warms.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test //test/integration:quic_http_integration_test
--test_filter='*QuicInplaceLdsIntegrationTest*' --runs_per_test=20`:
200/200 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>

Backport note (release/v1.38): the helper uses this branch's `waitForCounterGe()`
and `waitForGaugeEq()`, as it has no matcher overloads (envoyproxy#44864), and
`EnableAndDisableResumption` is not on this branch.

(cherry picked from commit 8937718)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…nvoyproxy#49303)

`testTranscoding()` closes the fake upstream connection after each
request and waits for the fake side to disconnect, but nothing waits for
Envoy to process that close. Tests that call it more than once can have
the next request handed to the dead pooled HTTP/2 connection, so the
fake upstream never sees a new connection and `waitForHttpConnection()`
times out. The helper now waits for
`cluster.cluster_0.upstream_cx_active` to drop to 0 after the close.

Additional Description:
This hit `ServerStreamingGet/IPv4`, which sends three requests. It's the
same failure as envoyproxy#44427 on `DisableRequestValidation`, which envoyproxy#44510
worked around by splitting that test into single-request tests. About 25
other tests in the file make several calls and pick this up too. The
calls that pass `expect_connection_to_upstream=false` are local replies,
so the wait returns immediately for them.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test
//test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test`
passes
- same target with
`--test_filter='IpVersions/GrpcJsonTranscoderIntegrationTest.ServerStreaming*'
--runs_per_test=50`: 400/400 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>
Backport note (release/v1.38): with this branch's `waitForGaugeEq()`, as it has
no `waitForGauge()` matcher overload (envoyproxy#44864).

(cherry picked from commit b794d7a)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…9300)

The in-place LDS tests wait for
`listener_manager.total_filter_chains_draining` to reach 1 and then 0,
but the gauge only stays up for the 1s drain time. A test thread
descheduled for longer than that under tsan never sees it rise and burns
the whole wait. The next QUIC connection then times out its handshake
straight away, because `QuicConnection` starts its handshake clock from
the test dispatcher's cached time, which went stale during that wait.
The tests now wait for `listener_create_success` to count one creation
per worker per update, which the main thread only does after
`inPlaceFilterChainUpdate()` has already started the drain, and then for
the gauge to reach 0.

Additional Description:
This hit `EnableAndDisableResumption/IPv4` under tsan. It's the same
timeout as envoyproxy#31183 (`EnableAndDisableEarlyData`) and envoyproxy#33453
(`ReloadConfigUpdateDefaultFilterChain`), both closed as stale.
`listener_in_place_updated` alone isn't enough to wait on, since it's
bumped when the update is accepted, before the new listener warms.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test //test/integration:quic_http_integration_test
--test_filter='*QuicInplaceLdsIntegrationTest*' --runs_per_test=20`:
200/200 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>

Backport note (release/v1.38): the helper uses this branch's `waitForCounterGe()`
and `waitForGaugeEq()`, as it has no matcher overloads (envoyproxy#44864), and
`EnableAndDisableResumption` is not on this branch.

(cherry picked from commit 8937718)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…nvoyproxy#49303)

`testTranscoding()` closes the fake upstream connection after each
request and waits for the fake side to disconnect, but nothing waits for
Envoy to process that close. Tests that call it more than once can have
the next request handed to the dead pooled HTTP/2 connection, so the
fake upstream never sees a new connection and `waitForHttpConnection()`
times out. The helper now waits for
`cluster.cluster_0.upstream_cx_active` to drop to 0 after the close.

Additional Description:
This hit `ServerStreamingGet/IPv4`, which sends three requests. It's the
same failure as envoyproxy#44427 on `DisableRequestValidation`, which envoyproxy#44510
worked around by splitting that test into single-request tests. About 25
other tests in the file make several calls and pick this up too. The
calls that pass `expect_connection_to_upstream=false` are local replies,
so the wait returns immediately for them.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test
//test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test`
passes
- same target with
`--test_filter='IpVersions/GrpcJsonTranscoderIntegrationTest.ServerStreaming*'
--runs_per_test=50`: 400/400 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>
Backport note (release/v1.38): with this branch's `waitForGaugeEq()`, as it has
no `waitForGauge()` matcher overload (envoyproxy#44864).

(cherry picked from commit b794d7a)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…9300)

The in-place LDS tests wait for
`listener_manager.total_filter_chains_draining` to reach 1 and then 0,
but the gauge only stays up for the 1s drain time. A test thread
descheduled for longer than that under tsan never sees it rise and burns
the whole wait. The next QUIC connection then times out its handshake
straight away, because `QuicConnection` starts its handshake clock from
the test dispatcher's cached time, which went stale during that wait.
The tests now wait for `listener_create_success` to count one creation
per worker per update, which the main thread only does after
`inPlaceFilterChainUpdate()` has already started the drain, and then for
the gauge to reach 0.

Additional Description:
This hit `EnableAndDisableResumption/IPv4` under tsan. It's the same
timeout as envoyproxy#31183 (`EnableAndDisableEarlyData`) and envoyproxy#33453
(`ReloadConfigUpdateDefaultFilterChain`), both closed as stale.
`listener_in_place_updated` alone isn't enough to wait on, since it's
bumped when the update is accepted, before the new listener warms.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test //test/integration:quic_http_integration_test
--test_filter='*QuicInplaceLdsIntegrationTest*' --runs_per_test=20`:
200/200 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>

Backport note (release/v1.38): the helper uses this branch's `waitForCounterGe()`
and `waitForGaugeEq()`, as it has no matcher overloads (envoyproxy#44864), and
`EnableAndDisableResumption` is not on this branch.

(cherry picked from commit 8937718)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…nvoyproxy#49303)

`testTranscoding()` closes the fake upstream connection after each
request and waits for the fake side to disconnect, but nothing waits for
Envoy to process that close. Tests that call it more than once can have
the next request handed to the dead pooled HTTP/2 connection, so the
fake upstream never sees a new connection and `waitForHttpConnection()`
times out. The helper now waits for
`cluster.cluster_0.upstream_cx_active` to drop to 0 after the close.

Additional Description:
This hit `ServerStreamingGet/IPv4`, which sends three requests. It's the
same failure as envoyproxy#44427 on `DisableRequestValidation`, which envoyproxy#44510
worked around by splitting that test into single-request tests. About 25
other tests in the file make several calls and pick this up too. The
calls that pass `expect_connection_to_upstream=false` are local replies,
so the wait returns immediately for them.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test
//test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test`
passes
- same target with
`--test_filter='IpVersions/GrpcJsonTranscoderIntegrationTest.ServerStreaming*'
--runs_per_test=50`: 400/400 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>
Backport note (release/v1.38): with this branch's `waitForGaugeEq()`, as it has
no `waitForGauge()` matcher overload (envoyproxy#44864).

(cherry picked from commit b794d7a)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…9300)

The in-place LDS tests wait for
`listener_manager.total_filter_chains_draining` to reach 1 and then 0,
but the gauge only stays up for the 1s drain time. A test thread
descheduled for longer than that under tsan never sees it rise and burns
the whole wait. The next QUIC connection then times out its handshake
straight away, because `QuicConnection` starts its handshake clock from
the test dispatcher's cached time, which went stale during that wait.
The tests now wait for `listener_create_success` to count one creation
per worker per update, which the main thread only does after
`inPlaceFilterChainUpdate()` has already started the drain, and then for
the gauge to reach 0.

Additional Description:
This hit `EnableAndDisableResumption/IPv4` under tsan. It's the same
timeout as envoyproxy#31183 (`EnableAndDisableEarlyData`) and envoyproxy#33453
(`ReloadConfigUpdateDefaultFilterChain`), both closed as stale.
`listener_in_place_updated` alone isn't enough to wait on, since it's
bumped when the update is accepted, before the new listener warms.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test //test/integration:quic_http_integration_test
--test_filter='*QuicInplaceLdsIntegrationTest*' --runs_per_test=20`:
200/200 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>

Backport note (release/v1.38): the helper uses this branch's `waitForCounterGe()`
and `waitForGaugeEq()`, as it has no matcher overloads (envoyproxy#44864), and
`EnableAndDisableResumption` is not on this branch.

(cherry picked from commit 8937718)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…nvoyproxy#49303)

`testTranscoding()` closes the fake upstream connection after each
request and waits for the fake side to disconnect, but nothing waits for
Envoy to process that close. Tests that call it more than once can have
the next request handed to the dead pooled HTTP/2 connection, so the
fake upstream never sees a new connection and `waitForHttpConnection()`
times out. The helper now waits for
`cluster.cluster_0.upstream_cx_active` to drop to 0 after the close.

Additional Description:
This hit `ServerStreamingGet/IPv4`, which sends three requests. It's the
same failure as envoyproxy#44427 on `DisableRequestValidation`, which envoyproxy#44510
worked around by splitting that test into single-request tests. About 25
other tests in the file make several calls and pick this up too. The
calls that pass `expect_connection_to_upstream=false` are local replies,
so the wait returns immediately for them.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test
//test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test`
passes
- same target with
`--test_filter='IpVersions/GrpcJsonTranscoderIntegrationTest.ServerStreaming*'
--runs_per_test=50`: 400/400 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>
Backport note (release/v1.38): with this branch's `waitForGaugeEq()`, as it has
no `waitForGauge()` matcher overload (envoyproxy#44864).

(cherry picked from commit b794d7a)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…9300)

The in-place LDS tests wait for
`listener_manager.total_filter_chains_draining` to reach 1 and then 0,
but the gauge only stays up for the 1s drain time. A test thread
descheduled for longer than that under tsan never sees it rise and burns
the whole wait. The next QUIC connection then times out its handshake
straight away, because `QuicConnection` starts its handshake clock from
the test dispatcher's cached time, which went stale during that wait.
The tests now wait for `listener_create_success` to count one creation
per worker per update, which the main thread only does after
`inPlaceFilterChainUpdate()` has already started the drain, and then for
the gauge to reach 0.

Additional Description:
This hit `EnableAndDisableResumption/IPv4` under tsan. It's the same
timeout as envoyproxy#31183 (`EnableAndDisableEarlyData`) and envoyproxy#33453
(`ReloadConfigUpdateDefaultFilterChain`), both closed as stale.
`listener_in_place_updated` alone isn't enough to wait on, since it's
bumped when the update is accepted, before the new listener warms.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test //test/integration:quic_http_integration_test
--test_filter='*QuicInplaceLdsIntegrationTest*' --runs_per_test=20`:
200/200 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>

Backport note (release/v1.38): the helper uses this branch's `waitForCounterGe()`
and `waitForGaugeEq()`, as it has no matcher overloads (envoyproxy#44864), and
`EnableAndDisableResumption` is not on this branch.

(cherry picked from commit 8937718)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 18, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 18, 2026
…nvoyproxy#49303)

`testTranscoding()` closes the fake upstream connection after each
request and waits for the fake side to disconnect, but nothing waits for
Envoy to process that close. Tests that call it more than once can have
the next request handed to the dead pooled HTTP/2 connection, so the
fake upstream never sees a new connection and `waitForHttpConnection()`
times out. The helper now waits for
`cluster.cluster_0.upstream_cx_active` to drop to 0 after the close.

Additional Description:
This hit `ServerStreamingGet/IPv4`, which sends three requests. It's the
same failure as envoyproxy#44427 on `DisableRequestValidation`, which envoyproxy#44510
worked around by splitting that test into single-request tests. About 25
other tests in the file make several calls and pick this up too. The
calls that pass `expect_connection_to_upstream=false` are local replies,
so the wait returns immediately for them.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test
//test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test`
passes
- same target with
`--test_filter='IpVersions/GrpcJsonTranscoderIntegrationTest.ServerStreaming*'
--runs_per_test=50`: 400/400 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>
Backport note (release/v1.38): with this branch's `waitForGaugeEq()`, as it has
no `waitForGauge()` matcher overload (envoyproxy#44864).

(cherry picked from commit b794d7a)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 18, 2026
…9300)

The in-place LDS tests wait for
`listener_manager.total_filter_chains_draining` to reach 1 and then 0,
but the gauge only stays up for the 1s drain time. A test thread
descheduled for longer than that under tsan never sees it rise and burns
the whole wait. The next QUIC connection then times out its handshake
straight away, because `QuicConnection` starts its handshake clock from
the test dispatcher's cached time, which went stale during that wait.
The tests now wait for `listener_create_success` to count one creation
per worker per update, which the main thread only does after
`inPlaceFilterChainUpdate()` has already started the drain, and then for
the gauge to reach 0.

Additional Description:
This hit `EnableAndDisableResumption/IPv4` under tsan. It's the same
timeout as envoyproxy#31183 (`EnableAndDisableEarlyData`) and envoyproxy#33453
(`ReloadConfigUpdateDefaultFilterChain`), both closed as stale.
`listener_in_place_updated` alone isn't enough to wait on, since it's
bumped when the update is accepted, before the new listener warms.

AI Disclosure: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- `bazel test //test/integration:quic_http_integration_test
--test_filter='*QuicInplaceLdsIntegrationTest*' --runs_per_test=20`:
200/200 pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>

Backport note (release/v1.38): the helper uses this branch's `waitForCounterGe()`
and `waitForGaugeEq()`, as it has no matcher overloads (envoyproxy#44864), and
`EnableAndDisableResumption` is not on this branch.

(cherry picked from commit 8937718)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 25, 2026
…ses (envoyproxy#45817)

Fix race condition where xDS updates were sent before Envoy actually
started an HTTP stream.

Risk Level: low
Testing: unit test
Docs Changes: no
Release Notes: no
Platform Specific Features: no

Backport note: uses `waitForCounterGe()`, as the counter matcher form
(envoyproxy#44864) is not on this branch.

Signed-off-by: Yan Avlasov <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit c8408f8)
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 25, 2026
…ses (envoyproxy#45817)

Fix race condition where xDS updates were sent before Envoy actually
started an HTTP stream.

Risk Level: low
Testing: unit test
Docs Changes: no
Release Notes: no
Platform Specific Features: no

Backport note: uses `waitForCounterGe()`, as the counter matcher form
(envoyproxy#44864) is not on this branch.

Signed-off-by: Yan Avlasov <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit c8408f8)
This was referenced Nov 25, 2026
phlax pushed a commit that referenced this pull request Nov 25, 2026
…ses (#45817)

Fix race condition where xDS updates were sent before Envoy actually
started an HTTP stream.

Risk Level: low
Testing: unit test
Docs Changes: no
Release Notes: no
Platform Specific Features: no

Backport note: uses `waitForCounterGe()`, as the counter matcher form
(#44864) is not on this branch.

Signed-off-by: Yan Avlasov <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit c8408f8)
phlax pushed a commit that referenced this pull request Nov 25, 2026
…ses (#45817)

Fix race condition where xDS updates were sent before Envoy actually
started an HTTP stream.

Risk Level: low
Testing: unit test
Docs Changes: no
Release Notes: no
Platform Specific Features: no

Backport note: uses `waitForCounterGe()`, as the counter matcher form
(#44864) is not on this branch.

Signed-off-by: Yan Avlasov <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit c8408f8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants