forgedock 1.66.0 → 1.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/config-schema.mjs +2 -0
- package/bin/engine/outcome-codes.mjs +1 -0
- package/bin/engine-cli.mjs +96 -17
- package/bin/forgedock.mjs +7 -0
- package/bin/help-text.mjs +3 -3
- package/bin/introspect-schedule.mjs +98 -0
- package/bin/introspect-schedule.test.mjs +67 -0
- package/bin/lean/advisory.test.mjs +49 -0
- package/bin/lean/amendment-schema.mjs +31 -0
- package/bin/lean/attempts.mjs +159 -0
- package/bin/lean/attempts.test.mjs +127 -0
- package/bin/lean/basered.mjs +55 -0
- package/bin/lean/basered.test.mjs +68 -1
- package/bin/lean/batch-health.mjs +3 -0
- package/bin/lean/batch-health.test.mjs +16 -0
- package/bin/lean/batch.mjs +45 -0
- package/bin/lean/batch.test.mjs +54 -3
- package/bin/lean/capwait.mjs +14 -3
- package/bin/lean/capwait.test.mjs +20 -0
- package/bin/lean/clear-breaker.mjs +14 -0
- package/bin/lean/commentstate.mjs +41 -0
- package/bin/lean/commentstate.test.mjs +32 -0
- package/bin/lean/concurrency.mjs +89 -0
- package/bin/lean/concurrency.test.mjs +113 -0
- package/bin/lean/conformance.e2e.test.mjs +4 -2
- package/bin/lean/conformance.mjs +35 -3
- package/bin/lean/conformance.test.mjs +52 -0
- package/bin/lean/efficiency.mjs +162 -0
- package/bin/lean/efficiency.test.mjs +79 -0
- package/bin/lean/execution.mjs +31 -13
- package/bin/lean/execution.test.mjs +46 -0
- package/bin/lean/failure-stop.mjs +46 -0
- package/bin/lean/failure-stop.test.mjs +45 -0
- package/bin/lean/fixtures/capacity-storm.json +609 -0
- package/bin/lean/lean.mjs +123 -24
- package/bin/lean/lean.test.mjs +137 -46
- package/bin/lean/liveness.mjs +37 -0
- package/bin/lean/liveness.test.mjs +33 -0
- package/bin/lean/orchestrate-attempts.test.mjs +74 -0
- package/bin/lean/orchestrate-pause.test.mjs +23 -0
- package/bin/lean/orchestrate-reconcile.test.mjs +147 -0
- package/bin/lean/orchestrate.mjs +170 -26
- package/bin/lean/phaseledger.mjs +6 -0
- package/bin/lean/phaseledger.test.mjs +13 -1
- package/bin/lean/prompts.mjs +6 -10
- package/bin/lean/reconcile.mjs +90 -0
- package/bin/lean/recurrence.mjs +38 -2
- package/bin/lean/recurrence.test.mjs +56 -1
- package/bin/lean/sandbox-remote.mjs +33 -2
- package/bin/lean/sched.mjs +19 -0
- package/bin/lean/sched.test.mjs +11 -1
- package/bin/lean/schedd-health.mjs +4 -4
- package/bin/lean/schedd-health.test.mjs +8 -4
- package/bin/lean/schedd.mjs +34 -2
- package/bin/lean/schedd.test.mjs +55 -2
- package/bin/lean/slo.mjs +126 -0
- package/bin/lean/slo.test.mjs +112 -0
- package/bin/lean/statuscomment.mjs +37 -0
- package/bin/lean/statuscomment.test.mjs +48 -1
- package/bin/lean/verify.mjs +2 -1
- package/bin/pool/agent.mjs +2 -2
- package/bin/pool/cli.mjs +16 -1
- package/bin/pool/lane-tools.mjs +21 -0
- package/bin/stats/attempts.mjs +54 -0
- package/bin/stats/attempts.test.mjs +30 -0
- package/bin/stats/churn.mjs +49 -0
- package/bin/stats/churn.test.mjs +31 -0
- package/bin/stats/index.mjs +11 -3
- package/commands/orchestrate.md +21 -18
- package/docs/OUTCOME-CODES.md +1 -0
- package/package.json +1 -1
- package/scripts/check-devdocs-freshness.sh +1 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// #5978: standing orders: selector join/leave, re-admission policy, env.* join, breaker auto-reset, staging-lane close, coverage.
|
|
4
|
+
import { describe, it } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { orchestrate } from "./orchestrate.mjs";
|
|
7
|
+
import { readmitDue, backoffMs, humanCode, environmentalDetail, closesManually, needsDecisionDigest, diffSelection, parseSelected, selectArgs, DEFER_CAP_MS, HELD_COOLDOWN_MS } from "./reconcile.mjs";
|
|
8
|
+
import { decideAutoReset } from "./clear-breaker.mjs";
|
|
9
|
+
import { coverage } from "./batch.mjs";
|
|
10
|
+
|
|
11
|
+
const harness = ({ script = {}, issues = [], reconcile, extra = {} }) => {
|
|
12
|
+
let t = 1_000_000;
|
|
13
|
+
const calls = [], decisions = [], updates = [];
|
|
14
|
+
return orchestrate({ issues, parallel: 2, readBody: async () => "", now: () => t, pollMs: 1000, reconcile, select: reconcile ? "no:milestone" : null,
|
|
15
|
+
sleep: async (ms) => { t += Math.max(1, Number(ms) || 0); },
|
|
16
|
+
runOne: async (n) => { calls.push(n); t += 1000; const l = script[n] ?? [{ terminalReason: "merged", pr: 1 }]; return l[Math.min(calls.filter((c) => c === n).length - 1, l.length - 1)]; },
|
|
17
|
+
decide: (d) => decisions.push(d), onUpdate: (r) => updates.push(r), ...extra }).then((rows) => ({ rows, calls, decisions, updates }));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const seeded = (results, more = {}) => ({ load: () => ({ v: 1, order: Object.keys(results).map(Number), pending: [], results, ...more }), save: () => {}, log: () => {} });
|
|
21
|
+
|
|
22
|
+
describe("selector reconcile (R2, R13)", () => {
|
|
23
|
+
it("a new matching issue joins within one interval, no operator command; a standing order ends only by stop", async () => {
|
|
24
|
+
let polls = 0;
|
|
25
|
+
const ac = new AbortController();
|
|
26
|
+
const list = async () => { polls++; if (polls >= 4) ac.abort(); return polls === 1 ? [{ number: 1 }] : [{ number: 1 }, { number: 2 }]; };
|
|
27
|
+
const r = await harness({ issues: [], reconcile: { everyMs: 5000, list }, extra: { signal: ac.signal } });
|
|
28
|
+
assert.deepEqual(r.calls.sort(), [1, 2]);
|
|
29
|
+
assert.ok(r.rows.every((x) => x.outcome === "merged"));
|
|
30
|
+
});
|
|
31
|
+
it("diffSelection joins matches and leaves closed pending issues, never running ones", () => {
|
|
32
|
+
const d = diffSelection({ open: [{ number: 5 }, { number: 6 }], members: [5, 7, 8], pending: [7], running: new Set([8]), results: new Map() });
|
|
33
|
+
assert.deepEqual(d, { join: [6], leave: [7] });
|
|
34
|
+
});
|
|
35
|
+
it("#6022 only a member the selector matched can leave: env.* issues, children, --add and argv members stay pending", () => {
|
|
36
|
+
const d = diffSelection({ open: [{ number: 5 }], members: [5, 7, 9], pending: [7, 9], running: new Set(), results: new Map(), matched: new Set([5, 7]) });
|
|
37
|
+
assert.deepEqual(d, { join: [], leave: [7] });
|
|
38
|
+
});
|
|
39
|
+
it("a failed read leaves nothing (parseSelected null)", () => {
|
|
40
|
+
assert.equal(parseSelected("not json"), null);
|
|
41
|
+
assert.deepEqual(parseSelected('[{"number":3,"labels":[{"name":"x"}]}]'), [{ number: 3, labels: ["x"] }]);
|
|
42
|
+
assert.ok(selectArgs("o/r", "no:milestone").includes("no:milestone"));
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe("re-admission policy (R5, R6, R8, R14)", () => {
|
|
47
|
+
const rows = (o) => new Map([[9, { issue: 9, outcome: o }]]);
|
|
48
|
+
it("deferred retries with exponential backoff capped at 2h", () => {
|
|
49
|
+
const state = new Map();
|
|
50
|
+
assert.equal(readmitDue({ results: rows("deferred"), state, now: 0 }).requeue.length, 0);
|
|
51
|
+
assert.equal(readmitDue({ results: rows("deferred"), state, now: backoffMs(0) }).requeue.length, 1);
|
|
52
|
+
assert.equal(backoffMs(30), DEFER_CAP_MS);
|
|
53
|
+
assert.ok(backoffMs(2) > backoffMs(1));
|
|
54
|
+
});
|
|
55
|
+
it("held / engine-error re-admit on a version change, or after the 6h cooldown", () => {
|
|
56
|
+
for (const o of ["held", "engine-error"]) {
|
|
57
|
+
const state = new Map();
|
|
58
|
+
readmitDue({ results: rows(o), state, now: 0, version: "1" });
|
|
59
|
+
assert.equal(readmitDue({ results: rows(o), state, now: 1000, version: "1" }).requeue.length, 0);
|
|
60
|
+
assert.equal(readmitDue({ results: rows(o), state, now: 2000, version: "2" }).requeue.length, 1);
|
|
61
|
+
const s2 = new Map();
|
|
62
|
+
readmitDue({ results: rows(o), state: s2, now: 0, version: "1" });
|
|
63
|
+
assert.equal(readmitDue({ results: rows(o), state: s2, now: HELD_COOLDOWN_MS, version: "1" }).requeue.length, 1);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
it("a human-coded needs-human is never re-admitted", () => {
|
|
67
|
+
const r = new Map([[4, { issue: 4, outcome: "needs-human", detail: "needs credentials for the payment API" }]]);
|
|
68
|
+
assert.equal(readmitDue({ results: r, state: new Map(), now: 0 }).requeue.length, 0);
|
|
69
|
+
assert.ok(humanCode({ outcome: "needs-human", detail: "product decision needed" }));
|
|
70
|
+
assert.ok(!humanCode({ outcome: "needs-human", detail: "tests failed on lint" })); // negative example
|
|
71
|
+
assert.ok(!humanCode({ outcome: "engine-error", detail: "customers table" }));
|
|
72
|
+
});
|
|
73
|
+
it("conformance: one more attempt after the base moves, then parked in one digest", () => {
|
|
74
|
+
const row = new Map([[7, { issue: 7, outcome: "needs-human", conformance: { failed: true } }]]);
|
|
75
|
+
const state = new Map();
|
|
76
|
+
assert.equal(readmitDue({ results: row, state, now: 0, base: "a" }).requeue.length, 0);
|
|
77
|
+
assert.equal(readmitDue({ results: row, state, now: 1, base: "a" }).requeue.length, 0);
|
|
78
|
+
assert.equal(readmitDue({ results: row, state, now: 2, base: "b" }).requeue.length, 1);
|
|
79
|
+
const again = readmitDue({ results: row, state, now: 3, base: "c" });
|
|
80
|
+
assert.equal(again.requeue.length, 0);
|
|
81
|
+
assert.deepEqual(again.parked.map((p) => p.issue), [7]);
|
|
82
|
+
assert.match(needsDecisionDigest(again.parked), /needs decision \(1\): #7/);
|
|
83
|
+
assert.equal(needsDecisionDigest([]), "");
|
|
84
|
+
});
|
|
85
|
+
it("runner requeues an ended held issue on a version change without an operator command", async () => {
|
|
86
|
+
let ver = "1", polls = 0;
|
|
87
|
+
const ac = new AbortController();
|
|
88
|
+
const r = await harness({ issues: [1], reconcile: { everyMs: 1000, version: () => ver, list: async () => { if (++polls === 3) ver = "2"; if (polls > 8) ac.abort(); return [{ number: 1 }]; } },
|
|
89
|
+
extra: { signal: ac.signal, store: seeded({ 1: { issue: 1, outcome: "held", detail: "x" } }) } });
|
|
90
|
+
assert.deepEqual(r.calls, [1]);
|
|
91
|
+
assert.ok(r.updates.some((u) => u.issue === 1 && u.outcome === "requeued"));
|
|
92
|
+
assert.equal(r.rows[0].outcome, "merged");
|
|
93
|
+
});
|
|
94
|
+
it("the env.* issue the engine filed joins the order", async () => {
|
|
95
|
+
const ac = new AbortController(); let polls = 0;
|
|
96
|
+
const r = await harness({ issues: [], reconcile: { everyMs: 1000, list: async () => { if (++polls > 3) ac.abort(); return []; } },
|
|
97
|
+
extra: { signal: ac.signal, store: seeded({}, { envSigs: { "env.tool:x": { issues: [1, 2], number: 77 } } }) } });
|
|
98
|
+
assert.deepEqual(r.calls, [77]);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe("breaker auto-reset (R9)", () => {
|
|
103
|
+
it("environmental signature + cooldown + healthy pool resets; anything else does not", () => {
|
|
104
|
+
const tripped = { at: 100 };
|
|
105
|
+
const base = { tripped, now: 100 + 1000, cooldownMs: 500, environmental: true, poolHealthy: true };
|
|
106
|
+
assert.equal(decideAutoReset(base).reset, true);
|
|
107
|
+
assert.equal(decideAutoReset({ ...base, environmental: false }).reset, false);
|
|
108
|
+
assert.equal(decideAutoReset({ ...base, now: 200 }).reset, false);
|
|
109
|
+
assert.equal(decideAutoReset({ ...base, poolHealthy: false }).reset, false);
|
|
110
|
+
assert.equal(decideAutoReset({ ...base, tripped: null }).reset, false);
|
|
111
|
+
});
|
|
112
|
+
it("environmental details are recognised; product failures are not", () => {
|
|
113
|
+
assert.ok(environmentalDetail("sandbox.lost: VM restart"));
|
|
114
|
+
assert.ok(environmentalDetail("mirror fetch ETIMEDOUT"));
|
|
115
|
+
assert.ok(!environmentalDetail("assertion failed in foo.test.mjs"));
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe("staging lane close (R11)", () => {
|
|
120
|
+
it("only a merge into a non-default staging/milestone lane closes by hand", () => {
|
|
121
|
+
assert.ok(closesManually("staging"));
|
|
122
|
+
assert.ok(closesManually("milestone/v2"));
|
|
123
|
+
assert.ok(!closesManually("main"));
|
|
124
|
+
assert.ok(!closesManually(""));
|
|
125
|
+
});
|
|
126
|
+
it("the runner closes the issue after a merge into a staging lane", async () => {
|
|
127
|
+
const closed = [];
|
|
128
|
+
let polls = 0;
|
|
129
|
+
const ac = new AbortController();
|
|
130
|
+
await harness({ issues: [3], script: { 3: [{ terminalReason: "merged", pr: 1, lane: "staging" }] },
|
|
131
|
+
reconcile: { everyMs: 1000, list: async () => { if (++polls > 2) ac.abort(); return [{ number: 3 }]; }, closeIssue: async (n, o) => closed.push([n, o.lane]) },
|
|
132
|
+
extra: { signal: ac.signal } }).catch(() => null);
|
|
133
|
+
assert.deepEqual(closed, [[3, "staging"]]);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe("--status coverage (R12, R16)", () => {
|
|
138
|
+
it("0 unscheduled when each open match is running/queued/backing-off/waiting/human-blocked", () => {
|
|
139
|
+
const state = { pending: [2, 3, 4], running: { 1: {} }, notBefore: { 3: 9e15 }, deps: { 4: [2] }, results: { 5: { outcome: "needs-human", detail: "needs credentials" }, 6: { outcome: "deferred" } }, readmit: { 6: {} } };
|
|
140
|
+
const c = coverage({ state, open: [1, 2, 3, 4, 5, 6].map((number) => ({ number })), now: 1 });
|
|
141
|
+
assert.deepEqual([c.running, c.queued, c.backingOff, c.waitingDeps, c.humanBlocked, c.unscheduled], [[1], [2], [3, 6], [4], [5], []]);
|
|
142
|
+
});
|
|
143
|
+
it("a match nobody will run is unscheduled", () => {
|
|
144
|
+
const c = coverage({ state: { pending: [], results: { 8: { outcome: "needs-human", detail: "tests failed" } } }, open: [{ number: 8 }, { number: 9 }] });
|
|
145
|
+
assert.deepEqual(c.unscheduled, [8, 9]);
|
|
146
|
+
});
|
|
147
|
+
});
|