mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-23 12:05:27 +08:00
feat(ql3): prove Console adopted cutover entry
This commit is contained in:
@@ -13,6 +13,6 @@ test('publishes bounded help without bootstrapping storage or a listener', () =>
|
||||
assert.equal(result.stderr, '');
|
||||
assert.equal(
|
||||
result.stdout,
|
||||
'Usage: ql3-local-api --config /absolute/private-config.json\n',
|
||||
'Usage: ql3-local-api [--cutover-probe] --config /absolute/private-config.json\n',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
const assert = require('node:assert/strict');
|
||||
const { test } = require('node:test');
|
||||
|
||||
const {
|
||||
localApiCliFailureFact,
|
||||
parseLocalApiCliCommand,
|
||||
} = require('../dist/production-process/cliCommand.js');
|
||||
|
||||
test('parses only the normal API and frozen cutover-probe commands', () => {
|
||||
assert.deepEqual(parseLocalApiCliCommand(['--config', '/private/api.json']), {
|
||||
configFilePath: '/private/api.json',
|
||||
mode: 'api',
|
||||
});
|
||||
assert.deepEqual(
|
||||
parseLocalApiCliCommand([
|
||||
'--cutover-probe',
|
||||
'--config',
|
||||
'/private/api.json',
|
||||
]),
|
||||
{
|
||||
configFilePath: '/private/api.json',
|
||||
mode: 'cutover_probe',
|
||||
},
|
||||
);
|
||||
for (const argv of [
|
||||
[],
|
||||
['--cutover-probe', '/private/api.json'],
|
||||
['--config', '/private/api.json', '--cutover-probe'],
|
||||
['--cutover-probe', '--config', ''],
|
||||
]) {
|
||||
assert.equal(parseLocalApiCliCommand(argv), null);
|
||||
}
|
||||
});
|
||||
|
||||
test('publishes bounded Local API failure facts', () => {
|
||||
assert.deepEqual(
|
||||
localApiCliFailureFact(
|
||||
Object.assign(new Error('secret detail'), { code: 'QL3_TEST' }),
|
||||
),
|
||||
{
|
||||
schemaVersion: 1,
|
||||
component: 'qinglong3-local-api',
|
||||
level: 'error',
|
||||
event: 'process_failed',
|
||||
name: 'Error',
|
||||
code: 'QL3_TEST',
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
const assert = require('node:assert/strict');
|
||||
const { test } = require('node:test');
|
||||
|
||||
const {
|
||||
LOCAL_API_PROCESS_CONFIG_SCHEMA,
|
||||
} = require('../dist/production-process/config.js');
|
||||
const {
|
||||
runProductionLocalApiCutoverProbe,
|
||||
} = require('../dist/production-process/cutoverProbeProcess.js');
|
||||
|
||||
test('validates the Local API entry config before delegating to the frozen Application probe', async () => {
|
||||
const signals = Object.freeze({
|
||||
subscribe() {
|
||||
return () => {};
|
||||
},
|
||||
});
|
||||
const events = [];
|
||||
let calls = 0;
|
||||
const result = await runProductionLocalApiCutoverProbe(
|
||||
{
|
||||
configFilePath: '/srv/qinglong/private/api.json',
|
||||
signals,
|
||||
emit(event) {
|
||||
events.push(event);
|
||||
},
|
||||
},
|
||||
{
|
||||
readConfig(filePath) {
|
||||
assert.equal(filePath, '/srv/qinglong/private/api.json');
|
||||
return Object.freeze({
|
||||
schema: LOCAL_API_PROCESS_CONFIG_SCHEMA,
|
||||
deploymentRoot: '/srv/qinglong',
|
||||
applicationConfigFilePath: '/srv/qinglong/private/application.json',
|
||||
ownerPepperKeyringDirectory: '/srv/qinglong/private/owner-pepper',
|
||||
listener: Object.freeze({ host: '127.0.0.1', port: 5701 }),
|
||||
});
|
||||
},
|
||||
async runApplicationProbe(options) {
|
||||
calls += 1;
|
||||
assert.equal(
|
||||
options.configFilePath,
|
||||
'/srv/qinglong/private/application.json',
|
||||
);
|
||||
assert.equal(options.signals, signals);
|
||||
await options.emit({ event: 'cutover_probe_active' });
|
||||
return 'stopped';
|
||||
},
|
||||
},
|
||||
);
|
||||
assert.equal(result, 'stopped');
|
||||
assert.equal(calls, 1);
|
||||
assert.deepEqual(events, [{ event: 'cutover_probe_active' }]);
|
||||
});
|
||||
|
||||
test('rejects malformed adapters before reading any authority', async () => {
|
||||
await assert.rejects(
|
||||
runProductionLocalApiCutoverProbe(
|
||||
{
|
||||
configFilePath: '/srv/qinglong/private/api.json',
|
||||
signals: Object.freeze({
|
||||
subscribe() {
|
||||
return () => {};
|
||||
},
|
||||
}),
|
||||
emit() {},
|
||||
},
|
||||
{},
|
||||
),
|
||||
/adapters are invalid/,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user