Repository navigation
test: ⚡✅ Wait on events in forward proxy tests - #1984
Conversation
Signed-off-by: Evaline Ju <69598118+evaline-ju@users.noreply.github.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Test-only change apart from one behaviour-preserving seam in transparent.go (tunnel → tunnelTicked(..., newDrainTicker), same time.Ticker at the same halfCloseDrainVar/4 interval). I compared every removed assertion against its replacement and none were weakened; several are stronger (1h-ttl hop joins asserting nothing is left pending, waiting for the no-request connection to close instead of sleeping 50ms, ordering checks instead of a drip/2 bound, exact-length io.ReadFull reads). Every new wait registers its signal before checking its condition, so none can miss an event that fired first.
Stress on head (forwardproxy package): -count=20 and -race -count=20 both pass with 0 failures and 0 data races. One package run takes ~12s on head vs ~38s on base.
Advisory nits: the commit subject has no conventional prefix (test: is only in the PR title), and the PR body has a truncated sentence ("so tick.").
Author: evaline-ju (CONTRIBUTOR — repo admin permission; approved after manual confirmation)
Areas reviewed: Go tests, forward proxy listener
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, signed-off: yes
CI status: passing
|
|
||
| // eventually blocks until cond holds, checking it again after each change to store. what | ||
| // names the awaited state, for the reader. | ||
| func eventually(t *testing.T, store *session.Store, cond func() bool, what string) { |
There was a problem hiding this comment.
suggestion: what is no longer used, and with every timeout removed a regression now hangs until go test's 10-minute timeout panic. That uses 10 of the core CI job's 15 minutes and stops the rest of the package from running. Consider failing with what shortly before t.Deadline() (when set), e.g. t.Fatalf("timed out waiting for %s", what). Also worth documenting that cond is only re-checked when the store records something, so it must only depend on state that is set before a store write.
There was a problem hiding this comment.
Clarified the doc comment: cond is checked again after each store write, and
what names the awaited state. I'd rather not add a deadline-derived timer.
t.Deadline() is the deadline for the whole binary, so failing just before it
saves no CI time compared with go test's own timeout. It only changes the
message, and the timeout's goroutine dump already shows the blocked wait.
These tests wait on events throughout and leave hangs to go test's timeout.
Signed-off-by: Evaline Ju <69598118+evaline-ju@users.noreply.github.com>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Re-reviewed at 8099c1b. The follow-up commit handles the points from the earlier review. The dead got == nil branches are gone, which is safe because outcomeRecorder.seen() only returns once done is closed, and done closes only when got is set. TestProcessAttribution_AConnectionWithNoRequestIsNotLookedUp now uses newProcessProxy with an http.Server hook rather than a copy that had drifted, and the hook runs before ts.Start(), so httptest's own ConnState wrapper still chains to it. eventually's doc comment now states what cond may depend on. Your reasoning for leaving hangs to go test's timeout (no CI time saved, and the goroutine dump shows where it is blocked) is fair, so I'm not pressing the deadline suggestion.
Ordering checks on head:
- The store calls recorders under its write lock, after the event is applied, so a
condthat reads throughViewsees the write that signalled it. - The non-store conditions (
Programs/Skip/Unread) are updated inbridgeServebeforetl.openwrites the row, so those waits cannot miss their event. bridgeServeruns synchronously insideHandleTransparentConn, so checkingSkipafter<-done1is sound.assertSplitsAtholds:sessioneventstampsAtbefore it computesDuration, soAt−Duration ≤ start.
Local runs of core/listener/forwardproxy on head: go vet is clean, -count=10 passes, and -race -count=10 shows no data races. One failure in the race run was TestEgress_DialFailure502WithKind (403 instead of 502), a test this PR doesn't touch. It reserves a port, closes it, and then newEgressRig opens new listeners, which can be handed that same port. It's a pre-existing flake and out of scope here, but it may be worth a follow-up given what this PR is about.
Still-open nits from the last pass (advisory): the PR body has a cut-off sentence ("so tick."), and the commit subjects have no conventional prefix.
Author: evaline-ju (CONTRIBUTOR, repo admin permission, so a maintainer)
Areas reviewed: Go tests and the forward-proxy listener (transparent.go drain-ticker seam, which keeps behaviour unchanged)
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed off: yes
CI status: passing
PR #1984 added a store argument to the eventually test helper and changed every caller that existed then. PR #1995 added parent_test.go on a base without #1984, so its two calls use the old signature. Each PR passed CI alone. After both merged, go vet on main fails: parent_test.go:146:24: not enough arguments in call to eventually Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
… made without it rossoctl#1984 (9064cbe) gave eventually a *session.Store parameter so it can wait on the store's signal instead of sleeping. Two call sites in parent_test.go, from 23ef75c, still called the three-argument form, so go vet fails on main and every PR merging against it inherits the failure. Both tests hold the store their rows come from; pass it. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Mariusz Sabath <mrsabath@gmail.com>
Summary
Removes timing from the forward proxy tests. Each test now waits for the event it checks, such as a store change, a handler being reached or a connection closing, instead of sleeping or polling to a deadline. Negative checks run right after a synchronous step, and expiry cases use a 1ns window. Timeouts that only guarded against hangs are gone, so a hang now fails with go test's goroutine dump.
The one production change is a seam in the tunnel's half-close drain: the drain takes its ticker as a parameter, so a test can send each tick itself. Production uses the same real ticker at the same interval.
Assisted-By: Claude (Anthropic AI)
Summary by CodeRabbit