Repository navigation
Fix five flaky server integration tests - #32467
Conversation
Each one raced the CI worker or a timing window: - access groups: drain the queued sync and compute jobs around the test's direct sync, since the recompute skips rows the worker holds locked - chat channel deletion: wait for the moved-threads job that holds the deleted channel's lock - api rate limit: widen the window to 5s and reset the bucket key instead of sleeping - sdk client schema text: wait for deferred schema operations before syncing, using the server's own list of operation names - workflow stopping: drain the executor job before forcing the run to STOPPING
🤖 PR Review
🛡️ Security Review✅ No high-severity vulnerabilities detected. 🚦 Auto-approve🙋 Manual review recommended for the following reason(s):
Automated pre-review — human approval still required. |
✅ Quality review · no findings
High-level — Test-only fix for flaky integration tests: it waits for queued jobs and deferred operations, resets the rate-limit bucket by deleting its Redis keys, and reuses the server's SCHEMA_AFFECTING_DEFERRED_WORKSPACE_OPERATIONS constant, so there is no product, architecture, build or deploy concern. Reviewed against the |
Confidence Score: 5/5
[Low impact] The PR appears safe to merge. SummaryThis PR makes integration tests wait for background work and gives rate-limit tests a clean starting state.
Reviews (2) · Last reviewed commit: "Drop added test comments" · Reviewed by Greptile |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the test-only changes aimed at reducing integration-test timing sensitivity.
No open issues 🎉
What changed in this PR
Stabilizes server integration tests by waiting for background work and reducing timing sensitivity. Changes are test-only; production code is unchanged.
Changes:
- Wait for queued jobs before access-group, chat-channel, and workflow assertions.
- Reset rate-limit buckets directly and widen timing tolerances.
- Wait for deferred schema operations before SDK synchronization, including object rebuilds.
| File | Description |
|---|---|
packages/twenty-server/test/integration/utils/wait-for-deferred-workspace-operations-or-throw.util.ts |
Reuses the shared schema-affecting operation list. |
packages/twenty-server/test/integration/usage-limit/api-rate-limit.integration-spec.ts |
Resets Redis buckets and relaxes retry timing assertions. |
packages/twenty-server/test/integration/sdk-client/utils/sync-sdk-client-probe-application.util.ts |
Waits for deferred operations before synchronization. |
packages/twenty-server/test/integration/permissions/access-groups/record-access-group.integration-spec.ts |
Drains jobs before synchronization and recomputation. |
packages/twenty-server/test/integration/permissions/access-groups/query-many-records-through-access-groups.integration-spec.ts |
Drains jobs around access-group synchronization. |
packages/twenty-server/test/integration/permissions/access-groups/access-groups-shared-by-value.integration-spec.ts |
Drains jobs around access-group synchronization. |
packages/twenty-server/test/integration/graphql/suites/workflow/core-workflow-execution.integration-spec.ts |
Waits for jobs before forcing the stopping state. |
packages/twenty-server/test/integration/graphql/suites/chat-channel/utils/chat-channel-test.util.ts |
Waits for background work after channel deletion. |
Review effort: Balanced
|
🚀 Preview Environment Ready! Your preview environment is available at: https://appointment-responding-cars-suburban.trycloudflare.com This environment will automatically shut down after 5 hours. |
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
record-access-group(+query-many-records-through-access-groups,access-groups-shared-by-value)SKIP LOCKED, so rows held by the worker stay NULLchat-channel-deletion-and-summariesMoveDeletedAgentChatChannelThreadsJob, which holds its deletion lock, so the next delete getsCHAT_CHANNEL_BUSYdeleteChannelBehindStaleCachedrains events and jobsapi-rate-limitsdk-client-core-module-schema-textcreateOneObjectleaves deferred index/FK builds, so the next sync getsDEFERRED_WORKSPACE_MIGRATION_ACTIONS_IN_PROGRESSSCHEMA_AFFECTING_DEFERRED_WORKSPACE_OPERATIONS(it was missingrebuild_object)core-workflow-execution"refuses a submission while its run is stopping"PENDING, sees the forcedSTOPPINGand fails the formSTOPPINGTest-only changes, no production code touched.