fix: upgrade directly launched hosts and freeze package QA evidence
This commit is contained in:
+28
-1
@@ -3,10 +3,37 @@ import assert from 'node:assert/strict';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { fixture, compatibleFixture, until, workspace } from './helpers.mjs';
|
||||
import { fixture, compatibleFixture, until, workspace, launchWorkbench } from './helpers.mjs';
|
||||
import { upgradeRunning } from '../scripts/upgrade-running.mjs';
|
||||
import { APP_VERSION } from '../src/server/diagnostics.mjs';
|
||||
|
||||
test('a directly started compiled host upgrades twice with the same PID, sessions, applied bytes and volatile provider', { timeout: 30000 }, async t => {
|
||||
const f = fixture(t), host = await launchWorkbench(t, f.data);
|
||||
const model = await compatibleFixture(t, () => ({ data: [{ id: 'direct-upgrade-fixture' }] }));
|
||||
await host.api('/config', { mode: 'compatible', model: 'direct-upgrade-fixture', baseUrl: model.baseUrl, apiKey: 'fixture-direct-memory-key' });
|
||||
await host.api('/sessions/' + f.session.id + '/proposals', { path: 'DIRECT-UPGRADE.md', content: '# Preserve applied source\n' });
|
||||
const proposed = await host.api('/sessions/' + f.session.id);
|
||||
await host.api('/sessions/' + f.session.id + '/changes/' + proposed.changes.at(-1).id + '/apply', {});
|
||||
const before = await host.api('/sessions/' + f.session.id), bootstrap = await host.api('/bootstrap');
|
||||
const beforeBytes = fs.readFileSync(path.join(f.projectRoot, 'DIRECT-UPGRADE.md'));
|
||||
let previousRoot;
|
||||
for (const label of ['first', 'second']) {
|
||||
const nextRoot = path.join(f.root, 'compiled-upgrade-' + label); fs.mkdirSync(nextRoot);
|
||||
for (const name of ['dist-server', 'dist-client']) fs.cpSync(path.join(workspace, name), path.join(nextRoot, name), { recursive: true });
|
||||
const result = await upgradeRunning({ url: host.url, pid: host.child.pid, currentRoot: workspace, handlerRoot: previousRoot, newRoot: nextRoot });
|
||||
assert.equal(result.version, APP_VERSION); assert.equal(result.pid, host.child.pid); assert.equal(result.verified, true); assert.equal(result.hasKey, true);
|
||||
const afterBootstrap = await host.api('/bootstrap');
|
||||
assert.equal(afterBootstrap.runtimeRoot, nextRoot); assert.deepEqual(afterBootstrap.projects, bootstrap.projects); assert.deepEqual(afterBootstrap.sessions, bootstrap.sessions);
|
||||
assert.deepEqual(await host.api('/sessions/' + f.session.id), before);
|
||||
assert.deepEqual(fs.readFileSync(path.join(f.projectRoot, 'DIRECT-UPGRADE.md')), beforeBytes);
|
||||
assert.deepEqual((await host.api('/config/models', {})).models, ['direct-upgrade-fixture']);
|
||||
assert.equal(model.requests.at(-1).headers.authorization, 'Bearer fixture-direct-memory-key');
|
||||
assert.ok(!fs.readFileSync(path.join(f.data, 'config.json'), 'utf8').includes('fixture-direct-memory-key'));
|
||||
await assert.rejects(fetch('http://127.0.0.1:9229/json/list', { signal: AbortSignal.timeout(500) }));
|
||||
previousRoot = nextRoot;
|
||||
}
|
||||
});
|
||||
|
||||
test('the running 0.1.0 process upgrades in place and retains its project, session, files and volatile model connection', { timeout: 60000 }, async t => {
|
||||
const f = fixture(t);
|
||||
const legacyData = path.join(f.root, 'legacy-data'); f.store.exportLegacyData(legacyData);
|
||||
|
||||
Reference in New Issue
Block a user