Skip to content

test(changehook): stop the end-to-end delivery test failing when the close lands in a later POST - #4668

Merged
strelov1 merged 1 commit into
mainfrom
test/changehook-flaky-batch
Nov 15, 2026
Merged

strelov1 merged 1 commit into
mainfrom
test/changehook-flaky-batch

Conversation

@strelov1

@strelov1 strelov1 commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

TestDeliveryEndToEnd fails now and then (CodeRabbit flagged it on #4591). The first subtest stopped at the first webhook POST and expected it to carry both job-a changes (opened, then closed).

Those two changes are separate transactions. The change feed only returns rows below pg_snapshot_xmin(pg_current_snapshot()), the oldest open transaction of the whole cluster. If another transaction (on a shared dev/CI database, usually another test) starts between them and is still open, the first run sees job-a opened but not job-a closed, sends a POST with only that, and the test fails. The rerun loop did not help, because it stopped once one POST arrived.

Fix (test only): keep running the worker until the received changes, across all POSTs, contain both job-a changes, then assert on that combined list. It still checks that every POST is a signed job.changes event whose ID matches the delivery header, that nothing besides before and job-a arrives, that the order and seq are right, and that the cursor moves. The wait uses the file's existing until (20 s deadline), so a real regression still fails fast.

What I ran:

  • mise exec -- go test -tags=integration -count=20 -run TestDeliveryEndToEnd ./internal/engage/changehook/: 20/20 pass.
  • Forced the race by holding an open transaction between the two job-a statements: the old test fails with exactly the reported error (first POST = job-a opened only); the new test passes 3/3.
  • gofmt -l, go vet -tags=integration ./..., golangci-lint run on the package: clean.

Created with Claude Opus 5.5 in Claude Code.


Note

Low Risk
Test-only change to integration test polling and assertions; no production webhook or worker behavior is modified.

Overview
Makes TestDeliveryEndToEnd’s first subtest resilient when job-a’s open and close changes land in separate webhook POSTs (e.g. another open transaction hides the close from the change feed on the first run).

The test no longer stops after the first delivery or assumes both changes appear in one event. It keeps driving the worker via until until two non-before changes for job-a are seen across all POSTs, then asserts each delivery is a signed job.changes event with matching delivery ID, the combined opened → closed order and seq, and that the subscription cursor advances.

Reviewed by Cursor Bugbot for commit d9242eb. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Tests
    • Updated delivery test coverage to handle changes arriving in separate batches, including batches containing earlier changes. Tests now verify that each delivery is associated with its corresponding event and delivery ID.

The end-to-end delivery test stopped at the first webhook POST and expected it to carry
both job-a changes. They are two transactions, and the feed only shows rows below the
cluster's oldest open transaction, so an unrelated open transaction between them leaves
the closing change for a later POST. Collect across POSTs until both arrive and assert
on the combined list.
@cursor

cursor Bot commented Nov 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: de827711-9971-4046-aa5e-404261ae419b)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T21:45:42.540507Z d9242eb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changehook integration test now accepts the two job-a changes across separate POSTs. It also checks event and delivery identifiers and verifies the expected change sequence.

Changes: Changehook delivery test

Layer / File(s) Summary
Validate changes across deliveries
internal/engage/changehook/worker_integration_test.go
The test collects changes from multiple deliveries, excludes before when checking the expected job-a sequence, and verifies event type, matching event and delivery IDs, change kinds, closed reason, and sequence ordering.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Merge Risk: Minimal · up to d9242

This updates a flaky end-to-end test to tolerate the two changes arriving in separate POSTs. It has no production impact and is ready to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: the end-to-end delivery test in the changehook package stops failing when the closing job-a change arrives in a later POST. The raw summary confirms the test now collects c…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: the end-to-end delivery test in the changehook package stops failing when the closing job-a change arrives in a later POST. The raw summary confirms the test now collects changes across POSTs and asserts on the combined list, so the title matches the main change. It uses the conventional test(scope): prefix and states the goal, though it is long at 96 characters.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3a7e3ba and d9242eb.

Files selected for processing: 1

  • internal/engage/changehook/worker_integration_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.

@strelov1
strelov1 enabled auto-merge (squash) November 15, 2026 21:53
@strelov1
strelov1 merged commit 3ba82a9 into main Nov 15, 2026
47 of 50 checks passed
@strelov1
strelov1 deleted the test/changehook-flaky-batch branch November 15, 2026 21:59
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.

1 participant