本地 K3s 节点此前在 Kubelet 中登记为宿主机资源,负载可挤压 etcd 并在 server 重启后继续污染同一 Run。现在为三节点设置真实可调度预算、独立 etcd/数据卷和锁定依赖镜像,并持续核对 server 与 API/etcd 健康。\n\n每次验收生成独立 Run ID,报告使用独占或原子写入,负载错误记录具体阶段;数据库鉴权不可用返回带 Retry-After 的 503,避免基础设施故障被误报为 401。\n\n验证:Go 全量测试、go vet、gofmt、OpenAPI、bash -n、ShellCheck、报告测试和 k3d 配置解析均通过。
140 lines
5.1 KiB
JavaScript
140 lines
5.1 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { execFileSync, spawnSync } from 'node:child_process';
|
|
import { mkdtempSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join, resolve } from 'node:path';
|
|
|
|
const root = resolve(import.meta.dirname, '../..');
|
|
const temporary = mkdtempSync(join(tmpdir(), 'easyai-acceptance-report-'));
|
|
const reports = join(temporary, 'reports');
|
|
mkdirSync(reports);
|
|
const releaseSha = 'a'.repeat(40);
|
|
const digest = `sha256:${'b'.repeat(64)}`;
|
|
const configHash = 'c'.repeat(64);
|
|
const snapshotHash = 'd'.repeat(64);
|
|
const runID = '00000000-0000-4000-8000-000000000001';
|
|
const writeJSON = (path, value) => writeFileSync(path, `${JSON.stringify(value)}\n`, { mode: 0o600 });
|
|
|
|
const runtime = join(temporary, 'runtime.json');
|
|
const snapshot = join(temporary, 'snapshot.json');
|
|
const artifact = join(temporary, 'artifact.json');
|
|
const output = join(temporary, 'acceptance-report.json');
|
|
const partialOutput = join(temporary, 'acceptance-report.partial.json');
|
|
const productionPartial = join(temporary, 'production-summary.partial.json');
|
|
const mergedPartialOutput = join(temporary, 'acceptance-report.production-partial.json');
|
|
writeJSON(runtime, {
|
|
schemaVersion: 'acceptance-runtime/v1',
|
|
runId: runID,
|
|
releaseSha,
|
|
apiImageDigest: digest,
|
|
workerImageDigest: digest,
|
|
snapshotConfigHash: configHash,
|
|
snapshotSha256: snapshotHash,
|
|
apiKeys: ['must-not-be-copied'],
|
|
runToken: 'must-not-be-copied'
|
|
});
|
|
writeJSON(snapshot, {
|
|
schemaVersion: 'acceptance-snapshot/v1',
|
|
source: { releaseSha: 'e'.repeat(40), configHash },
|
|
snapshotSha256: snapshotHash
|
|
});
|
|
writeJSON(artifact, {
|
|
schemaVersion: 'acceptance-artifact-smoke/v1',
|
|
releaseSha,
|
|
apiImageDigest: digest,
|
|
passed: true,
|
|
secretSafe: true
|
|
});
|
|
writeJSON(join(reports, 'load.json'), {
|
|
schemaVersion: 'acceptance-load-report/v1',
|
|
profile: 'simulated-smoke',
|
|
passed: true,
|
|
secretSafe: true,
|
|
phases: [],
|
|
startedAt: '2026-01-01T00:00:00Z',
|
|
finishedAt: '2026-01-01T00:01:00Z'
|
|
});
|
|
|
|
execFileSync('node', [
|
|
join(root, 'scripts/acceptance/report.mjs'),
|
|
'build-local',
|
|
'--runtime', runtime,
|
|
'--snapshot', snapshot,
|
|
'--reports', reports,
|
|
'--artifact', artifact,
|
|
'--api-digest', digest,
|
|
'--certified-profile', 'P24',
|
|
'--output', output
|
|
]);
|
|
const report = JSON.parse(readFileSync(output, 'utf8'));
|
|
assert.equal(report.schemaVersion, 'acceptance-report/v1');
|
|
assert.equal(report.stages.localNative.status, 'passed');
|
|
assert.equal(report.stages.amd64Artifact.status, 'passed');
|
|
assert.equal(report.promotion.ready, false);
|
|
assert.equal(readFileSync(output, 'utf8').includes('must-not-be-copied'), false);
|
|
execFileSync('node', [join(root, 'scripts/acceptance/report.mjs'), 'validate', '--input', output]);
|
|
const overwrite = spawnSync('node', [
|
|
join(root, 'scripts/acceptance/report.mjs'),
|
|
'build-local',
|
|
'--runtime', runtime,
|
|
'--snapshot', snapshot,
|
|
'--reports', reports,
|
|
'--artifact', artifact,
|
|
'--api-digest', digest,
|
|
'--output', output
|
|
], { encoding: 'utf8' });
|
|
assert.notEqual(overwrite.status, 0);
|
|
assert.match(`${overwrite.stdout}${overwrite.stderr}`, /EEXIST|file already exists/);
|
|
assert.equal(JSON.parse(readFileSync(output, 'utf8')).runId, runID);
|
|
|
|
execFileSync('node', [
|
|
join(root, 'scripts/acceptance/report.mjs'),
|
|
'build-local-partial',
|
|
'--runtime', runtime,
|
|
'--snapshot', snapshot,
|
|
'--reports', reports,
|
|
'--certified-profile', 'P24',
|
|
'--failure-phase', 'capacity_p28_round_2',
|
|
'--failure-gate', 'local_control_plane_restarted',
|
|
'--output', partialOutput
|
|
]);
|
|
const partialReport = JSON.parse(readFileSync(partialOutput, 'utf8'));
|
|
assert.equal(partialReport.stages.localNative.status, 'failed');
|
|
assert.equal(partialReport.stages.localNative.failurePhase, 'capacity_p28_round_2');
|
|
assert.equal(partialReport.gates[0].id, 'local_control_plane_restarted');
|
|
assert.equal(partialReport.stages.amd64Artifact.status, 'not-run');
|
|
assert.equal(partialReport.promotion.ready, false);
|
|
assert.equal(readFileSync(partialOutput, 'utf8').includes('must-not-be-copied'), false);
|
|
execFileSync('node', [join(root, 'scripts/acceptance/report.mjs'), 'validate', '--input', partialOutput]);
|
|
|
|
writeJSON(productionPartial, {
|
|
releaseSha,
|
|
apiImageDigest: digest,
|
|
snapshotConfigHash: configHash,
|
|
snapshotSha256: snapshotHash,
|
|
stableCapacityProfile: 'P24',
|
|
realCanaryPassed: false,
|
|
gates: [
|
|
{
|
|
id: 'workflow_interrupted',
|
|
passed: false,
|
|
detail: 'production acceptance interrupted by signal'
|
|
}
|
|
],
|
|
passed: false
|
|
});
|
|
execFileSync('node', [
|
|
join(root, 'scripts/acceptance/report.mjs'),
|
|
'merge-production',
|
|
'--local-report', output,
|
|
'--production-summary', productionPartial,
|
|
'--output', mergedPartialOutput
|
|
]);
|
|
const mergedPartial = JSON.parse(readFileSync(mergedPartialOutput, 'utf8'));
|
|
assert.equal(mergedPartial.stages.onlineSimulation.status, 'failed');
|
|
assert.equal(mergedPartial.stages.realCanary.status, 'failed');
|
|
assert.equal(mergedPartial.promotion.ready, false);
|
|
assert.equal(mergedPartial.promotion.trafficMode, 'validation');
|
|
assert.equal(mergedPartial.gates.at(-1).id, 'workflow_interrupted');
|
|
execFileSync('node', [join(root, 'scripts/acceptance/report.mjs'), 'validate', '--input', mergedPartialOutput]);
|