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 #13104

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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

  • Merged. torque/13072-the-weekly-production-probe-fails-when-c was merged into main as 6b4948a.

Review

Sign in to review this change.
3 files changed +35 −6
src/core/v1_proof.ts +15
@@ -202,6 +202,21 @@ export const probes: readonly Probe[] = [
202202 return "/api/v1/health: no schedule is overdue";
203203 },
204204 },
205 {
206 issue: 13072,
207 item: "the changelog feed has at least one entry",
208 // The failure names what was seen (URL, status, bytes) so the defect filed from it
209 // carries them.
210 run: async (get) => {
211 const path = "/changelog.atom";
212 const got = await get(path);
213 const bytes = new TextEncoder().encode(got.text).length;
214 expect(got.status === 200, `${path} answers ${got.status}, not 200 (${bytes} bytes)`);
215 const entries = (got.text.match(/<entry[\s>]/g) ?? []).length;
216 expect(entries > 0, `${path} answers ${got.status} with no <entry> in ${bytes} bytes`);
217 return `${path} carries ${entries} entr${entries === 1 ? "y" : "ies"} (${bytes} bytes)`;
218 },
219 },
205220 {
206221 issue: 10441,
207222 item: "the security headers are on the page and on a machine answer",
test/security-floor-paths.test.ts +3 −2
@@ -213,7 +213,8 @@ test("`bun scripts/v1-proven.ts`'s proof passes 20 times in a row against a boot
213213 for (let run = 0; run < 20; run++)
214214 for (const r of await prove(forge.servers.url, fetch))
215215 // A test forge is built from no release, so the two probes that read the release
216 // (#10304, #13042) have nothing to read; every other probe must pass.
217 if (r.status !== "pass" && r.issue !== 10304 && r.issue !== 13042) failed.push(`run ${run}: ${line(r)}`);
216 // (#10304, #13042) have nothing to read, and it has shipped nothing, so its changelog feed
217 // (#13072) has no entry; every other probe must pass.
218 if (r.status !== "pass" && ![10304, 13042, 13072].includes(r.issue)) failed.push(`run ${run}: ${line(r)}`);
218219 expect(failed).toEqual([]);
219220 }, 60_000);
test/v1-proven.test.ts +17 −4
@@ -27,6 +27,7 @@ const rule = (days: number, words = days) =>
2727 const health = (schedules?: unknown, ver = "1.0.0") =>
2828 Response.json({ ok: true, version: ver, commit: "058b6cf", draining: false, ...(schedules === undefined ? {} : { schedules }) });
2929
30 const FEED = '<?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom"><title>Changelog</title><entry><id>x</id></entry></feed>';
3031 type Over = Record<string, () => Response>;
3132 function stub(over: Over = {}, seen: string[] = []): Fetch {
3233 const routes: Over = {
@@ -40,6 +41,7 @@ function stub(over: Over = {}, seen: string[] = []): Fetch {
4041 "/settings/billing": () => new Response(null, { status: 303, headers: { location: "/signin?next=%2Fsettings%2Fbilling" } }),
4142 "/settings/crew": () => new Response(null, { status: 303, headers: { location: "/signin?next=%2Fsettings%2Fcrew" } }),
4243 "/api/v1/health": () => health({ overdue: 0, oldestSeconds: 0 }),
44 "/changelog.atom": () => new Response(FEED),
4345 ...over,
4446 };
4547 return async (url, init) => {
@@ -53,9 +55,9 @@ describe("v1-proven", () => {
5355 test("every list item has a probe, and all pass on a healthy forge", async () => {
5456 const results = await prove("https://f.test/", stub());
5557 expect(results.map((r) => r.issue).sort()).toEqual(
56 [11541, 11539, 11158, 11573, 10304, 13042, 11507, 11138, 11140, 11141, 11515, 11595, 10441].sort(),
58 [11541, 11539, 11158, 11573, 10304, 13042, 11507, 11138, 11140, 11141, 11515, 11595, 13072, 10441].sort(),
5759 );
58 expect(probes.length).toBe(13);
60 expect(probes.length).toBe(14);
5961 const status = (n: number) => results.find((r) => r.issue === n)?.status;
6062 // What no public read can show is unproven, never a pass.
6163 expect(results.filter((r) => r.status === "unproven").map((r) => r.issue).sort()).toEqual([]);
@@ -98,6 +100,8 @@ describe("v1-proven", () => {
98100 [11141, { "/pricing": pricing(ldWith(props().slice(0, 2))) }, [11141]],
99101 [11515, { "/settings/crew": () => new Response("x", { status: 500 }) }, [11515]],
100102 [11595, { "/api/v1/health": () => health({ overdue: 2, oldestSeconds: 86_400 }) }, [11595]],
103 [13072, { "/changelog.atom": () => new Response('<feed xmlns="http://www.w3.org/2005/Atom"><title>Changelog</title></feed>') }, [13072]],
104 [13072, { "/changelog.atom": () => new Response("down", { status: 503 }) }, [13072]],
101105 [10441, { "/healthz": () => new Response("ok") }, [10441]],
102106 ];
103107 for (const [issue, over, expected] of breaks)
@@ -124,6 +128,15 @@ describe("v1-proven", () => {
124128 expect(all.every((r) => r.status === "fail")).toBe(true);
125129 });
126130
131 test("an empty feed fails naming URL, status and bytes; a populated one passes", async () => {
132 const empty = '<feed xmlns="http://www.w3.org/2005/Atom"><title>Changelog</title></feed>';
133 const bad = (await prove("https://f.test", stub({ "/changelog.atom": () => new Response(empty) }))).find((x) => x.issue === 13072)!;
134 expect(line(bad)).toBe(`fail #13072 the changelog feed has at least one entry: /changelog.atom answers 200 with no <entry> in ${empty.length} bytes`);
135 const ok = (await prove("https://f.test", stub())).find((x) => x.issue === 13072)!;
136 expect(ok.status).toBe("pass");
137 expect(ok.detail).toBe(`/changelog.atom carries 1 entry (${FEED.length} bytes)`);
138 });
139
127140 test("an age reads in the unit a person would use", () => {
128141 expect([ageWords(45), ageWords(600), ageWords(3 * 3600 + 720), ageWords(3 * 86_400 + 7200)]).toEqual(["45 s", "10 min", "3 h 12 min", "3 d 2 h"]);
129142 });
@@ -143,7 +156,7 @@ describe("v1-proven", () => {
143156 const { code, out } = await run(async () => new Response("down", { status: 503 }));
144157 expect(code).toBe(1);
145158 expect(out).toContain("fail #11539");
146 expect(out).toContain("v1.0.0 is not proven: 13 of 13 fail, 0 unproven");
159 expect(out).toContain("v1.0.0 is not proven: 14 of 14 fail, 0 unproven");
147160 });
148161
149162 test("the script exits 3, not 0, when nothing fails but some items are unproven", async () => {
@@ -151,7 +164,7 @@ describe("v1-proven", () => {
151164 expect(out).not.toContain("fail #");
152165 expect(code).toBe(3);
153166 expect(out).toContain("unproven #11595");
154 expect(out).toContain("v1.0.0 is not proven: none fail, 1 of 13 unproven");
167 expect(out).toContain("v1.0.0 is not proven: none fail, 1 of 14 unproven");
155168 });
156169
157170 test("the script exits 2 on bad usage", () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs