Skip to content

test: use DefaultTimeout for waitForCounter in shadow policy tests - #48352

Merged
RyanTheOptimist merged 1 commit into
envoyproxy:mainfrom
asedeno:shadow-policy-tsan-fix
Oct 15, 2026
Merged

RyanTheOptimist merged 1 commit into
envoyproxy:mainfrom
asedeno:shadow-policy-tsan-fix

Conversation

@asedeno

@asedeno asedeno commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Two positive waitForCounter() assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and 1000ms). These overrode TestUtility::DefaultTimeout, which is scaled by TIMEOUT_FACTOR under sanitizers.

In BackedUpConnectionBeforeShadowBegins, it can take longer than 500ms under TSAN on a loaded machine to set up the upstream shadow connection and fill its write buffer past the high watermark. The test then fails with downstream_flow_control_paused_reading_total still at 0, even though it reaches 1 later in the same run (the final EXPECT_EQ on that counter still passes). The 1000ms wait on cluster.cluster_1.upstream_rq_rx_reset in

RequestMirrorPolicyWithShadowUpstreamReset has the same weakness. Drop the explicit timeouts so both waits use DefaultTimeout. This costs nothing on passing runs because waitForCounter() returns as soon as the counter matches. The 500ms negative wait on waitForEndStream() in BackedUpConnectionBeforeShadowBegins is intentional and left unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably under --config=tsan. With this change, 200 runs under TSAN passed with no flakes.

AI was used in debugging and authoring this PR.

Risk Level: Low
Testing: CI, local testing

Two positive `waitForCounter()` assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and
1000ms). These overrode `TestUtility::DefaultTimeout`, which is scaled
by `TIMEOUT_FACTOR` under sanitizers.

In BackedUpConnectionBeforeShadowBegins, it can take longer than 500ms
under TSAN on a loaded machine to set up the upstream shadow
connection and fill its write buffer past the high watermark. The test
then fails with `downstream_flow_control_paused_reading_total` still
at 0, even though it reaches 1 later in the same run (the final
`EXPECT_EQ` on that counter still passes). The 1000ms wait on
`cluster.cluster_1.upstream_rq_rx_reset` in

RequestMirrorPolicyWithShadowUpstreamReset has the same weakness.
Drop the explicit timeouts so both waits use `DefaultTimeout`. This
costs nothing on passing runs because `waitForCounter()` returns as
soon as the counter matches. The 500ms negative wait on
`waitForEndStream()` in BackedUpConnectionBeforeShadowBegins is
intentional and left unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably
under `--config=tsan`. With this change, 200 runs under TSAN passed
with no flakes.

AI was used in debugging and authoring this PR.

Signed-off-by: Alejandro R. Sedeño <[email protected]>
@asedeno asedeno changed the title test: use DefaultTimeout in BackedUpConnectionBeforeShadowBegins test: use DefaultTimeout for waitForCounter in shadow policy tests Oct 14, 2026
@RyanTheOptimist
RyanTheOptimist merged commit eeaf23f into envoyproxy:main Oct 15, 2026
27 checks passed
jwendell pushed a commit that referenced this pull request Nov 12, 2026
…48352)

Two positive `waitForCounter()` assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and
1000ms). These overrode `TestUtility::DefaultTimeout`, which is scaled
by `TIMEOUT_FACTOR` under sanitizers.

In `BackedUpConnectionBeforeShadowBegins`, it can take longer than 500ms
under TSAN on a loaded machine to set up the upstream shadow connection
and fill its write buffer past the high watermark. The test then fails
with `downstream_flow_control_paused_reading_total` still at 0, even
though it reaches 1 later in the same run (the final `EXPECT_EQ` on that
counter still passes). The 1000ms wait on
`cluster.cluster_1.upstream_rq_rx_reset` in

`RequestMirrorPolicyWithShadowUpstreamReset` has the same weakness. Drop
the explicit timeouts so both waits use `DefaultTimeout`. This costs
nothing on passing runs because `waitForCounter()` returns as soon as
the counter matches. The 500ms negative wait on `waitForEndStream()` in
`BackedUpConnectionBeforeShadowBegins` is intentional and left
unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably under
`--config=tsan`. With this change, 200 runs under TSAN passed with no
flakes.

AI was used in debugging and authoring this PR.

Risk Level: Low
Testing: CI, local testing

Signed-off-by: Alejandro R. Sedeño <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#48352)

Two positive `waitForCounter()` assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and
1000ms). These overrode `TestUtility::DefaultTimeout`, which is scaled
by `TIMEOUT_FACTOR` under sanitizers.

In `BackedUpConnectionBeforeShadowBegins`, it can take longer than 500ms
under TSAN on a loaded machine to set up the upstream shadow connection
and fill its write buffer past the high watermark. The test then fails
with `downstream_flow_control_paused_reading_total` still at 0, even
though it reaches 1 later in the same run (the final `EXPECT_EQ` on that
counter still passes). The 1000ms wait on
`cluster.cluster_1.upstream_rq_rx_reset` in

`RequestMirrorPolicyWithShadowUpstreamReset` has the same weakness. Drop
the explicit timeouts so both waits use `DefaultTimeout`. This costs
nothing on passing runs because `waitForCounter()` returns as soon as
the counter matches. The 500ms negative wait on `waitForEndStream()` in
`BackedUpConnectionBeforeShadowBegins` is intentional and left
unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably under
`--config=tsan`. With this change, 200 runs under TSAN passed with no
flakes.

AI was used in debugging and authoring this PR.

Risk Level: Low
Testing: CI, local testing

Signed-off-by: Alejandro R. Sedeño <[email protected]>
(cherry picked from commit eeaf23f)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#48352)

Two positive `waitForCounter()` assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and
1000ms). These overrode `TestUtility::DefaultTimeout`, which is scaled
by `TIMEOUT_FACTOR` under sanitizers.

In `BackedUpConnectionBeforeShadowBegins`, it can take longer than 500ms
under TSAN on a loaded machine to set up the upstream shadow connection
and fill its write buffer past the high watermark. The test then fails
with `downstream_flow_control_paused_reading_total` still at 0, even
though it reaches 1 later in the same run (the final `EXPECT_EQ` on that
counter still passes). The 1000ms wait on
`cluster.cluster_1.upstream_rq_rx_reset` in

`RequestMirrorPolicyWithShadowUpstreamReset` has the same weakness. Drop
the explicit timeouts so both waits use `DefaultTimeout`. This costs
nothing on passing runs because `waitForCounter()` returns as soon as
the counter matches. The 500ms negative wait on `waitForEndStream()` in
`BackedUpConnectionBeforeShadowBegins` is intentional and left
unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably under
`--config=tsan`. With this change, 200 runs under TSAN passed with no
flakes.

AI was used in debugging and authoring this PR.

Risk Level: Low
Testing: CI, local testing

Signed-off-by: Alejandro R. Sedeño <[email protected]>
(cherry picked from commit eeaf23f)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#48352)

Two positive `waitForCounter()` assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and
1000ms). These overrode `TestUtility::DefaultTimeout`, which is scaled
by `TIMEOUT_FACTOR` under sanitizers.

In `BackedUpConnectionBeforeShadowBegins`, it can take longer than 500ms
under TSAN on a loaded machine to set up the upstream shadow connection
and fill its write buffer past the high watermark. The test then fails
with `downstream_flow_control_paused_reading_total` still at 0, even
though it reaches 1 later in the same run (the final `EXPECT_EQ` on that
counter still passes). The 1000ms wait on
`cluster.cluster_1.upstream_rq_rx_reset` in

`RequestMirrorPolicyWithShadowUpstreamReset` has the same weakness. Drop
the explicit timeouts so both waits use `DefaultTimeout`. This costs
nothing on passing runs because `waitForCounter()` returns as soon as
the counter matches. The 500ms negative wait on `waitForEndStream()` in
`BackedUpConnectionBeforeShadowBegins` is intentional and left
unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably under
`--config=tsan`. With this change, 200 runs under TSAN passed with no
flakes.

AI was used in debugging and authoring this PR.

Risk Level: Low
Testing: CI, local testing

Signed-off-by: Alejandro R. Sedeño <[email protected]>
(cherry picked from commit eeaf23f)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#48352)

Two positive `waitForCounter()` assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and
1000ms). These overrode `TestUtility::DefaultTimeout`, which is scaled
by `TIMEOUT_FACTOR` under sanitizers.

In `BackedUpConnectionBeforeShadowBegins`, it can take longer than 500ms
under TSAN on a loaded machine to set up the upstream shadow connection
and fill its write buffer past the high watermark. The test then fails
with `downstream_flow_control_paused_reading_total` still at 0, even
though it reaches 1 later in the same run (the final `EXPECT_EQ` on that
counter still passes). The 1000ms wait on
`cluster.cluster_1.upstream_rq_rx_reset` in

`RequestMirrorPolicyWithShadowUpstreamReset` has the same weakness. Drop
the explicit timeouts so both waits use `DefaultTimeout`. This costs
nothing on passing runs because `waitForCounter()` returns as soon as
the counter matches. The 500ms negative wait on `waitForEndStream()` in
`BackedUpConnectionBeforeShadowBegins` is intentional and left
unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably under
`--config=tsan`. With this change, 200 runs under TSAN passed with no
flakes.

AI was used in debugging and authoring this PR.

Risk Level: Low
Testing: CI, local testing

Signed-off-by: Alejandro R. Sedeño <[email protected]>
(cherry picked from commit eeaf23f)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…nvoyproxy#48352)

Two positive `waitForCounter()` assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and
1000ms). These overrode `TestUtility::DefaultTimeout`, which is scaled
by `TIMEOUT_FACTOR` under sanitizers.

In `BackedUpConnectionBeforeShadowBegins`, it can take longer than 500ms
under TSAN on a loaded machine to set up the upstream shadow connection
and fill its write buffer past the high watermark. The test then fails
with `downstream_flow_control_paused_reading_total` still at 0, even
though it reaches 1 later in the same run (the final `EXPECT_EQ` on that
counter still passes). The 1000ms wait on
`cluster.cluster_1.upstream_rq_rx_reset` in

`RequestMirrorPolicyWithShadowUpstreamReset` has the same weakness. Drop
the explicit timeouts so both waits use `DefaultTimeout`. This costs
nothing on passing runs because `waitForCounter()` returns as soon as
the counter matches. The 500ms negative wait on `waitForEndStream()` in
`BackedUpConnectionBeforeShadowBegins` is intentional and left
unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably under
`--config=tsan`. With this change, 200 runs under TSAN passed with no
flakes.

AI was used in debugging and authoring this PR.

Risk Level: Low
Testing: CI, local testing

Signed-off-by: Alejandro R. Sedeño <[email protected]>
(cherry picked from commit eeaf23f)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…nvoyproxy#48352)

Two positive `waitForCounter()` assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and
1000ms). These overrode `TestUtility::DefaultTimeout`, which is scaled
by `TIMEOUT_FACTOR` under sanitizers.

In `BackedUpConnectionBeforeShadowBegins`, it can take longer than 500ms
under TSAN on a loaded machine to set up the upstream shadow connection
and fill its write buffer past the high watermark. The test then fails
with `downstream_flow_control_paused_reading_total` still at 0, even
though it reaches 1 later in the same run (the final `EXPECT_EQ` on that
counter still passes). The 1000ms wait on
`cluster.cluster_1.upstream_rq_rx_reset` in

`RequestMirrorPolicyWithShadowUpstreamReset` has the same weakness. Drop
the explicit timeouts so both waits use `DefaultTimeout`. This costs
nothing on passing runs because `waitForCounter()` returns as soon as
the counter matches. The 500ms negative wait on `waitForEndStream()` in
`BackedUpConnectionBeforeShadowBegins` is intentional and left
unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably under
`--config=tsan`. With this change, 200 runs under TSAN passed with no
flakes.

AI was used in debugging and authoring this PR.

Risk Level: Low
Testing: CI, local testing

Signed-off-by: Alejandro R. Sedeño <[email protected]>
(cherry picked from commit eeaf23f)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…nvoyproxy#48352)

Two positive `waitForCounter()` assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and
1000ms). These overrode `TestUtility::DefaultTimeout`, which is scaled
by `TIMEOUT_FACTOR` under sanitizers.

In `BackedUpConnectionBeforeShadowBegins`, it can take longer than 500ms
under TSAN on a loaded machine to set up the upstream shadow connection
and fill its write buffer past the high watermark. The test then fails
with `downstream_flow_control_paused_reading_total` still at 0, even
though it reaches 1 later in the same run (the final `EXPECT_EQ` on that
counter still passes). The 1000ms wait on
`cluster.cluster_1.upstream_rq_rx_reset` in

`RequestMirrorPolicyWithShadowUpstreamReset` has the same weakness. Drop
the explicit timeouts so both waits use `DefaultTimeout`. This costs
nothing on passing runs because `waitForCounter()` returns as soon as
the counter matches. The 500ms negative wait on `waitForEndStream()` in
`BackedUpConnectionBeforeShadowBegins` is intentional and left
unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably under
`--config=tsan`. With this change, 200 runs under TSAN passed with no
flakes.

AI was used in debugging and authoring this PR.

Risk Level: Low
Testing: CI, local testing

Signed-off-by: Alejandro R. Sedeño <[email protected]>
(cherry picked from commit eeaf23f)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…nvoyproxy#48352)

Two positive `waitForCounter()` assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and
1000ms). These overrode `TestUtility::DefaultTimeout`, which is scaled
by `TIMEOUT_FACTOR` under sanitizers.

In `BackedUpConnectionBeforeShadowBegins`, it can take longer than 500ms
under TSAN on a loaded machine to set up the upstream shadow connection
and fill its write buffer past the high watermark. The test then fails
with `downstream_flow_control_paused_reading_total` still at 0, even
though it reaches 1 later in the same run (the final `EXPECT_EQ` on that
counter still passes). The 1000ms wait on
`cluster.cluster_1.upstream_rq_rx_reset` in

`RequestMirrorPolicyWithShadowUpstreamReset` has the same weakness. Drop
the explicit timeouts so both waits use `DefaultTimeout`. This costs
nothing on passing runs because `waitForCounter()` returns as soon as
the counter matches. The 500ms negative wait on `waitForEndStream()` in
`BackedUpConnectionBeforeShadowBegins` is intentional and left
unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably under
`--config=tsan`. With this change, 200 runs under TSAN passed with no
flakes.

AI was used in debugging and authoring this PR.

Risk Level: Low
Testing: CI, local testing

Signed-off-by: Alejandro R. Sedeño <[email protected]>
(cherry picked from commit eeaf23f)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit that referenced this pull request Nov 17, 2026
…48352)

Two positive `waitForCounter()` assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and
1000ms). These overrode `TestUtility::DefaultTimeout`, which is scaled
by `TIMEOUT_FACTOR` under sanitizers.

In `BackedUpConnectionBeforeShadowBegins`, it can take longer than 500ms
under TSAN on a loaded machine to set up the upstream shadow connection
and fill its write buffer past the high watermark. The test then fails
with `downstream_flow_control_paused_reading_total` still at 0, even
though it reaches 1 later in the same run (the final `EXPECT_EQ` on that
counter still passes). The 1000ms wait on
`cluster.cluster_1.upstream_rq_rx_reset` in

`RequestMirrorPolicyWithShadowUpstreamReset` has the same weakness. Drop
the explicit timeouts so both waits use `DefaultTimeout`. This costs
nothing on passing runs because `waitForCounter()` returns as soon as
the counter matches. The 500ms negative wait on `waitForEndStream()` in
`BackedUpConnectionBeforeShadowBegins` is intentional and left
unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably under
`--config=tsan`. With this change, 200 runs under TSAN passed with no
flakes.

AI was used in debugging and authoring this PR.

Risk Level: Low
Testing: CI, local testing

Signed-off-by: Alejandro R. Sedeño <[email protected]>
(cherry picked from commit eeaf23f)
Signed-off-by: Ryan Northey <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 18, 2026
…nvoyproxy#48352)

Two positive `waitForCounter()` assertions in
shadow_policy_integration_test.cc used hardcoded timeouts (500ms and
1000ms). These overrode `TestUtility::DefaultTimeout`, which is scaled
by `TIMEOUT_FACTOR` under sanitizers.

In `BackedUpConnectionBeforeShadowBegins`, it can take longer than 500ms
under TSAN on a loaded machine to set up the upstream shadow connection
and fill its write buffer past the high watermark. The test then fails
with `downstream_flow_control_paused_reading_total` still at 0, even
though it reaches 1 later in the same run (the final `EXPECT_EQ` on that
counter still passes). The 1000ms wait on
`cluster.cluster_1.upstream_rq_rx_reset` in

`RequestMirrorPolicyWithShadowUpstreamReset` has the same weakness. Drop
the explicit timeouts so both waits use `DefaultTimeout`. This costs
nothing on passing runs because `waitForCounter()` returns as soon as
the counter matches. The 500ms negative wait on `waitForEndStream()` in
`BackedUpConnectionBeforeShadowBegins` is intentional and left
unchanged.

Lowering the 500ms timeout to 50ms reproduces the failure reliably under
`--config=tsan`. With this change, 200 runs under TSAN passed with no
flakes.

AI was used in debugging and authoring this PR.

Risk Level: Low
Testing: CI, local testing

Signed-off-by: Alejandro R. Sedeño <[email protected]>
(cherry picked from commit eeaf23f)
Signed-off-by: Ryan Northey <[email protected]>
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