test(platform-cloudflare): split keep-alive recovery into its own test file

Recovery.test.ts now covers only unprocessed persisted-message replay
after a restart. The keep-alive restart test moves unchanged to
KeepAliveRecovery.test.ts, which is tracked separately.
This commit is contained in:
Tim Smart
2026-10-08 08:45:11 +00:00
parent 7753e290cd
commit 8ed3dc6f62
2 changed files with 45 additions and 38 deletions
@@ -0,0 +1,44 @@
import { assert, describe, it } from "@effect/vitest"
import { Effect } from "effect"
import { makeCluster } from "./harness.ts"
// After a restart nothing in these tests messages the entity before the
// rebuild is observed: the entity Durable Object has to wake on its own.
describe("Cloudflare cluster integration | KeepAlive recovery", () => {
it.effect("rebuilds an entity holding keepAlive after an isolate restart", () =>
Effect.gen(function*() {
const cluster = yield* makeCluster
yield* cluster.fetchJson("/pinned/pin?id=recover")
yield* cluster.waitUntil(
"Entity.keepAlive(true) did not establish a hold on the entity Durable Object",
Effect.map(cluster.fetchJson("/holds?type=Pinned&id=recover"), (result) => result.holds === 1)
)
yield* cluster.restart
yield* cluster.waitUntil(
"The keep-alive entity was not rebuilt after the isolate restart",
Effect.map(cluster.fetchJson("/state"), (state) => (state.builds["Pinned/recover"] ?? 0) === 1)
)
yield* cluster.waitUntil(
"The rebuilt keep-alive entity did not hold its Durable Object again",
Effect.map(cluster.fetchJson("/holds?type=Pinned&id=recover"), (result) => result.holds === 1)
)
// Releasing keep-alive ends the recovery: the next restart leaves the
// entity cold.
yield* cluster.fetchJson("/pinned/unpin?id=recover")
yield* cluster.waitUntil(
"Releasing keepAlive did not unpin the entity Durable Object",
Effect.map(cluster.fetchJson("/holds?type=Pinned&id=recover"), (result) => result.holds === 0)
)
yield* cluster.restart
yield* Effect.sleep("2 seconds")
const state = yield* cluster.fetchJson("/state")
assert.isUndefined(
state.builds["Pinned/recover"],
"The entity was rebuilt after a restart although it had released keepAlive"
)
}), 60_000)
})
@@ -3,45 +3,8 @@ import { Effect } from "effect"
import { makeCluster } from "./harness.ts"
// After a restart nothing in these tests messages the entity before the
// recovery is observed: the entity Durable Object has to wake on its own.
// replay is observed: the entity Durable Object has to wake on its own.
describe("Cloudflare cluster integration | Recovery", () => {
it.effect("rebuilds an entity holding keepAlive after an isolate restart", () =>
Effect.gen(function*() {
const cluster = yield* makeCluster
yield* cluster.fetchJson("/pinned/pin?id=recover")
yield* cluster.waitUntil(
"Entity.keepAlive(true) did not establish a hold on the entity Durable Object",
Effect.map(cluster.fetchJson("/holds?type=Pinned&id=recover"), (result) => result.holds === 1)
)
yield* cluster.restart
yield* cluster.waitUntil(
"The keep-alive entity was not rebuilt after the isolate restart",
Effect.map(cluster.fetchJson("/state"), (state) => (state.builds["Pinned/recover"] ?? 0) === 1)
)
yield* cluster.waitUntil(
"The rebuilt keep-alive entity did not hold its Durable Object again",
Effect.map(cluster.fetchJson("/holds?type=Pinned&id=recover"), (result) => result.holds === 1)
)
// Releasing keep-alive ends the recovery: the next restart leaves the
// entity cold.
yield* cluster.fetchJson("/pinned/unpin?id=recover")
yield* cluster.waitUntil(
"Releasing keepAlive did not unpin the entity Durable Object",
Effect.map(cluster.fetchJson("/holds?type=Pinned&id=recover"), (result) => result.holds === 0)
)
yield* cluster.restart
yield* Effect.sleep("2 seconds")
const state = yield* cluster.fetchJson("/state")
assert.isUndefined(
state.builds["Pinned/recover"],
"The entity was rebuilt after a restart although it had released keepAlive"
)
}), 60_000)
it.effect(
"replays an unprocessed persisted tell after an isolate restart without new contact",
() =>