Repository navigation
conn: stepped-clock tests of the HTTP/2 D0, D2, header-block, tombstone and ExpiredWrites deadlines (Refs #1190) - #1191
Merged
Merged
Conversation
…the write window (D2, ExpiredWrites), the header-block and the tombstone deadlines (Refs #1190) mono.Manual is a clock that moves only when a test moves it (Advance: time passes on both readings; Step: the wall reading alone), standing an hour past the real clock so that a site that still reads time.Now is an hour off. The tests need no sleep. For each deadline, in both directions of a 75 s step: the step alone must not fire it, and the time that then passes must. They pass on the monotonic clock and are red on the wall clock (flipped = false: 14 of 15 subtests; the forward step of the renewal case is the one that does not discriminate).
No production change: every one of the deadlines (D0 and its ack cap, D2 and ExpiredWrites, the header block, the tombstone) already reads internal/mono. The wiring: the canary step runs the five tests by name with -v at +1 h and fails when fewer than five pass, so a rename cannot pass as no tests; the whole of internal/conn already runs under the canary at both signs, and the tests take milliseconds, so they stay in the -race steps (they add no measurable time to them).
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…r path are stepped-clock tests; the Manual clock stands an hour past the real wall at every skew (Refs #1190) Review r1 of #1191. F2a: TestIdleClockRestartsFromStreamActivity...: a conn that carried a stream is idle for IdleTimeout after the stream, not after the first sweep (red on the wall clock; the d0At reset at conn/h2.go reads the sweep's now). F2b: TestWaiterWindowIgnores... (h2 stream): a pool handler's wait is judged at its window's end by its own timer, which ExpiredWrites skips; the manual clock gives no verdict before Advance, whatever the runner's speed, and the timer re-arms against the clock. F1: NewManual anchors to the real wall AFTER the skew (at CELERIS_MONO_SKEW=-1h the hour on the monotonic reading alone cancelled the skew and the clock stood on the real wall: two mutants passed the named run). F3: the last D0 period runs out. F4: the 'step alone' sweep crosses the d0Interval gate; a comment says what forward and backward test on the monotonic clock. F5: the tombstone test asserts the request did not expire at 0.5 s. CI: the named run covers both packages and wants 7.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1190
Stepped-clock tests for the HTTP/2 deadlines the flip's tests (#1188) do not pin: the connection's idle clock D0 (and its restart from stream activity, and its ack cap,
ExtendIdleontcp_infobytes_acked), the write window D2 (buffered streams,ExpiredWrites, and pool-handler waiters), the header-block deadline and the tombstone deadline. For each, in both directions of a 75 s step of the wall clock: the step alone must not fire the deadline (cut early), and the time that then really passes must (held past its bound).Commits
conn: stepped-clock tests ...:internal/conn/stepped_h2_1190_test.goandmono.Manual(internal/mono/stepclock.go).ci: the canary names the HTTP/2 stepped-clock tests.conn, h2 stream: the D0 restart ... and the D2 waiter path ...: F2 two more tests (D0 restart from stream activity; D2 waiter path, ininternal/protocol/h2/stream/stepped_wait_1190_test.go), F1NewManualanchored to the real wall at every skew, F3/F4/F5 assertions, CI names 7 tests. Then a lint nit (realshadowed a built-in).No production change: every one of these deadlines already reads
internal/mono; all seven tests pass on the monotonic clock as they are.Flake-proof by construction
No sleep that depends on runner speed, no real time in the conn tests.
mono.Manualis a clock that moves only when the test moves it:Advance(d)lets d of time pass on both readings,Step(d)steps the wall reading alone. No verdict can come beforeAdvance, whatever the runner's speed. The waiter test (stream package) has a real Go timer of WriteTimeout (40 ms) that the waiter arms itself; the clock being frozen, the timer fires and re-arms against it until the test advances the clock, so the verdict comes one timer period afterAdvanceon any runner (the negative assertions, "no verdict yet", can only pass vacuously on a slow runner, never fail; the positive wait is bounded at 5 s for a 40 ms period).The clock stands one hour past the REAL wall clock at every
CELERIS_MONO_SKEW(review r1 F1):NewManualanchors its readings to the real wall after the canary's skew (the skewedNow()is real + 1 h at +1 h, 0 and -1 h; earlier the hour was put on the monotonic reading alone and at -1 h it cancelled the skew, leaving the clock on the real wall, where two mutants survived the named run). So a site that still readstime.Nowis an hour off every stamp of the clock and its test fails, at both signs (the mutant table below, column "new tests -1 h").On the monotonic clock a step moves nothing, so the "forward" and "backward" subtests test the same thing there (the time that passes fires the deadline); they differ on the wall clock, where the tests are RED. The sweeps that assert "the step alone fired nothing" come after enough time has passed to cross D0's
d0Intervalgate (100 ms), or the sweep would not look at the idle clock.Scenarios
TestIdleClockAndAckCapIgnoreAStepOfTheWallClock1190ExtendIdlegives the first extension, a step and 0.5 s into the extended period do not close, 1.2 s do; no acknowledged progress refuses the next extension; progress extends, a step and 0.5 s into that period do not close, and that period runs out at 1.2 sTestIdleClockRestartsFromStreamActivityOnAStepOfTheWallClock1190d0At = now, conn/h2.go)TestWriteWindowExpiryIgnoresAStepOfTheWallClock1190ExpiredWrites(WriteTimeout 1 s)ExpiredWritesboth), and is reset with 1.2 s of timeTestWriteWindowRenewalIgnoresAStepOfTheWallClock1190TestWaiterWindowIgnoresAStepOfTheWallClock1190(h2 stream)write_wait.go, judged by the handler's own timer)os.ErrDeadlineExceeded) once the window's time has passedTestHeaderBlockDeadlineIgnoresAStepOfTheWallClock1190TestTombstoneDeadlineIgnoresAStepOfTheWallClock1190Scope, said plainly:
ExpiredWritesis D2's SWEEP side for BUFFERED streams only (it skips waiters:!st.waiter); the waiter path is the separate test above.RED against the wall clock (
flipped = false: the clock is the wall reading)const flipped = falseininternal/mono/mono.go(nothing else changed),go test -run '1190$' -v ./internal/conn ./internal/protocol/h2/stream: 20 of the 21 test and subtest results FAIL (7 tests, 14 subtests); the one that passes is the forward renewal subtest (a forward step does not hurt a stream that keeps releasing).With
flipped = true(main): all pass, also with the clock skewed by +1 h and -1 h.Mutants: one site back to
time.Now().UnixNano()(scratch copy;mut1190b.py)Gates: the scan (
TestNoWallStamps); the new tests by name (-run '1190$', conn + h2 stream) with no skew, at +1 h and at -1 h; the canary's wholeinternal/conn+internal/protocol/h2/streamat +1 h and -1 h. "killed (N)" = N FAIL lines; "pass" = the mutant survived that gate.Every gate kills every mutant at every skew, including the two (header block, D2 noteBuffered) that survived the named run at -1 h before F1, and the two (D0 activity reset, D2 waiter record) that no test reached before F2.
CI wiring and headroom
-run '1190$' -v, +1 h,-p 1, conn + h2 stream; fails unless seven pass), so a rename cannot pass as "no tests".internal/connandinternal/protocol/h2/streamrun whole under the canary at both signs as before.-racestep: six take milliseconds, the waiter's 0.7 s. Test-binary times on this PR's CI run (head e220f3d), against the previous run of this PR (8037241): unit job iouring (race) 496.9 s of 600 s (499.9 s), unit job root set incl. epoll 361.7 s of 540 s (365.6 s),internal/connthere 27.9 s (32.5 s),internal/protocol/h2/streamthere 89.3 s, base-tier iouring (race) 590.5 s of 900 s (597.6 s), the canary step 241 s (246 s; the seven named tests are 0.7 s of it). The other near-timeout step, test-coverage.yml's iouring, is not touched by a conn or stream test. 31 checks pass, 1 skipped (CodeRabbit).Draft.
Refs #1190only.