Clean up deterministic tests
This commit is contained in:
parent
7b9287ca52
commit
f36a84b275
1 changed files with 1366 additions and 3835 deletions
|
|
@ -1,36 +1,8 @@
|
|||
import type { ClientState, TestDefinition } from "../test-definition";
|
||||
import { assert } from "../utils/assert";
|
||||
|
||||
function verifyBothFiles(state: ClientState): void {
|
||||
assert(
|
||||
state.files.has("alpha.md"),
|
||||
`Expected alpha.md to exist, got: ${Array.from(state.files.keys()).join(", ")}`
|
||||
);
|
||||
assert(
|
||||
state.files.has("beta.md"),
|
||||
`Expected beta.md to exist, got: ${Array.from(state.files.keys()).join(", ")}`
|
||||
);
|
||||
const alphaContent = state.files.get("alpha.md") ?? "";
|
||||
const betaContent = state.files.get("beta.md") ?? "";
|
||||
assert(
|
||||
alphaContent.includes("from client 0"),
|
||||
`Expected alpha.md to contain "from client 0", got: "${alphaContent}"`
|
||||
);
|
||||
assert(
|
||||
betaContent.includes("from client 1"),
|
||||
`Expected beta.md to contain "from client 1", got: "${betaContent}"`
|
||||
);
|
||||
}
|
||||
import type { TestDefinition } from "../test-definition";
|
||||
|
||||
export const serverPauseBothClientsCreateTest: TestDefinition = {
|
||||
name: "Server Pause While Both Clients Create",
|
||||
description:
|
||||
"Both clients are synced. Client 0 creates alpha.md. The server is immediately " +
|
||||
"paused (SIGSTOP), stalling in-flight requests and WebSocket broadcasts. " +
|
||||
"While the server is paused, Client 1 creates beta.md (its request will also stall). " +
|
||||
"After the server resumes, both files should propagate to both clients. " +
|
||||
"This tests that the retry logic on both clients correctly recovers stalled " +
|
||||
"HTTP creates and that WebSocket reconnection delivers the missed broadcasts.",
|
||||
"Client 0 creates a file, then the server is paused. Client 1 creates a different file while the server is paused. After the server resumes, both files should exist on both clients.",
|
||||
clients: 2,
|
||||
steps: [
|
||||
{ type: "enable-sync", client: 0 },
|
||||
|
|
@ -38,8 +10,6 @@ export const serverPauseBothClientsCreateTest: TestDefinition = {
|
|||
{ type: "sync" },
|
||||
{ type: "barrier" },
|
||||
|
||||
// Client 0 creates a file, then immediately pause the server
|
||||
// so the create response (or broadcast to client 1) may be stalled
|
||||
{
|
||||
type: "create",
|
||||
client: 0,
|
||||
|
|
@ -48,8 +18,6 @@ export const serverPauseBothClientsCreateTest: TestDefinition = {
|
|||
},
|
||||
{ type: "pause-server" },
|
||||
|
||||
// While server is paused, client 1 creates a different file.
|
||||
// This HTTP request will stall until the server is resumed.
|
||||
{
|
||||
type: "create",
|
||||
client: 1,
|
||||
|
|
@ -57,18 +25,17 @@ export const serverPauseBothClientsCreateTest: TestDefinition = {
|
|||
content: "from client 1"
|
||||
},
|
||||
|
||||
// Resume the server — both stalled requests should complete
|
||||
{ type: "resume-server" },
|
||||
|
||||
// Let both clients finish all pending sync work
|
||||
{ type: "sync" },
|
||||
{ type: "barrier" },
|
||||
|
||||
// Both files must exist on both clients
|
||||
{ type: "assert-exists", client: 0, path: "alpha.md" },
|
||||
{ type: "assert-exists", client: 0, path: "beta.md" },
|
||||
{ type: "assert-exists", client: 1, path: "alpha.md" },
|
||||
{ type: "assert-exists", client: 1, path: "beta.md" },
|
||||
{ type: "assert-consistent", verify: verifyBothFiles }
|
||||
{
|
||||
type: "assert-consistent",
|
||||
verify: (s) =>
|
||||
s
|
||||
.assertContains("alpha.md", "from client 0")
|
||||
.assertContains("beta.md", "from client 1"),
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue