Skip to content

fix(tests): match timeout status code in event stream timeout test - #2255

Merged
lgecse merged 1 commit into
mainfrom
fix/events-timeout-assertion
Oct 1, 2026
Merged

lgecse merged 1 commit into
mainfrom
fix/events-timeout-assertion

Conversation

@tkircsi

@tkircsi tkircsi commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Problem

The Event Streaming E2E Tests → No events scenario → should timeout when no events occur spec fails intermittently in CI. Example: CI run 36840447776, where it was the only failing spec (106 passed, 1 failed, 1 skipped) and took the Test Client job down with it. The two other red E2E jobs in that run (Test Local Kind, Test Network) were collateral cancellations from merge-group fail-fast, not independent failures.

The spec asserted on error message substrings using case-sensitive matchers:

gomega.Expect(err).To(gomega.Or(
    gomega.Equal(context.DeadlineExceeded),
    gomega.MatchError(gomega.ContainSubstring("deadline")),
    gomega.MatchError(gomega.ContainSubstring("cancel")),
))

When the server tears the HTTP/2 stream down with RST_STREAM, the error reads:

failed to receive: rpc error: code = DeadlineExceeded desc = stream terminated by RST_STREAM with error code: CANCEL

That satisfies none of the three matchers — DeadlineExceeded and CANCEL do not contain the lowercase substrings, and Equal(context.DeadlineExceeded) fails because the value is a wrapped *status.Error rather than the bare sentinel. The deadline fired exactly as intended; only the assertion was wrong.

Why it's flaky rather than always failing

tryReceiveEvent races two select branches. If ctx.Done() wins, the caller gets the bare context.DeadlineExceeded and the spec passes. If the stream's ErrCh() wins, it gets a wrapped gRPC status whose description varies — the common phrasing desc = context deadline exceeded happens to contain lowercase "deadline", which is why this usually slips through.

Fix

Assert on the gRPC status code instead of the message text, covering both outcomes of the race:

gomega.Expect(err).To(gomega.Or(
    gomega.MatchError(context.DeadlineExceeded),
    gomega.MatchError(context.Canceled),
    gomega.WithTransform(status.Code, gomega.BeElementOf(codes.DeadlineExceeded, codes.Canceled)),
))

This is test-only; no production code paths change.

Testing

go vet ./e2e/client/ is clean and pre-commit hooks (golangci-lint) pass. The spec itself needs a running server, so it was not exercised locally against the RST_STREAM failure mode — CI is the real verification here.

Made with Cursor

@tkircsi
tkircsi requested a review from a team as a code owner October 1, 2026 10:20
@github-actions github-actions Bot added the size/XS Denotes a PR that changes 0-49 lines label Oct 1, 2026
The "should timeout when no events occur" spec asserted on error message
substrings ("deadline", "cancel") with case-sensitive matchers. When the
server tears the stream down with RST_STREAM, the error reads
"code = DeadlineExceeded desc = stream terminated by RST_STREAM with error
code: CANCEL", which matches none of them, so the spec failed even though
the deadline fired correctly.

tryReceiveEvent races ctx.Done() against the stream error channel, so the
error is either the bare context error or a wrapped gRPC status. Assert on
the status code instead of the message to cover both outcomes.

Co-authored-by: Cursor <[email protected]>
Signed-off-by: Tibor Kircsi <[email protected]>
@tkircsi
tkircsi force-pushed the fix/events-timeout-assertion branch from 0ac68b0 to 53b0f6e Compare October 1, 2026 10:20
@lgecse
lgecse enabled auto-merge October 1, 2026 10:23
@lgecse
lgecse disabled auto-merge October 1, 2026 10:23
@lgecse
lgecse enabled auto-merge October 1, 2026 10:23
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@lgecse
lgecse added this pull request to the merge queue Oct 1, 2026
Merged via the queue into main with commit 5f43ee2 Oct 1, 2026
34 checks passed
@lgecse
lgecse deleted the fix/events-timeout-assertion branch October 1, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Denotes a PR that changes 0-49 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants