mirror of
https://github.com/whyour/qinglong.git
synced 2026-11-07 01:27:39 +08:00
Build complete platform tar.gz bundles with production dependencies for 13 Linux architecture/libc targets, including ARMv6 glibc and musl. Share archive, payload, runtime and dependency verification across online preparation and manual offline installation while retaining the existing Node runtime. Publish readiness only after an isolated backend starts successfully. Repair verified dependency failures once with the frozen lockfile; offline repair requires explicit opt-in. Preserve configured proxies and bound memory, concurrency, process lifetimes and cleanup on small devices. Verify the running build after explicit restart, restore prior application files and dependencies on failure, and retain backups when the failed service cannot stop. Complete cancellation recovery outside the aborted signal, reap descendants as their supervisor exits, and keep operation-only upgrade variables out of both Bash and CLI service startup environments. Keep dialog/sidebar states consistent, hide completed notices, and retain menu/user controls in narrow desktop viewports with long-name truncation. Validation: 791 backend/frontend tests passed (8 platform skips), 294 CLI tests passed (5 platform skips), backend/CLI type checks and standalone offline installer build. On dev, 29 additional Linux fault regressions passed without external networking, including real Node/PM2 SIGTERM rollback. Earlier full bundle application and ARM1176/glibc prestart acceptance remain recorded. Make the mirror notification timing regression respect Bash SECONDS integer resolution: require two clock ticks and assert the logged retry threshold. Validated with Node 20 full regression and 12 repeated boundary runs.
71 lines
2.5 KiB
JavaScript
71 lines
2.5 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs/promises');
|
|
const path = require('node:path');
|
|
const { execFile } = require('node:child_process');
|
|
const { promisify } = require('node:util');
|
|
const execute = promisify(execFile);
|
|
const {
|
|
manualUpgradeFixture,
|
|
} = require('../helpers/manual-upgrade-fixture.cjs');
|
|
const jobs = require('../../cli/src/internal/maintenance/panelUpgrade.cjs');
|
|
|
|
for (const wrongVersion of [false, true]) {
|
|
test(`Bash reload consumes offline readiness and records the actual result; wrong version=${wrongVersion}`, async (t) => {
|
|
const f = await manualUpgradeFixture(t, wrongVersion);
|
|
const operation = execute(
|
|
process.execPath,
|
|
[path.resolve('shell/upgrade.cjs'), 'reload'],
|
|
{ env: f.env, timeout: 15000 },
|
|
);
|
|
if (wrongVersion) await assert.rejects(operation, /启动版本与更新包不一致/);
|
|
else await operation;
|
|
const state = await f.state();
|
|
assert.equal(state.status, wrongVersion ? 'failed' : 'completed');
|
|
assert.equal(state.action, 'apply');
|
|
assert.notEqual(state.id, 'offline-prepared');
|
|
assert.equal(
|
|
await fs.readFile(path.join(f.root, 'static/build/app.js'), 'utf8'),
|
|
wrongVersion ? 'old backend' : 'new backend',
|
|
);
|
|
assert.equal(
|
|
await fs.readFile(path.join(f.root, '.env'), 'utf8'),
|
|
'preserve configuration',
|
|
);
|
|
assert.equal(
|
|
await fs.readFile(path.join(f.root, 'data/keep'), 'utf8'),
|
|
'preserve data',
|
|
);
|
|
if (wrongVersion)
|
|
assert.equal(
|
|
await fs.readFile(path.join(f.root, 'node_modules/old'), 'utf8'),
|
|
'old dependency',
|
|
);
|
|
else
|
|
await assert.rejects(
|
|
fs.access(path.join(f.tmp, 'upgrade-ready-develop.json')),
|
|
);
|
|
});
|
|
}
|
|
|
|
test('manual application holds the launch lock and does not allow a competing panel job', async (t) => {
|
|
const f = await manualUpgradeFixture(t);
|
|
await assert.rejects(
|
|
jobs.withPreparedJob(f.tmp, f.env, f.selected, async (job) => {
|
|
assert.equal((await f.state()).status, 'running');
|
|
await assert.rejects(
|
|
jobs.startJob({ root: f.root, tmp: f.tmp, env: f.env }, 'apply'),
|
|
/已有更新/,
|
|
);
|
|
await job.onStop();
|
|
assert.equal((await f.state()).status, 'restarting');
|
|
throw new Error('cancel manual operation');
|
|
}),
|
|
/cancel manual operation/,
|
|
);
|
|
assert.equal((await f.state()).status, 'failed');
|
|
await assert.rejects(
|
|
fs.access(path.join(f.tmp, 'panel-job-launch/upgrade.lock')),
|
|
);
|
|
});
|