mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 01:39:52 +08:00
fix: restore Node 24 dev startup and legacy cron registration
This commit is contained in:
1 parent
2ddb592800
commit
3b6a873520
6 files changed
+2148
-988
No files matched your search
@@ -19,7 +19,7 @@ for (const [name, rows, delay, succeeds] of [
|
||||
setTimeout(()=>cb(delay<=budget ? null : Object.assign(Error('deadline'),{code:grpc.status.DEADLINE_EXCEEDED}), {}), Math.min(delay,budget));
|
||||
}};
|
||||
const client=load('back/schedule/client.ts', {
|
||||
'../protos/cron':{CronClient:class{constructor(){return fake}}},
|
||||
'../protos/cron':{...require('../../back/protos/cron'),CronClient:class{constructor(){return fake}}},
|
||||
'../config':{grpcPort:5500},
|
||||
'../config/grpcCerts':{getGrpcCerts:()=>({caCert:'ca',clientKey:'key',clientCert:'cert'})},
|
||||
'@grpc/grpc-js':{...grpc,credentials:{createSsl:()=>({})}},
|
||||
|
||||
@@ -81,7 +81,7 @@ test('scheduler probe uses the cron channel and failed writes are not replayed',
|
||||
addCron(request,metadata,options,cb){calls.push(['add',request,options]);cb(Object.assign(Error('invalid'),{code:3}));},
|
||||
};
|
||||
const client=load('back/schedule/client.ts',{
|
||||
'../protos/cron':{CronClient:class{constructor(){return fake;}}},
|
||||
'../protos/cron':{...require('../../back/protos/cron'),CronClient:class{constructor(){return fake;}}},
|
||||
'../config':{grpcPort:5500},'../config/grpcCerts':{getGrpcCerts:()=>({caCert:'ca',clientKey:'key',clientCert:'cert'})},
|
||||
'@grpc/grpc-js':{...require('@grpc/grpc-js'),credentials:{createSsl:()=>({})},status:{UNAVAILABLE:14},Metadata:class{}},
|
||||
}).default;
|
||||
|
||||
@@ -20,6 +20,7 @@ for (const method of ['addCron', 'delCron']) {
|
||||
};
|
||||
const client = load('back/schedule/client.ts', {
|
||||
'../protos/cron': {
|
||||
...require('../../back/protos/cron'),
|
||||
CronClient: class {
|
||||
constructor() {
|
||||
return fake;
|
||||
@@ -47,3 +48,26 @@ for (const method of ['addCron', 'delCron']) {
|
||||
assert.equal(writes, 1, 'do not replay an uncertain mutation');
|
||||
});
|
||||
}
|
||||
|
||||
test('registration serializes nullable SQLite scheduling fields as absent', async () => {
|
||||
const { AddCronRequest, ICron } = require('../../back/protos/cron');
|
||||
const client = load('back/schedule/client.ts', {}).default;
|
||||
let received;
|
||||
client._client = {
|
||||
waitForReady: (_deadline, callback) => callback(),
|
||||
addCron(request, _metadata, _options, callback) {
|
||||
received = AddCronRequest.decode(AddCronRequest.encode(request).finish());
|
||||
callback(null, {});
|
||||
},
|
||||
};
|
||||
const legacy = {
|
||||
id: '1', extra_schedules: null, max_queue_wait: null, catchup_seconds: null, recovery_from: null,
|
||||
};
|
||||
const configured = {
|
||||
id: '2', schedule: '* * * * *', extra_schedules: [{ schedule: '0 1 * * *' }],
|
||||
max_queue_wait: 0, catchup_seconds: 60, recovery_from: 1700000000000,
|
||||
};
|
||||
await client.addCron([legacy, configured], true);
|
||||
assert.equal(received.replace, true);
|
||||
assert.deepEqual(received.crons, [ICron.create({ id: '1' }), ICron.create(configured)]);
|
||||
});
|
||||
Reference in new issue
Block a user