Public: anyone can read this; the crew can change it.

The weekly production probe fails when /changelog.atom has no entries and files the defect with the byte count it saw #13083

opened this

Parked 17d 11h ago

scout/forge:scout/13072-the-weekly-production-probe-fails-when-c → main 3 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
3 files changed +46 −4
src/core/v1_proof.ts +14
@@ -187,6 +187,20 @@ export const probes: readonly Probe[] = [
187187 return "/api/v1/health: no schedule is overdue";
188188 },
189189 },
190 {
191 issue: 13072,
192 item: "the changelog feed has at least one entry",
193 run: async (get) => {
194 const started = performance.now();
195 const got = await get("/changelog.atom");
196 const ms = Math.round(performance.now() - started);
197 // What a defect filed from this line needs: where, what status, how many bytes, how long.
198 const seen = `/changelog.atom: status ${got.status}, ${new TextEncoder().encode(got.text).length} bytes, ${ms} ms`;
199 expect(got.status === 200, `${seen}; not 200`);
200 expect(/<entry[\s>]/.test(got.text), `${seen}; the feed has no <entry>`);
201 return `${seen}; it has an entry`;
202 },
203 },
190204 {
191205 issue: 10441,
192206 item: "the security headers are on the page and on a machine answer",
test/security-floor-paths.test.ts +14
@@ -18,6 +18,8 @@ import { afterAll, beforeAll, expect, test } from "bun:test";
1818 import { newApp } from "../src/actions/apps.ts";
1919 import type { EnvStatus } from "../src/apps/runtime.ts";
2020 import type { AppRecord } from "../src/core/apps.ts";
21 import { createRepo } from "../src/actions/repos.ts";
22 import { keepLive } from "../src/release/landings.ts";
2123 import { line, prove } from "../src/core/v1_proof.ts";
2224 import {
2325 fetchAsHost,
@@ -209,6 +211,18 @@ test("the proxy's 304 of an app's page keeps the headers the app's 200 left with
209211 });
210212
211213 test("`bun scripts/v1-proven.ts`'s proof passes 20 times in a row against a booted forge", async () => {
214 // A fresh forge has shipped nothing; the proof wants one entry in the changelog feed
215 // (#13072).
216 const repo = await createRepo(forge.app, forge.alice, { name: "forge", visibility: "public" });
217 if (!repo.ok) throw new Error(String(repo.error));
218 forge.app.db.query(
219 `INSERT INTO issue (id, repo_id, number, kind, title, author_id, state) VALUES ('shipped', ?1, 1, 'pull', 'Shipped', ?2, 'closed')`,
220 ).run(repo.value.id, forge.alice.id);
221 forge.app.db.query(
222 `INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, merged_at, merged_oid) VALUES ('shipped', ?1, 'b', 'base', '', '2026-10-01T10:00:00.000Z', 'oid-live')`,
223 ).run(repo.value.defaultBranch);
224 keepLive(forge.app.db, "alice/forge", ["oid-live"], 0);
225 (forge.app.config as { forgeRepo?: string }).forgeRepo = "alice/forge";
212226 const failed: string[] = [];
213227 for (let run = 0; run < 20; run++)
214228 for (const r of await prove(forge.servers.url, fetch))
test/v1-proven.test.ts +18 −4
@@ -27,6 +27,9 @@ const rule = (days: number, words = days) =>
2727 const health = (schedules?: unknown) =>
2828 Response.json({ ok: true, version: "1.0.0", commit: "058b6cf", draining: false, ...(schedules === undefined ? {} : { schedules }) });
2929
30 const FEED_WITH_ENTRY = '<?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom"><title>t</title><entry><title>v1</title></entry></feed>';
31 const FEED_EMPTY = '<?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom"><title>t</title></feed>';
32
3033 type Over = Record<string, () => Response>;
3134 function stub(over: Over = {}, seen: string[] = []): Fetch {
3235 const routes: Over = {
@@ -41,6 +44,7 @@ function stub(over: Over = {}, seen: string[] = []): Fetch {
4144 "/settings/billing": () => new Response(null, { status: 303, headers: { location: "/signin?next=%2Fsettings%2Fbilling" } }),
4245 "/settings/crew": () => new Response(null, { status: 303, headers: { location: "/signin?next=%2Fsettings%2Fcrew" } }),
4346 "/api/v1/health": () => health({ overdue: 0, oldestSeconds: 0 }),
47 "/changelog.atom": () => new Response(FEED_WITH_ENTRY),
4448 ...over,
4549 };
4650 return async (url, init) => {
@@ -54,9 +58,9 @@ describe("v1-proven", () => {
5458 test("every list item has a probe, and all pass on a healthy forge", async () => {
5559 const results = await prove("https://f.test/", stub());
5660 expect(results.map((r) => r.issue).sort()).toEqual(
57 [11541, 11539, 11158, 11573, 10304, 11507, 11138, 11140, 11141, 11515, 11595, 10441].sort(),
61 [11541, 11539, 11158, 11573, 10304, 11507, 11138, 11140, 11141, 11515, 11595, 10441, 13072].sort(),
5862 );
59 expect(probes.length).toBe(12);
63 expect(probes.length).toBe(13);
6064 const status = (n: number) => results.find((r) => r.issue === n)?.status;
6165 // What no public read can show is unproven, never a pass.
6266 expect(results.filter((r) => r.status === "unproven").map((r) => r.issue).sort()).toEqual([]);
@@ -92,6 +96,8 @@ describe("v1-proven", () => {
9296 [11141, { "/pricing": pricing(ldWith(props().slice(0, 2))) }, [11141]],
9397 [11515, { "/settings/crew": () => new Response("x", { status: 500 }) }, [11515]],
9498 [11595, { "/api/v1/health": () => health({ overdue: 2, oldestSeconds: 86_400 }) }, [11595]],
99 [13072, { "/changelog.atom": () => new Response(FEED_EMPTY) }, [13072]],
100 [13072, { "/changelog.atom": () => new Response("gone", { status: 404 }) }, [13072]],
95101 [10441, { "/healthz": () => new Response("ok") }, [10441]],
96102 ];
97103 for (const [issue, over, expected] of breaks)
@@ -103,6 +109,14 @@ describe("v1-proven", () => {
103109 expect(line(results.find((r) => r.issue === issue)!)).toStartWith(`fail #${issue}`);
104110 });
105111
112 test("an empty changelog feed fails with its URL, status, bytes and time; a populated one passes", async () => {
113 const empty = (await prove("https://f.test", stub({ "/changelog.atom": () => new Response(FEED_EMPTY) }))).find((x) => x.issue === 13072)!;
114 expect(empty.status).toBe("fail");
115 expect(empty.detail).toMatch(new RegExp(`^/changelog\\.atom: status 200, ${FEED_EMPTY.length} bytes, \\d+ ms; the feed has no <entry>$`));
116 const full = (await prove("https://f.test", stub())).find((x) => x.issue === 13072)!;
117 expect(full.status).toBe("pass");
118 });
119
106120 test("the schedule probe fails naming the oldest age, is unproven without the field, and a network error is a fail", async () => {
107121 const late = (await prove("https://f.test", stub({ "/api/v1/health": () => health({ overdue: 2, oldestSeconds: 3 * 3600 + 720 }) }))).find((x) => x.issue === 11595)!;
108122 expect(line(late)).toBe("fail #11595 no schedule is past its period: 2 schedule(s) overdue, the oldest by 3 h 12 min");
@@ -137,7 +151,7 @@ describe("v1-proven", () => {
137151 const { code, out } = await run(async () => new Response("down", { status: 503 }));
138152 expect(code).toBe(1);
139153 expect(out).toContain("fail #11539");
140 expect(out).toContain("v1.0.0 is not proven: 12 of 12 fail, 0 unproven");
154 expect(out).toContain("v1.0.0 is not proven: 13 of 13 fail, 0 unproven");
141155 });
142156
143157 test("the script exits 3, not 0, when nothing fails but some items are unproven", async () => {
@@ -145,7 +159,7 @@ describe("v1-proven", () => {
145159 expect(out).not.toContain("fail #");
146160 expect(code).toBe(3);
147161 expect(out).toContain("unproven #11595");
148 expect(out).toContain("v1.0.0 is not proven: none fail, 1 of 12 unproven");
162 expect(out).toContain("v1.0.0 is not proven: none fail, 1 of 13 unproven");
149163 });
150164
151165 test("the script exits 2 on bad usage", () => {

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs