Files
workinf_Blender_Wasm/tools/web/check-server-job-isolation.mjs
mes123456 380cbed4ff
Some checks are pending
M6 deployable RC / quick (push) Waiting to run
M6 deployable RC / chromium (push) Blocked by required conditions
M6 deployable RC / release (push) Blocked by required conditions
Checkpoint web parity through Chromium input tasks
2026-08-19 10:39:03 -04:00

39 lines
2.9 KiB
JavaScript

import assert from "node:assert/strict";
import crypto from "node:crypto";
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { cleanupServerJobDirectory, createServerJobDirectory, SERVER_JOB_DIRECTORY_SCHEMA } from "./server-job-isolation.mjs";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const reportPath = path.join(root, "tests/golden/M13-04A/server-job-directory-report.json");
const manifestPath = path.join(root, "tests/golden/M13-04A/manifest.json");
const temporary = await fs.mkdtemp(path.join(os.tmpdir(), "m13-04a-check-"));
const hashFile = async (file) => crypto.createHash("sha256").update(await fs.readFile(file)).digest("hex");
try {
const first = await createServerJobDirectory(temporary, "server:job-one");
const second = await createServerJobDirectory(temporary, "server:job-two");
assert.equal(first.schemaVersion, SERVER_JOB_DIRECTORY_SCHEMA);
assert.notEqual(first.directoryName, second.directoryName);
assert.ok(!first.directoryName.includes(first.jobId));
assert.ok(!second.directoryName.includes(second.jobId));
const firstPath = first.path;
const secondPath = second.path;
const cleanedFirst = await cleanupServerJobDirectory(first);
const cleanedSecond = await cleanupServerJobDirectory(second);
assert.equal(cleanedFirst.state, "CLEANED");
assert.equal(cleanedSecond.state, "CLEANED");
await assert.rejects(fs.stat(firstPath), { code: "ENOENT" });
await assert.rejects(fs.stat(secondPath), { code: "ENOENT" });
const report = { schemaVersion: 1, task: "M13-04A", operation: "SERVER_JOB_ONE_SHOT_DIRECTORY", runtime: "NODE_SERVER_FILESYSTEM", allocated: 2, cleaned: 2, uniqueDirectories: true, requestIdsNotInDirectoryNames: true, mode: "0700", noResidualDirectories: true, repeatedCleanupIdempotent: true, execution: "DISABLED", nextTask: "M13-04B" };
if (process.env.UPDATE_M13_04A_REPORT === "1") { await fs.mkdir(path.dirname(reportPath), { recursive: true }); await fs.writeFile(reportPath, `${JSON.stringify(report, null, 2)}\n`); }
assert.deepEqual(JSON.parse(await fs.readFile(reportPath, "utf8")), report);
const manifest = JSON.parse(await fs.readFile(manifestPath, "utf8"));
assert.deepEqual({ schemaVersion: manifest.schemaVersion, task: manifest.task, parentTask: manifest.parentTask, nextTask: manifest.nextTask }, { schemaVersion: 1, task: "M13-04A", parentTask: "M13-03G", nextTask: "M13-04B" });
for (const artifact of Object.values(manifest.artifacts)) assert.equal(await hashFile(path.join(root, artifact.path)), artifact.sha256, `artifact hash mismatch ${artifact.path}`);
process.stdout.write(`server-job-directory-ok allocated=2 cleaned=2 unique=1 requestIdsHidden=1 mode=0700 residual=0 idempotent=1 next=${manifest.nextTask}\n`);
} finally {
await fs.rm(temporary, { recursive: true, force: true });
}