Fix five flaky server integration tests
Merged
CH
3h ago+45+45+01234567890123456789-12-12-01234567890123456789
Why
I ranked integration test failures from PR runs since Nov 10 (86 failed shard logs) by how many unrelated branches each spec failed on. Five specs account for most of the noise. Each one races the CI worker or a timing window.
flowchart LR
A[Test mutates metadata] --> B[Listener queues a job]
B --> C[CI worker runs the job]
A --> D[Test asserts or acts directly]
C -. holds a lock or rewrites state .-> D
D --> E{Race}
E -->|worker first| F[Flaky failure]
E -->|test first| G[Pass]
Before / after
| Spec | Failures | Before | After |
|---|---|---|---|
record-access-group (+ query-many-records-through-access-groups, access-groups-shared-by-value) | ~24 | Rule upsert queues a sync, and the sync queues a compute job. The test's recompute uses SKIP LOCKED, so rows held by the worker stay NULL | Drain jobs before the direct sync and again before the recompute |
chat-channel-deletion-and-summaries | ~21 | Deleting the destination queues MoveDeletedAgentChatChannelThreadsJob, which holds its deletion lock, so the next delete gets CHAT_CHANNEL_BUSY | deleteChannelBehindStaleCache drains events and jobs |
api-rate-limit | 7 | 1 request per 1s token bucket with continuous refill, so a request over 1s on a loaded runner refilled the bucket | 5s window, bucket reset by deleting its Redis key instead of sleeping, Retry-After checked as a range |
sdk-client-core-module-schema-text | 6 | createOneObject leaves deferred index/FK builds, so the next sync gets DEFERRED_WORKSPACE_MIGRATION_ACTIONS_IN_PROGRESS | Wait for deferred operations first. The wait helper now reuses SCHEMA_AFFECTING_DEFERRED_WORKSPACE_OPERATIONS (it was missing rebuild_object) |
core-workflow-execution "refuses a submission while its run is stopping" | 5 | The executor job is still running when the form reads PENDING, sees the forced STOPPING and fails the form | Drain jobs before forcing STOPPING |
Test-only changes, no production code touched.