jonathansudhakar1 opened a new pull request, #40993:
URL: https://github.com/apache/beam/pull/40993

   Fixes #40992.
   
   `TestPersistBundle_ResidualResumeDelay/parks_with_hold_and_schedules` is 
flaky. It failed on master in [this "Go tests" 
run](https://github.com/apache/beam/actions/runs/41695459870) with `residual 
release scheduled 5.000001877s after persisting, want within (0, 5s]`.
   
   **Cause.** The test takes `before := time.Now()`, at nanosecond precision, 
and checks that the scheduled release time `fireAt` is within `(0, delay]` of 
it. `PersistBundle` computes `fireAt` as `emNow.Add(delay)`. With `EnableRTC`, 
`emNow` is `mtime.Now()`, which is read a little later and truncated to 
milliseconds. When a millisecond boundary falls between the two reads, `fireAt` 
lands a few microseconds past `before + delay`. The runner behaves correctly; 
only the test's bound is wrong.
   
   **Change (test only).** The test now also takes `after := time.Now()` once 
`PersistBundle` returns. It checks `fireAt` against 
`[mtime.FromTime(before).Add(delay), mtime.FromTime(after).Add(delay)]`. That 
is the exact range `PersistBundle` can produce, so the check is still strict: a 
release time that is immediate, doubled, or off by a millisecond still fails.
   
   ## Testing
   
   Run from `sdks/` on macOS/arm64 with Go 1.26:
   
   - **Before:** `go test ./go/pkg/beam/runners/prism/internal/engine/ -run 
'TestPersistBundle_ResidualResumeDelay/parks_with_hold_and_schedules' 
-count=20000` failed 13 times, with the same message as CI (for example, 
`5.000001s after persisting`). A separate `-count=3000` run failed once.
   - **After:** the same command with `-count=20000`, run twice: 0 failures, 
`ok`.
   - **Mutants**, each run once against the new check in `partitionResiduals`, 
all failed as expected:
     - `fireAt := emNow.Add(r.Delay + time.Millisecond)` failed.
     - `fireAt := emNow.Add(r.Delay - time.Millisecond)` failed.
     - `fireAt := emNow.Add(2 * r.Delay)` failed.
   - `go test ./go/pkg/beam/runners/prism/internal/engine/`: `ok` (53.5s). `go 
vet` and `gofmt -l` on the package are clean.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to