Skip to content

Fix five flaky server integration tests - #32467

Merged
charlesBochet merged 2 commits into
mainfrom
charles/integration-tests-flakiness-3b89ac
Dec 5, 2026
Merged

charlesBochet merged 2 commits into
mainfrom
charles/integration-tests-flakiness-3b89ac

Conversation

@charlesBochet

@charlesBochet charlesBochet commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

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]
Loading

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.

View guided diff

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
Copilot AI balanced review requested due to automatic review settings December 5, 2026 11:13
@twenty-ci-bot-public

twenty-ci-bot-public Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

🤖 PR Review

Check Result
🔍 Build safety ⏭️ skipped — external-only
🧭 Triage ⏭️ skipped — external-only
📐 Quality ✅ passed
🛡️ Security ✅ passed
🚦 Auto-approve 👀 needs review — Touches high-blast-radius paths: Auth / permissions code
🔐 Permissions ⏭️ skipped: no endpoint permission change

🛡️ Security Review

✅ No high-severity vulnerabilities detected.


🚦 Auto-approve

🙋 Manual review recommended for the following reason(s):

  • Touches high-blast-radius paths: Auth / permissions code

  • 🧠 Complexity: low

  • 📏 Size: +45 / -12 lines across 8 file(s)

  • ⛔ High-blast-radius paths: packages/twenty-server/test/integration/permissions/access-groups/access-groups-…, packages/twenty-server/test/integration/permissions/access-groups/query-many-rec…, packages/twenty-server/test/integration/permissions/access-groups/record-access-…


View details

Automated pre-review — human approval still required.

@twenty-ci-bot-public

twenty-ci-bot-public Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

✅ Quality review · no findings

Safe to merge — no high-level 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.
Low-level — No rule violations found — 400 rule questions over 8 piece(s) of 8 file(s)


Reviewed against the pr-review standard — high-level then low-level. Advisory; human review still required. Run details.

@greptile-apps

greptile-apps Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5RetriggerView in Greptile

[Low impact] The PR appears safe to merge.

Summary

This PR makes integration tests wait for background work and gives rate-limit tests a clean starting state.

  • Access-group tests wait for queued jobs before syncing and recomputing records.
  • Channel deletion waits for grant rewrites before setting up stale-cache access.
  • The workflow test waits for jobs to finish before setting a run to STOPPING.
  • Rate-limit tests reset their API key bucket and use a five-second window.
  • Deferred schema waits include object rebuilds before the SDK probe applies its manifest.

Reviews (2) · Last reviewed commit: "Drop added test comments" · Reviewed by Greptile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@twenty-ci-bot-public

Copy link
Copy Markdown

🚀 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.

@charlesBochet
charlesBochet merged commit 7920c30 into main Dec 5, 2026
171 checks passed
@charlesBochet
charlesBochet deleted the charles/integration-tests-flakiness-3b89ac branch December 5, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants