PEP-233: сторож не обрывает задания, PR без проверок не держит очередь
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
124e910511
commit
90bbc62e5d
@ -1,12 +1,12 @@
|
||||
## 1. Сторож
|
||||
- [ ] 1.1 `actRunnerTick`: не перезапускать при контейнерах `GITEA-ACTIONS-TASK-*` (и при ошибке `docker ps`)
|
||||
- [ ] 1.2 `hung` только по головам, увиденным после прошлого перезапуска; сироты не в счёт
|
||||
- [ ] 1.3 Тесты `act-runner.test.ts`: идут задания — не трогаем; та же голова — один перезапуск; новая голова — снова
|
||||
- [x] 1.1 `actRunnerTick`: не перезапускать при контейнерах `GITEA-ACTIONS-TASK-*` (и при ошибке `docker ps`)
|
||||
- [x] 1.2 `hung` только по головам, увиденным после прошлого перезапуска; сироты не в счёт
|
||||
- [x] 1.3 Тесты `act-runner.test.ts`: идут задания — не трогаем; та же голова — один перезапуск; новая голова — снова
|
||||
|
||||
## 2. Очередь
|
||||
- [ ] 2.1 `checksQueueTick`: причина `no_workflow`, сироты (`no_workflow` или старше 2 суток) не в очереди
|
||||
- [ ] 2.2 Задержка и одно сообщение на сироту, агенту без workflow — подсказка один раз
|
||||
- [ ] 2.3 Тесты `platform-delays.test.ts`: без workflow — очередь не стоит; старше 2 суток — очередь снята
|
||||
- [x] 2.1 `checksQueueTick`: причина `no_workflow`, сироты (`no_workflow` или старше 2 суток) не в очереди
|
||||
- [x] 2.2 Задержка и одно сообщение на сироту, агенту без workflow — подсказка один раз
|
||||
- [x] 2.3 Тесты `platform-delays.test.ts`: без workflow — очередь не стоит; старше 2 суток — очередь снята
|
||||
|
||||
## 3. Завершение
|
||||
- [ ] 3.1 Проверки (lint, typecheck, тесты), память, archive, PR
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
// PEP-205: the checks executor (Gitea Actions `peppa-act-runner`, a docker container) is under the
|
||||
// watchdog's eye: if it is down it is started again; if it is up but nobody takes the jobs of a
|
||||
// standing checks queue (no job at all on the heads), it is restarted once per half hour.
|
||||
// PEP-233: never while jobs run (their containers `GITEA-ACTIONS-TASK-*` are up — a restart would
|
||||
// cut them, a deploy half-done), and only for a head first seen after the last restart: the same
|
||||
// standing head restarts the executor once, a new one is a new sign. Heads without a workflow or
|
||||
// older than two days are not the executor's fault (`checksQueueTick` marks them `orphan`).
|
||||
// Every restart is an event in the platform project's journal.
|
||||
// glossary-ignore-file: events here are read by the superadmin.
|
||||
import { execFile } from "node:child_process";
|
||||
import { promisify } from "node:util";
|
||||
import { getSetting, listProjects, logEvent, setSetting } from "@peppa/core";
|
||||
import { settings, type Db, keyPrefix } from "@peppa/db";
|
||||
import { like } from "drizzle-orm";
|
||||
import { platformKey } from "./platform-release.ts";
|
||||
|
||||
const run = promisify(execFile);
|
||||
@ -17,6 +20,18 @@ const RESTART_KEY = "actrunner.restarted";
|
||||
/** A head without any job this long (after the stuck threshold) — the executor does not take jobs. */
|
||||
const HUNG_AFTER_MS = 10 * 60_000;
|
||||
const RESTART_GAP_MS = 30 * 60_000;
|
||||
/** PEP-233: the containers act_runner starts for jobs. */
|
||||
const JOB_PREFIX = "GITEA-ACTIONS-TASK-";
|
||||
|
||||
/** PEP-233: jobs run on the host's docker (or we can't tell — then we don't cut anything). */
|
||||
async function jobsRunning(): Promise<boolean> {
|
||||
try {
|
||||
const out = (await run(docker(), ["ps", "--format", "{{.Names}}"], { timeout: 20_000 })).stdout;
|
||||
return out.split("\n").some((l) => l.split("\t").some((f) => f.trim().startsWith(JOB_PREFIX)));
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export type ActRunnerRestart = "down" | "hung";
|
||||
|
||||
@ -35,10 +50,10 @@ export async function actRunnerTick(db: Db, o: { now?: Date; log?: (m: string) =
|
||||
if (!reason && now - last >= RESTART_GAP_MS) {
|
||||
const waits = await db.select().from(settings).where(keyPrefix(settings.key, "checks.wait:"));
|
||||
const hung = waits.some((w) => {
|
||||
const v = w.value as { stuck?: boolean; cause?: string; since: number };
|
||||
return v.stuck && v.cause === "no_job" && now - v.since >= HUNG_AFTER_MS;
|
||||
const v = w.value as { stuck?: boolean; cause?: string; since: number; orphan?: boolean };
|
||||
return v.stuck && !v.orphan && v.cause === "no_job" && v.since >= last && now - v.since >= HUNG_AFTER_MS;
|
||||
});
|
||||
if (hung) reason = "hung";
|
||||
if (hung && !(await jobsRunning())) reason = "hung";
|
||||
}
|
||||
if (!reason) return null;
|
||||
if (reason === "down" && now - last < 60_000) return null;
|
||||
|
||||
@ -65,8 +65,14 @@ interface ChecksWait {
|
||||
/** PEP-205: how many times Peppa reopened the PR to start the job again for this head, and when last (ms). */
|
||||
reopened?: number;
|
||||
reopenedAt?: number;
|
||||
/** PEP-233: not the queue — no workflow in the head, or it stands longer than `ORPHAN_AFTER_MS`; its own delay is set. */
|
||||
orphan?: boolean;
|
||||
}
|
||||
export type StuckCause = "job_failed" | "queue" | "no_job";
|
||||
export type StuckCause = "job_failed" | "queue" | "no_job" | "no_workflow";
|
||||
/** PEP-233: the workflow the template (and `peppa ci connect`) puts into a project. */
|
||||
const CI_WORKFLOW = ".gitea/workflows/ci.yml";
|
||||
/** PEP-233: a head waiting longer than this is an abandoned story, not the queue. */
|
||||
const ORPHAN_AFTER_MS = 2 * 24 * 3600_000;
|
||||
/** PEP-205: reopening a PR re-runs a workflow that fell before the checks (DNS hiccup on `git clone`): twice per head, 10 min apart. */
|
||||
const REOPEN_MAX = 2;
|
||||
const REOPEN_GAP_MS = 10 * 60_000;
|
||||
@ -79,7 +85,9 @@ async function stuckCause(gitea: GiteaClient, o: string, r: string, sha: string)
|
||||
const others = (st?.statuses ?? []).filter((x) => !x.context.startsWith("peppa/"));
|
||||
if (others.some((x) => x.status === "failure" || x.status === "error")) return "job_failed";
|
||||
if (others.some((x) => x.status === "pending")) return "queue";
|
||||
return "no_job";
|
||||
// PEP-233: nothing to run in this head — no job will ever come (Gitea unreachable → unknown, as before).
|
||||
const wf = await gitea.fileText(o, r, CI_WORKFLOW, sha).catch(() => "");
|
||||
return wf == null ? "no_workflow" : "no_job";
|
||||
}
|
||||
|
||||
const causeText = (c: StuckCause | undefined) =>
|
||||
@ -87,7 +95,9 @@ const causeText = (c: StuckCause | undefined) =>
|
||||
? m("задание упало до проверок (сбой связи на сервере)")
|
||||
: c === "queue"
|
||||
? m("очередь заданий растёт, исполнитель не успевает")
|
||||
: m("исполнитель не взял задание или вебхук не дошёл");
|
||||
: c === "no_workflow"
|
||||
? m("в изменениях нет описания проверок")
|
||||
: m("исполнитель не взял задание или вебхук не дошёл");
|
||||
const WAIT_PREFIX = "checks.wait:";
|
||||
const waitKey = (taskId: number) => `${WAIT_PREFIX}${taskId}`;
|
||||
const QUEUE = "checks.queue";
|
||||
@ -104,12 +114,13 @@ async function dropWait(db: Db, projectId: number, taskId: number, w: ChecksWait
|
||||
* line, its agent is told to wait (once), the superadmin gets one message for the whole
|
||||
* queue. Statuses appeared → the delay is lifted; all green → the agent is woken.
|
||||
*/
|
||||
export async function checksQueueTick(db: Db, o: { stuckMin: number; now?: Date; gitea?: GiteaClient; log?: Log }): Promise<{ stuck: number }> {
|
||||
export async function checksQueueTick(db: Db, o: { stuckMin: number; now?: Date; gitea?: GiteaClient; log?: Log }): Promise<{ stuck: number; orphans: number }> {
|
||||
const log = o.log ?? (() => {});
|
||||
const now = (o.now ?? new Date()).getTime();
|
||||
const seen = new Set<number>();
|
||||
const fresh: Array<{ projectId: number; taskId: number; key: string; sessionId: number | null }> = [];
|
||||
let stuck = 0;
|
||||
let orphans = 0;
|
||||
let oldest = now;
|
||||
const causes = new Map<StuckCause, number>();
|
||||
const stuckKeys: string[] = [];
|
||||
@ -132,18 +143,35 @@ export async function checksQueueTick(db: Db, o: { stuckMin: number; now?: Date;
|
||||
if (prev && prev.sha !== sha && prev.stuck) await clearPlatformDelay(db, { projectId: t.projectId, taskId: t.id }, "checks");
|
||||
const session = (await listSessions(db, { active: true, taskId: t.id }))[0] ?? null;
|
||||
if (gate.summary.state === "none") {
|
||||
if (!w.stuck && now - w.since >= o.stuckMin * 60_000) {
|
||||
w = { ...w, stuck: true };
|
||||
fresh.push({ projectId: t.projectId, taskId: t.id, key: ref.key, sessionId: session?.id ?? null });
|
||||
if (session && !w.told) {
|
||||
await sendToSession(db, session.id, `Проверки PR ${ref.key} ещё не стартовали: очередь на стороне Пеппы, администратор уже знает. Не пушь пустых коммитов для перезапуска и не спрашивай PM — закончи ход и жди: Пеппа разбудит тебя, когда проверки пройдут.`).then(() => (w = { ...w, told: true }), () => {});
|
||||
}
|
||||
}
|
||||
if (w.stuck) {
|
||||
const gt = o.gitea ?? giteaForBot();
|
||||
const late = !w.stuck && now - w.since >= o.stuckMin * 60_000;
|
||||
if (late || w.stuck) {
|
||||
// PEP-205: why it stands; a job that fell before the checks is started again by reopening the PR.
|
||||
const gt = o.gitea ?? giteaForBot();
|
||||
const cause = await stuckCause(gt, ref.project.giteaOwner, ref.project.giteaRepo, sha);
|
||||
w = { ...w, cause };
|
||||
// PEP-233: no workflow, or standing for days — not the queue: its own delay, the queue does not stand for it.
|
||||
const orphan = cause === "no_workflow" || now - w.since >= ORPHAN_AFTER_MS;
|
||||
w = { ...w, stuck: true, cause };
|
||||
if (orphan) {
|
||||
if (!w.orphan) {
|
||||
w = { ...w, orphan: true };
|
||||
const why = cause === "no_workflow" ? causeText(cause) : m("ждёт больше двух суток");
|
||||
await platformDelay(db, { projectId: t.projectId, taskId: t.id, sessionId: session?.id ?? null }, { reason: "checks", state: `orphan:${sha}`, details: `${m("⏳ Проверки задачи {key} не стартуют, в очередь не считается:", { key: ref.key })} ${why}`, alertKey: `checks-orphan:${t.id}:${sha}`, now: new Date(now), log });
|
||||
if (session && !w.told && cause === "no_workflow") {
|
||||
await sendToSession(db, session.id, `Проверки PR ${ref.key} не стартуют: в головном коммите нет ${CI_WORKFLOW}. Обнови ветку от основной (merge или rebase на свежую основную ветку) и запушь — проверки пойдут сами.`).then(() => (w = { ...w, told: true }), () => {});
|
||||
}
|
||||
log(`${ref.key}: checks never start (${cause === "no_workflow" ? "no workflow" : "stands for days"}) — not counted as the queue`);
|
||||
}
|
||||
orphans++;
|
||||
await setSetting(db, waitKey(t.id), w);
|
||||
continue;
|
||||
}
|
||||
if (w.orphan) w = { ...w, orphan: false };
|
||||
if (late) {
|
||||
fresh.push({ projectId: t.projectId, taskId: t.id, key: ref.key, sessionId: session?.id ?? null });
|
||||
if (session && !w.told) {
|
||||
await sendToSession(db, session.id, `Проверки PR ${ref.key} ещё не стартовали: очередь на стороне Пеппы, администратор уже знает. Не пушь пустых коммитов для перезапуска и не спрашивай PM — закончи ход и жди: Пеппа разбудит тебя, когда проверки пройдут.`).then(() => (w = { ...w, told: true }), () => {});
|
||||
}
|
||||
}
|
||||
if (cause === "job_failed" && (w.reopened ?? 0) < REOPEN_MAX && now - (w.reopenedAt ?? 0) >= REOPEN_GAP_MS) {
|
||||
const done = await gt.closePullRequest(ref.project.giteaOwner, ref.project.giteaRepo, pull.number).then(() => gt.reopenPullRequest(ref.project.giteaOwner, ref.project.giteaRepo, pull.number)).then(() => true, () => false);
|
||||
w = { ...w, reopened: (w.reopened ?? 0) + (done ? 1 : 0), reopenedAt: now };
|
||||
@ -190,7 +218,7 @@ export async function checksQueueTick(db: Db, o: { stuckMin: number; now?: Date;
|
||||
}
|
||||
if (!stuck) {
|
||||
await deleteSetting(db, QUEUE);
|
||||
return { stuck };
|
||||
return { stuck, orphans };
|
||||
}
|
||||
const queue = (await getSetting<{ since: number; win?: number }>(db, QUEUE)) ?? { since: now };
|
||||
const win = Math.floor((now - queue.since) / QUEUE_REPEAT_MS);
|
||||
@ -205,7 +233,7 @@ export async function checksQueueTick(db: Db, o: { stuckMin: number; now?: Date;
|
||||
else await alertAdmins(db, `checks:${queue.since}:w${win}`, details, log);
|
||||
log(`checks queue: ${stuck} waiting, oldest ${Math.round((now - oldest) / 60_000)} min`);
|
||||
} else if (!(await getSetting(db, QUEUE))) await setSetting(db, QUEUE, { since: queue.since, win: 0 });
|
||||
return { stuck };
|
||||
return { stuck, orphans };
|
||||
}
|
||||
|
||||
// ── stale cards ────────────────────────────────────────────────────────────────────
|
||||
|
||||
@ -473,6 +473,9 @@ export const runner: Dict = {
|
||||
"задание упало до проверок (сбой связи на сервере)": "the job fell before the checks (a network failure on the server)",
|
||||
"очередь заданий растёт, исполнитель не успевает": "the job queue is growing, the executor cannot keep up",
|
||||
"исполнитель не взял задание или вебхук не дошёл": "the executor did not take the job or the webhook did not arrive",
|
||||
"в изменениях нет описания проверок": "the changes have no checks workflow",
|
||||
"ждёт больше двух суток": "has been waiting for more than two days",
|
||||
"⏳ Проверки задачи {key} не стартуют, в очередь не считается:": "⏳ Checks of {key} do not start, not counted as the queue:",
|
||||
"{who}: агент не смог войти в аккаунт — сбой связи, повторим сами.": "{who}: the agent could not sign in to the account — a network failure, we will retry by ourselves.",
|
||||
"🔑 Подписка «{name}»: проблема со входом — агент {n} раза подряд не смог войти в аккаунт. Агенты переезжают на другую подписку набора; эту проверьте в «Подписках».": "🔑 Subscription “{name}”: sign-in problem — the agent failed to sign in {n} times in a row. The agents move to another subscription of the set; check this one in “Subscriptions”.",
|
||||
"{who}: агент не может войти в аккаунт, другой подписки в наборе нет.": "{who}: the agent cannot sign in to the account, and there is no other subscription in the set.",
|
||||
|
||||
@ -381,6 +381,9 @@ export const runner: Dict = {
|
||||
"задание упало до проверок (сбой связи на сервере)": "тапсырма тексерулерге дейін құлады (серверде байланыс ақауы)",
|
||||
"очередь заданий растёт, исполнитель не успевает": "тапсырмалар кезегі өсіп жатыр, орындаушы үлгермей жатыр",
|
||||
"исполнитель не взял задание или вебхук не дошёл": "орындаушы тапсырманы алмады немесе вебхук жетпеді",
|
||||
"в изменениях нет описания проверок": "өзгерістерде тексерулер сипаттамасы жоқ",
|
||||
"ждёт больше двух суток": "екі тәуліктен артық күтіп тұр",
|
||||
"⏳ Проверки задачи {key} не стартуют, в очередь не считается:": "⏳ {key} тапсырмасының тексерулері басталмайды, кезекке саналмайды:",
|
||||
"{who}: агент не смог войти в аккаунт — сбой связи, повторим сами.": "{who}: агент аккаунтқа кіре алмады — байланыс ақауы, өзіміз қайталаймыз.",
|
||||
"🔑 Подписка «{name}»: проблема со входом — агент {n} раза подряд не смог войти в аккаунт. Агенты переезжают на другую подписку набора; эту проверьте в «Подписках».": "🔑 «{name}» жазылымы: кіру мәселесі — агент аккаунтқа қатарынан {n} рет кіре алмады. Агенттер жиынтықтағы басқа жазылымға көшеді; бұны «Жазылымдар» бөлімінде тексеріңіз.",
|
||||
"{who}: агент не может войти в аккаунт, другой подписки в наборе нет.": "{who}: агент аккаунтқа кіре алмайды, жиынтықта басқа жазылым жоқ.",
|
||||
|
||||
@ -57,4 +57,41 @@ describe("Исполнитель проверок под присмотром",
|
||||
assert.equal(restarts().length, n);
|
||||
await core.deleteSetting(db, "checks.wait:999");
|
||||
});
|
||||
|
||||
// PEP-233
|
||||
test("Задания идут — исполнитель не перезапускается", async () => {
|
||||
set("running");
|
||||
const now = Date.now();
|
||||
writeFileSync(join(state, "ps"), "abc123\tGITEA-ACTIONS-TASK-41_WORKFLOW-deploy_JOB-deploy\t\t\n");
|
||||
await core.setSetting(db, "checks.wait:999", { sha: "a", since: now - 20 * 60_000, stuck: true, told: true, cause: "no_job" });
|
||||
const n = restarts().length;
|
||||
assert.equal(await runner.actRunnerTick(db, { now: new Date(now) }), null);
|
||||
assert.equal(restarts().length, n, "running jobs are not cut");
|
||||
const { rmSync } = await import("node:fs");
|
||||
rmSync(join(state, "ps"), { force: true });
|
||||
assert.equal(await runner.actRunnerTick(db, { now: new Date(now) }), "hung", "no jobs — restarted");
|
||||
await core.deleteSetting(db, "checks.wait:999");
|
||||
});
|
||||
|
||||
test("Та же стоящая голова — один перезапуск; новая голова — снова", async () => {
|
||||
set("running");
|
||||
const now = Date.now();
|
||||
await core.setSetting(db, "checks.wait:999", { sha: "a", since: now - 20 * 60_000, stuck: true, told: true, cause: "no_job" });
|
||||
assert.equal(await runner.actRunnerTick(db, { now: new Date(now) }), "hung");
|
||||
const n = restarts().length;
|
||||
assert.equal(await runner.actRunnerTick(db, { now: new Date(now + 60 * 60_000) }), null, "the same head after an hour — no second restart");
|
||||
assert.equal(restarts().length, n);
|
||||
await core.setSetting(db, "checks.wait:998", { sha: "b", since: now + 40 * 60_000, stuck: true, told: true, cause: "no_job" });
|
||||
assert.equal(await runner.actRunnerTick(db, { now: new Date(now + 61 * 60_000) }), "hung", "a new head without a job — a new sign");
|
||||
await core.deleteSetting(db, "checks.wait:999");
|
||||
await core.deleteSetting(db, "checks.wait:998");
|
||||
});
|
||||
|
||||
test("Голова без проверок — не повод для перезапуска", async () => {
|
||||
set("running");
|
||||
const now = Date.now();
|
||||
await core.setSetting(db, "checks.wait:999", { sha: "a", since: now - 20 * 60_000, stuck: true, told: true, cause: "no_workflow", orphan: true });
|
||||
assert.equal(await runner.actRunnerTick(db, { now: new Date(now) }), null);
|
||||
await core.deleteSetting(db, "checks.wait:999");
|
||||
});
|
||||
});
|
||||
|
||||
@ -52,11 +52,12 @@ async function atWork(turns: Parameters<typeof project>[0]["turns"], extra: Part
|
||||
}
|
||||
|
||||
/** A story at work with an open result whose head commit has no check statuses yet. */
|
||||
async function withResult(turns: Parameters<typeof project>[0]["turns"] = []) {
|
||||
async function withResult(turns: Parameters<typeof project>[0]["turns"] = [], o: { workflow?: boolean } = {}) {
|
||||
const { tp, proj } = await atWork(turns);
|
||||
const pj = JSON.stringify({ slug: proj.slug, key: tp.key, name: tp.key, peppaUrl: "http://test", checks: CHECKS });
|
||||
writeFileSync(join(tp.dir, ".peppa/project.json"), pj);
|
||||
gitea.addRepo(proj.giteaOwner, proj.giteaRepo, { files: { "README.md": "x\n", ".peppa/project.json": pj } });
|
||||
const wf: Record<string, string> = o.workflow === false ? {} : { ".gitea/workflows/ci.yml": "name: ci\n" };
|
||||
gitea.addRepo(proj.giteaOwner, proj.giteaRepo, { files: { "README.md": "x\n", ".peppa/project.json": pj, ...wf } });
|
||||
gitea.repo(proj.giteaOwner, proj.giteaRepo).collaborators[BOT.login] = "write";
|
||||
const sha = gitea.commit(proj.giteaOwner, proj.giteaRepo, `task/${tp.taskKey}`, { "f.txt": "1" });
|
||||
const pr = gitea.openPull(proj.giteaOwner, proj.giteaRepo, `task/${tp.taskKey}`);
|
||||
@ -377,6 +378,53 @@ describe("PEP-205: очередь проверок стоит", () => {
|
||||
assert.equal(await core.taskDelayed(db, (await t.tp.task()).id), false, "the checks run — no delay");
|
||||
});
|
||||
|
||||
// PEP-233: stories of earlier tests stand in the same queue — park them.
|
||||
const alone = async (taskKey: string) => {
|
||||
for (const x of await core.listTasks(db, { statuses: ["in_progress", "review"] })) {
|
||||
const ref = await runner.resolveTaskById(db, x.id);
|
||||
if (ref.key !== taskKey) await core.updateTask(db, ref, { status: "backlog" });
|
||||
}
|
||||
};
|
||||
test("В ветке нет описания проверок: очередь не стоит, задача — со своей задержкой", async () => {
|
||||
const t = await withResult([], { workflow: false });
|
||||
await alone(t.tp.taskKey);
|
||||
const t0 = Date.now();
|
||||
const tick = (min: number) => runner.checksQueueTick(db, { stuckMin: 30, now: new Date(t0 + min * MIN) });
|
||||
await tick(0);
|
||||
const r = await tick(40);
|
||||
assert.equal(r.stuck, 0);
|
||||
assert.equal(r.orphans, 1);
|
||||
assert.equal(await core.checksQueueStanding(db), false, "one such story does not stop the dispatcher");
|
||||
assert.equal(await core.taskDelayed(db, (await t.tp.task()).id), true, "the story shows its delay");
|
||||
const mine = async () => (await sentTo(ADMIN_CHAT)).filter((x) => x.includes(t.tp.taskKey));
|
||||
await tick(60);
|
||||
await tick(200);
|
||||
const got = await mine();
|
||||
assert.equal(got.length, 1, "one message per head");
|
||||
assert.match(got[0]!, /нет описания проверок/);
|
||||
assert.equal(got[0]!.includes("Очередь проверок"), false);
|
||||
const proj = await core.getProject(db, t.tp.key);
|
||||
assert.ok((await runner.autoPickSlots(db, proj, { ...(await core.getAutonomy(db, proj.id)), pick: "auto", wipLimit: 3 }, new Date(t0 + 200 * MIN))) > 0, "the dispatcher takes stories");
|
||||
});
|
||||
|
||||
test("Голова ждёт больше двух суток: в очередь не считается", async () => {
|
||||
const t = await withResult();
|
||||
await alone(t.tp.taskKey);
|
||||
const t0 = Date.now();
|
||||
const tick = (min: number) => runner.checksQueueTick(db, { stuckMin: 30, now: new Date(t0 + min * MIN) });
|
||||
await tick(0);
|
||||
assert.equal((await tick(31)).stuck, 1);
|
||||
assert.equal(await core.checksQueueStanding(db), true);
|
||||
const r = await tick(49 * 60);
|
||||
assert.equal(r.stuck, 0);
|
||||
assert.equal(r.orphans, 1);
|
||||
assert.equal(await core.checksQueueStanding(db), false, "the queue is lifted");
|
||||
assert.equal(await core.taskDelayed(db, (await t.tp.task()).id), true);
|
||||
t.status("pending");
|
||||
await tick(49 * 60 + 1);
|
||||
assert.equal(await core.taskDelayed(db, (await t.tp.task()).id), false, "checks started — the delay is lifted");
|
||||
});
|
||||
|
||||
test("Задание упало до проверок: PR переоткрывается, не больше двух раз на коммит", async () => {
|
||||
const t = await withResult();
|
||||
ciJob(t.proj, t.sha, "failure");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user