mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-18 14:14:37 +01:00
/ship's test step says when it hits its time limit, and long test file lists no longer overflow the remote command (GST-2958) (#4429)
* Say when /ship's test step hit its time limit, and keep long file lists off the remote test command line gstack-ship-preflight stopped gstack-pregate after a fixed hour and printed 'PREGATE: unreadable (exit 143)'. The whole step's budget is now --step-timeout <s> (default 3600), and a stop at it prints 'PREGATE: time limit hit' with the way out: push and let CI's full run carry the tests, or a larger budget. The test_backend command pregate prints for a small machine put every selected file into one argument, which Linux refuses past 128 KiB. The files now reach the VM in a setup script named by its content. Also adds an arg-limit troubleshooting entry and says the Windows job has eight shards. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Read the small-machine file list from the setup script in the hidden-folder path test The remote command now names a setup script instead of the files, so the test checks that the script lists the ./-prefixed path. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Keep a test path with a newline out of the remote file list A selected test path containing a newline, or equal to the list's end marker, could end the setup script's file list early and run the rest as shell on the test VM. Such paths now keep the quoted inline command. Review-Finding: p1/outside-voice#1 reader=outside-voice Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Mark the preflight half of the Step 5 time limit to-do as done Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
e8c8625bd6
commit
aeb74eb00b
11 files changed
+146
-20
No files matched your search
@@ -30,7 +30,7 @@
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { baseInputs, sha256 } from '../context';
|
||||
import { baseInputs, defaultScratchRoot, sha256 } from '../context';
|
||||
import { PREGATE_CONFIG_PATH } from '../config';
|
||||
import { classifyCommandEnvironment, classifyEnvironment, environmentLine, environmentResult, launchCause } from '../environment';
|
||||
import { checkScratch } from '../run-scratch';
|
||||
@@ -498,12 +498,39 @@ const GSTACK_ROOT = path.resolve(import.meta.dir, '..', '..', '..');
|
||||
*/
|
||||
function remoteObligation(ctx: PregateContext, sel: Selection): RemoteObligation {
|
||||
const declared = ctx.config.remote_gate;
|
||||
const runner = detectRunner(ctx, sel.gateTests);
|
||||
const command = declared ?? `${GSTACK_ROOT}/scripts/ubicloud/ubi-runner.sh run --src ${quote(ctx.repoRoot)} -- ${quote(runner ? runner.replace('{files}', testFileArgs(runner, sel.gateTests).map(quote).join(' ')) : '<test runner> <selected files>')}`;
|
||||
const command = declared ?? backendCommand(ctx, sel.gateTests);
|
||||
const [workflow, job] = declared ? REMOTE_GATE_LANE.split('/') as [string, string] : ['test_backend', ctx.testBackend];
|
||||
return { lane: `${workflow}/${job}`, platform: 'remote', workflow, job, tests: sel.gateTests, receipt: null, command };
|
||||
}
|
||||
|
||||
/**
|
||||
* The test backend's command: gstack's Ubicloud runner, with the selected files in a setup script that writes them one per line
|
||||
* on the VM. The command reaches the VM as one argument and Linux caps one argument at 128 KiB (#4424), so the list never goes in
|
||||
* it. The script lives under the state root, named by its content, so the same selection prints the same command every run and a
|
||||
* same-tree clear still matches it; an unwritable state root keeps it in this run's scratch. A path the one-per-line list can't
|
||||
* hold (a newline, or the list's end marker) keeps the quoted inline form, so no path can end the list early and run as shell.
|
||||
*/
|
||||
function backendCommand(ctx: PregateContext, files: readonly string[]): string {
|
||||
const ubi = `${GSTACK_ROOT}/scripts/ubicloud/ubi-runner.sh run --src ${quote(ctx.repoRoot)}`;
|
||||
const runner = detectRunner(ctx, files);
|
||||
if (!runner) return `${ubi} -- ${quote('<test runner> <selected files>')}`;
|
||||
const args = testFileArgs(runner, files);
|
||||
if (args.some(f => f.includes('\n') || f === 'PREGATE_FILES')) return `${ubi} -- ${quote(runner.replace('{files}', () => args.map(quote).join(' ')))}`;
|
||||
const setup = `cat > ~/.pregate-files.txt <<'PREGATE_FILES'\n${args.map(f => `${f}\n`).join('')}PREGATE_FILES\n`;
|
||||
const name = `${sha256(setup).slice(0, 16)}.sh`;
|
||||
let file: string;
|
||||
try {
|
||||
const dir = path.join(path.dirname(defaultScratchRoot(ctx.repoRoot, ctx.env)), 'remote-files');
|
||||
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
||||
file = path.join(dir, name);
|
||||
fs.writeFileSync(file, setup);
|
||||
} catch {
|
||||
file = path.join(checkScratch(ctx.scratch, 'remote'), name);
|
||||
fs.writeFileSync(file, setup);
|
||||
}
|
||||
return `${ubi} --setup ${quote(file)} -- ${quote(`mapfile -t PREGATE_FILES < ~/.pregate-files.txt && ${runner.replace('{files}', () => '"${PREGATE_FILES[@]}"')}`)}`;
|
||||
}
|
||||
|
||||
export const REMOTE_GATE_LANE = 'pregate.json/remote_gate';
|
||||
/** How many leading lines of a remote gate's output are read for an environment cause: its preamble, before any test output could stream. */
|
||||
export const REMOTE_PREAMBLE_LINES = 40;
|
||||
|
||||
Reference in new issue
Block a user