fix(test): serialize harness client cache under parallel integration tests - #289
Merged
Merged
Conversation
…ests Co-authored-by: Silvan <adlerhurst@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a flaky fatal error: concurrent map writes panic in Go integration tests by making the shared integration test Harness safe to use across parallel subtests. It does so by introducing a mutex on the harness and serializing lazy cache initialization for API clients and fake security sources.
Changes:
- Add a
sync.MutextoHarnessto guard shared mutable state. - Serialize initialization/writes for
apiClients,anonymousClient,fakeSecuritySources, andanonymousSecuritySourcein the harness helper methods. - Add an empty changeset documenting a test-only fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/api/integration_test/helpers/harness.go | Adds a mutex to the shared integration test harness. |
| internal/api/integration_test/helpers/client.go | Uses the harness mutex to guard cached client/security-source creation. |
| .changeset/fix-harness-parallel-test-race.md | Empty changeset for a test-only harness concurrency fix. |
Co-authored-by: Silvan <adlerhurst@users.noreply.github.com>
|
@adlerhurst must be a member of the zitadel team on Vercel to deploy. Learn more about collaboration on Vercel and other options here. |
adlerhurst
added a commit
that referenced
this pull request
Jul 20, 2026
…#287) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Fixes #267 Align user/team storage with [ADR 024](docs/adrs/024-user-team-lifecycle-ownership.md): - Replace `users.team_id` with nullable `lifecycle_owner_team_id` (NULL = self-owned, set = team-owned) - Add `users.status` (active/suspended/deactivated/pending_purge) - Add `team_memberships` N:N table with membership status - Add `teams.status` and lifecycle `Deactivate` methods on team/user repositories - Remove `ON DELETE CASCADE` on the user/team graph; lifecycle deletes via repository policy - Backfill existing `team_id` data in migration `000011_user_team_lifecycle.sql` (Postgres + Spanner) ## Validation - `go test -tags=postgres_integration ./internal/storage/database/repository/... -count=1` - `corepack pnpm run check -- --only go` ## Release notes / changeset `.changeset/user-team-lifecycle-storage.md` — `@zitadel/server` patch: align user/team lifecycle storage with ADR 024. ## Notes Closes #267 Branch merged with `main` before review fixes. Harness mutex fix landed via #289. Migration backfill maps legacy `users.team_id` to `lifecycle_owner_team_id` as a conservative alpha default (old schema required a team context, so self-serve vs enterprise provenance cannot be distinguished retroactively). New creates stay self-owned unless `LifecycleOwnerTeamID` is set. Acceptance checklist: - [x] Self-owned user survives team deletion - [x] Team-owned user deactivated when owning team deleted - [x] Deleting a user does not cascade-delete teams they created - [x] No ON DELETE CASCADE on user/team graph - [x] Team-owned users lose all memberships when owning team is deactivated <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-f52f2c82-7c40-4962-bf78-39a8915c3d00"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-f52f2c82-7c40-4962-bf78-39a8915c3d00"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Silvan <adlerhurst@users.noreply.github.com> Co-authored-by: Florian Forster <florian@zitadel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a flaky
fatal error: concurrent map writespanic ingo-integration-test-postgreswhen parallel subtests share one integration testHarness.The harness lazily caches API clients and fake security sources in maps (
apiClients,fakeSecuritySources) without synchronization. Parallel subtests (for example in flow definition tests) can write to those maps concurrently and crash the test binary.This change adds a mutex on
Harnessand serializes map initialization and writes inEnsureAPIClient,EnsureAnonymousAPIClient, and the fake security source helpers.No product behavior change — test harness only.
Validation
go-integration-test-postgres(primary proof)go build ./...Release notes / changeset
No changeset required — no public npm package files changed.
Notes
Extracted from #287 so the lifecycle storage work stays focused on ADR 024 / Fixes #267.