Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion pkgs/id/hosted-worker/smoke/smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,19 @@
//
// Usage: node smoke/smoke.mjs
import { spawn } from "node:child_process";
import { readFileSync } from "node:fs";

const PKG = new URL("..", import.meta.url).pathname;

// The schema version has one source: SCHEMA_VERSION in src/user-do.ts.
// Reading it here rather than repeating a literal means a future bump
// updates the DO, the bootstrap and this assertion together (#13673).
const SCHEMA_VERSION = (() => {
const src = readFileSync(new URL("../src/user-do.ts", import.meta.url), "utf8");
const m = src.match(/export const SCHEMA_VERSION = (\d+);/);
if (!m) throw new Error("smoke: SCHEMA_VERSION not found in src/user-do.ts");
return Number(m[1]);
})();
const A = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const B = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
let failures = 0;
Expand Down Expand Up @@ -79,7 +90,7 @@ async function waitUp(port, tries) {
check("harness + DO start, lazy create", up);
let r = await fetch(base + q(A, A, "us"));
let body = await r.json();
check("state reports binding, jurisdiction, schema v2", body.binding_id === A && body.jurisdiction === "us" && body.schema_version === 2, JSON.stringify(body));
check("state reports binding, jurisdiction, current schema version (source: SCHEMA_VERSION)", body.binding_id === A && body.jurisdiction === "us" && body.schema_version === SCHEMA_VERSION, JSON.stringify(body));

const many = await Promise.all(Array.from({ length: 8 }, () => fetch(base + q("cccccccccccccccccccccccccccccccc", "cccccccccccccccccccccccccccccccc", "eu"))));
check("concurrent first requests all 200 (idempotent bootstrap)", many.every((x) => x.status === 200));
Expand Down