t3-code-android-nightly/.repos/effect-smol/packages/platform/node/test/cluster-integration
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00
..
ClusterCron.test.ts chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
Entity.test.ts chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
globalSetup.ts chore(refs): sync Effect reference to rc.112 (#10653) 2026-09-07 21:54:44 -07:00
harness.ts chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
Locks.test.ts chore(refs): sync Effect reference to rc.112 (#10653) 2026-09-07 21:54:44 -07:00
Persistence.test.ts chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
README.md chore(refs): sync Effect and Alchemy references to rc.115 and beta.78 (#12327) 2026-09-17 23:21:25 -07:00
Residency.test.ts chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
Smoke.test.ts chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
StreamDisconnect.test.ts chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
Transport.test.ts chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00
Workflow.test.ts chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170) 2026-10-05 13:22:30 -07:00

Cluster integration tests

This suite runs multi-runner clusters against shared PostgreSQL and MySQL containers. It is excluded from the default test projects and only registered when EFFECT_CLUSTER_TESTS=1.

EFFECT_CLUSTER_TESTS=1 pnpm test-cluster

Docker must be running. Vitest global setup starts one postgres:alpine and one mysql:lts container for the entire project. Every cluster uses a unique table prefix, and every runner listens on an operating-system-assigned port.

Harness

harness.ts exposes:

  • make({ backend, entities, lockMode, config }) to create a scoped cluster harness.
  • start(count, { assignedShardGroups, entities, runnerShardWeight }) to start in-process socket runners and a client over SchemaBinary, optionally overriding the entity layer for those runners.
  • stop(runner) for graceful deregistration and shard handoff.
  • kill(runner) for abrupt teardown without deregistration or explicit lock cleanup.
  • freeze(runner) to suspend SQL heartbeats and lock refresh while leaving the runner's sockets and reserved SQL connection open.
  • faultLock(runner, mode) to blackhole, stick, fail, stick while blocking release of, or clear faults on a runner's reserved lock connection.
  • cutSocket(runner, { peer, direction }) to close one inbound or outbound client/runner connection without stopping either endpoint.
  • insertMessage(row) to inject a raw row into this cluster's prefixed message table.
  • waitUntil, waitForStableAssignments, and waitForEntityOwner for deadline-based polling with cluster diagnostics on failure.
  • clientSharding and ownersOfShard for direct shard ownership assertions.
  • messageCounts, unprocessedMessageCount, repliedMessageCount, and failedMessageCount for storage assertions scoped to the cluster prefix.

Advisory locks are owned by the reserved database session. A frozen advisory-lock runner therefore keeps its locks until it is stopped or killed. Row-lock mode uses expiry-driven takeover while frozen.

Adding a test

Add *.test.ts under this directory. Test files define entities and assertions; all cluster startup, lifecycle, waiting, and storage inspection belongs in the harness. Use the harness polling helpers instead of calling Effect.sleep.