@whyour/qinglong 2.23.0 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +3 -0
- package/README-NODE.md +10 -0
- package/back/protos/api.proto +10 -0
- package/cli/README.en.md +156 -0
- package/cli/README.md +156 -0
- package/cli/src/internal/maintenance/nodeRuntime.cjs +18 -0
- package/cli/src/internal/maintenance/panelUpgrade.cjs +577 -0
- package/cli/src/internal/maintenance/platformBundle.cjs +582 -0
- package/cli/src/internal/maintenance/upgradeArtifacts.cjs +979 -0
- package/cli/src/internal/maintenance/upgradePrestart.cjs +396 -0
- package/ecosystem.config.js +3 -0
- package/package.json +53 -10
- package/sample/notify.js +308 -135
- package/sample/notify.py +174 -27
- package/shell/api.sh +18 -7
- package/shell/install-bundle.cjs +320 -0
- package/shell/install-package.cjs +74 -0
- package/shell/lang/en.sh +38 -0
- package/shell/node-runtime-probe.cjs +62 -0
- package/shell/otask.sh +38 -36
- package/shell/preload/client.js +1 -0
- package/shell/preload/notificationAudit.js +51 -0
- package/shell/preload/sitecustomize.js +3 -3
- package/shell/preload/sitecustomize.py +5 -5
- package/shell/rmlog.sh +21 -16
- package/shell/share.sh +61 -44
- package/shell/start-simplify.sh +90 -0
- package/shell/start.sh +48 -71
- package/shell/task-timeout.sh +22 -10
- package/shell/task.sh +7 -7
- package/shell/update.sh +52 -38
- package/shell/upgrade-lock.yaml +16122 -0
- package/shell/upgrade.cjs +1 -1
- package/static/build/api/clientIp.js +2 -1
- package/static/build/api/clientIp.js.map +1 -0
- package/static/build/api/config.js.map +1 -0
- package/static/build/api/cron.js.map +1 -0
- package/static/build/api/dashboard.js.map +1 -0
- package/static/build/api/dependence.js.map +1 -0
- package/static/build/api/env.js.map +1 -0
- package/static/build/api/health.js.map +1 -0
- package/static/build/api/index.js.map +1 -0
- package/static/build/api/log.js.map +1 -0
- package/static/build/api/open.js.map +1 -0
- package/static/build/api/retention.js.map +1 -0
- package/static/build/api/script.js.map +1 -0
- package/static/build/api/subscription.js.map +1 -0
- package/static/build/api/system.js +18 -0
- package/static/build/api/system.js.map +1 -0
- package/static/build/api/update.js.map +1 -0
- package/static/build/api/user.js.map +1 -0
- package/static/build/app.js +10 -23
- package/static/build/app.js.map +1 -0
- package/static/build/bootstrap/database.js.map +1 -0
- package/static/build/bootstrap/upgradeProbe.js +154 -0
- package/static/build/bootstrap/upgradeProbe.js.map +1 -0
- package/static/build/config/const.js +2 -1
- package/static/build/config/const.js.map +1 -0
- package/static/build/config/container.js.map +1 -0
- package/static/build/config/grpcCerts.js.map +1 -0
- package/static/build/config/http.js.map +1 -0
- package/static/build/config/index.js.map +1 -0
- package/static/build/config/serverEnv.js.map +1 -0
- package/static/build/config/share.js.map +1 -0
- package/static/build/config/subscription.js.map +1 -0
- package/static/build/config/util.js +178 -79
- package/static/build/config/util.js.map +1 -0
- package/static/build/data/cron.js.map +1 -0
- package/static/build/data/cronStats.js.map +1 -0
- package/static/build/data/cronView.js.map +1 -0
- package/static/build/data/dependence.js.map +1 -0
- package/static/build/data/env.js.map +1 -0
- package/static/build/data/index.js.map +1 -0
- package/static/build/data/notify.js.map +1 -0
- package/static/build/data/open.js.map +1 -0
- package/static/build/data/runningInstance.js.map +1 -0
- package/static/build/data/sock.js.map +1 -0
- package/static/build/data/subscription.js.map +1 -0
- package/static/build/data/system.js +3 -1
- package/static/build/data/system.js.map +1 -0
- package/static/build/interface/schedule.js.map +1 -0
- package/static/build/loaders/app.js.map +1 -0
- package/static/build/loaders/bootAfter.js.map +1 -0
- package/static/build/loaders/db.js.map +1 -0
- package/static/build/loaders/depInjector.js.map +1 -0
- package/static/build/loaders/deps.js.map +1 -0
- package/static/build/loaders/express.js +8 -3
- package/static/build/loaders/express.js.map +1 -0
- package/static/build/loaders/httpApplication.js +55 -0
- package/static/build/loaders/httpApplication.js.map +1 -0
- package/static/build/loaders/initData.js.map +1 -0
- package/static/build/loaders/initFile.js.map +1 -0
- package/static/build/loaders/initTask.js +1 -1
- package/static/build/loaders/initTask.js.map +1 -0
- package/static/build/loaders/logger.js.map +1 -0
- package/static/build/loaders/server.js.map +1 -0
- package/static/build/loaders/sock.js.map +1 -0
- package/static/build/middlewares/monitoring.js.map +1 -0
- package/static/build/middlewares/protectedPathCase.js.map +1 -0
- package/static/build/middlewares/uniqueConstraintError.js.map +1 -0
- package/static/build/middlewares/validationErrors.js +17 -0
- package/static/build/middlewares/validationErrors.js.map +1 -0
- package/static/build/protos/api.js +140 -2
- package/static/build/protos/api.js.map +1 -0
- package/static/build/protos/cron.js.map +1 -0
- package/static/build/protos/health.js.map +1 -0
- package/static/build/schedule/addCron.js +2 -2
- package/static/build/schedule/addCron.js.map +1 -0
- package/static/build/schedule/api.js +21 -2
- package/static/build/schedule/api.js.map +1 -0
- package/static/build/schedule/client.js.map +1 -0
- package/static/build/schedule/data.js.map +1 -0
- package/static/build/schedule/delCron.js +5 -3
- package/static/build/schedule/delCron.js.map +1 -0
- package/static/build/schedule/health.js.map +1 -0
- package/static/build/schedule/setConcurrency.js.map +1 -0
- package/static/build/services/config.js.map +1 -0
- package/static/build/services/cron.js +7 -7
- package/static/build/services/cron.js.map +1 -0
- package/static/build/services/cronView.js.map +1 -0
- package/static/build/services/dependence.js +48 -13
- package/static/build/services/dependence.js.map +1 -0
- package/static/build/services/env.js.map +1 -0
- package/static/build/services/grpc.js +2 -2
- package/static/build/services/grpc.js.map +1 -0
- package/static/build/services/health.js +2 -0
- package/static/build/services/health.js.map +1 -0
- package/static/build/services/http.js.map +1 -0
- package/static/build/services/log.js.map +1 -0
- package/static/build/services/metrics.js +2 -1
- package/static/build/services/metrics.js.map +1 -0
- package/static/build/services/notify.js +45 -24
- package/static/build/services/notify.js.map +1 -0
- package/static/build/services/open.js.map +1 -0
- package/static/build/services/retention.js.map +1 -0
- package/static/build/services/schedule.js +13 -12
- package/static/build/services/schedule.js.map +1 -0
- package/static/build/services/script.js.map +1 -0
- package/static/build/services/scriptHistory.js.map +1 -0
- package/static/build/services/sock.js.map +1 -0
- package/static/build/services/sshKey.js +8 -5
- package/static/build/services/sshKey.js.map +1 -0
- package/static/build/services/subscription.js.map +1 -0
- package/static/build/services/system.js +76 -46
- package/static/build/services/system.js.map +1 -0
- package/static/build/services/user.js +2 -2
- package/static/build/services/user.js.map +1 -0
- package/static/build/shared/auth.js.map +1 -0
- package/static/build/shared/authMutation.js.map +1 -0
- package/static/build/shared/childProcess.js.map +1 -0
- package/static/build/shared/clientIp.js.map +1 -0
- package/static/build/shared/cronCommand.js.map +1 -0
- package/static/build/shared/cronSchedule.js +65 -9
- package/static/build/shared/cronSchedule.js.map +1 -0
- package/static/build/shared/cronScheduler.js +3 -2
- package/static/build/shared/cronScheduler.js.map +1 -0
- package/static/build/shared/errors.js.map +1 -0
- package/static/build/shared/fileAccess.js.map +1 -0
- package/static/build/shared/i18n.js +164 -85
- package/static/build/shared/i18n.js.map +1 -0
- package/static/build/shared/interface.js.map +1 -0
- package/static/build/shared/languageSync.js +61 -0
- package/static/build/shared/languageSync.js.map +1 -0
- package/static/build/shared/linuxMirror.js +96 -0
- package/static/build/shared/linuxMirror.js.map +1 -0
- package/static/build/shared/logPath.js.map +1 -0
- package/static/build/shared/logReader.js.map +1 -0
- package/static/build/shared/logStreamManager.js.map +1 -0
- package/static/build/shared/loginThrottle.js.map +1 -0
- package/static/build/shared/notificationAudit.js +46 -0
- package/static/build/shared/notificationAudit.js.map +1 -0
- package/static/build/shared/pLimit.js +8 -8
- package/static/build/shared/pLimit.js.map +1 -0
- package/static/build/shared/password.js.map +1 -0
- package/static/build/shared/retention.js.map +1 -0
- package/static/build/shared/runCron.js +69 -26
- package/static/build/shared/runCron.js.map +1 -0
- package/static/build/shared/runtimeBuild.js +44 -0
- package/static/build/shared/runtimeBuild.js.map +1 -0
- package/static/build/shared/schedulerMutationLock.js.map +1 -0
- package/static/build/shared/schedulerReadiness.js.map +1 -0
- package/static/build/shared/schemaMigrations.js.map +1 -0
- package/static/build/shared/scriptHistory.js.map +1 -0
- package/static/build/shared/shellQuote.js.map +1 -0
- package/static/build/shared/startupProcess.js.map +1 -0
- package/static/build/shared/store.js.map +1 -0
- package/static/build/shared/subscriptionMutationLock.js.map +1 -0
- package/static/build/shared/subscriptionPath.js.map +1 -0
- package/static/build/shared/subscriptionStorage.js.map +1 -0
- package/static/build/shared/trustProxy.js +5 -4
- package/static/build/shared/trustProxy.js.map +1 -0
- package/static/build/shared/utils.js.map +1 -0
- package/static/build/token.js.map +1 -0
- package/static/build/validation/schedule.js +19 -1
- package/static/build/validation/schedule.js.map +1 -0
- package/static/build-info.json +754 -0
- package/static/dist/1089.0ecc5383.async.js.gz +0 -0
- package/static/dist/1174.41a43fee.async.js.gz +0 -0
- package/static/dist/119.89e2d610.async.js.gz +0 -0
- package/static/dist/1212.f87fd07a.async.js.gz +0 -0
- package/static/dist/1352.96a77e1d.async.js.gz +0 -0
- package/static/dist/1379.f91563a1.async.js.gz +0 -0
- package/static/dist/1571.94ddca13.async.js.gz +0 -0
- package/static/dist/1706.ac98cb3f.async.js.gz +0 -0
- package/static/dist/1765.5ac01a93.async.js.gz +0 -0
- package/static/dist/1836.f0b74cf1.async.js.gz +0 -0
- package/static/dist/1883.675b6a18.chunk.css.gz +0 -0
- package/static/dist/1885.b8f427bf.async.js.gz +0 -0
- package/static/dist/1887.9e0d3da8.async.js.gz +0 -0
- package/static/dist/1967.3f3945d0.async.js.gz +0 -0
- package/static/dist/198.db47fc1a.async.js.gz +0 -0
- package/static/dist/2325.dfa32834.async.js.gz +0 -0
- package/static/dist/2338.d678967d.async.js.gz +0 -0
- package/static/dist/2372.b5a50ee7.async.js +1 -0
- package/static/dist/2372.b5a50ee7.async.js.gz +0 -0
- package/static/dist/2476.4e9b0992.async.js.gz +0 -0
- package/static/dist/2537.2b262ee0.async.js.gz +0 -0
- package/static/dist/2577.aa8fe709.async.js.gz +0 -0
- package/static/dist/2635.d4c59d23.async.js.gz +0 -0
- package/static/dist/2664.e69530fb.async.js +1 -0
- package/static/dist/2664.e69530fb.async.js.gz +0 -0
- package/static/dist/2693.51c2636b.async.js.gz +0 -0
- package/static/dist/2808.cdc0995c.async.js.gz +0 -0
- package/static/dist/2821.651f31e5.async.js.gz +0 -0
- package/static/dist/2890.add55e85.async.js.gz +0 -0
- package/static/dist/2901.6d0de54e.async.js +1 -0
- package/static/dist/2901.6d0de54e.async.js.gz +0 -0
- package/static/dist/292.1b962b29.chunk.css.gz +0 -0
- package/static/dist/292.27ce781f.async.js +1 -0
- package/static/dist/292.27ce781f.async.js.gz +0 -0
- package/static/dist/300.08ac9875.async.js.gz +0 -0
- package/static/dist/3191.3b7e4b42.async.js +1 -0
- package/static/dist/3191.3b7e4b42.async.js.gz +0 -0
- package/static/dist/3382.a584a111.async.js.gz +0 -0
- package/static/dist/3383.041eee73.async.js.gz +0 -0
- package/static/dist/3512.95e41255.async.js.gz +0 -0
- package/static/dist/3714.8d6dba9e.async.js.gz +0 -0
- package/static/dist/3906.a5eee612.async.js.gz +0 -0
- package/static/dist/3948.4fe809fd.async.js.gz +0 -0
- package/static/dist/4324.5a5887d1.async.js.gz +0 -0
- package/static/dist/4559.faab3673.async.js.gz +0 -0
- package/static/dist/4573.16f19278.async.js.gz +0 -0
- package/static/dist/{4736.1d2b5cb6.async.js → 4736.7c4c489b.async.js} +1 -1
- package/static/dist/4736.7c4c489b.async.js.gz +0 -0
- package/static/dist/4887.8e3ae573.async.js.gz +0 -0
- package/static/dist/4934.f3539d08.async.js.gz +0 -0
- package/static/dist/5077.cbd111cd.async.js.gz +0 -0
- package/static/dist/{5481.624d0e07.async.js → 5481.e2945a63.async.js} +1 -1
- package/static/dist/5481.e2945a63.async.js.gz +0 -0
- package/static/dist/5662.678b0cfb.async.js.gz +0 -0
- package/static/dist/5970.5862e59e.async.js +1 -0
- package/static/dist/5970.5862e59e.async.js.gz +0 -0
- package/static/dist/6013.db535339.async.js.gz +0 -0
- package/static/dist/6035.32ebfad9.async.js.gz +0 -0
- package/static/dist/6212.30a9c190.async.js +1 -0
- package/static/dist/6212.30a9c190.async.js.gz +0 -0
- package/static/dist/6341.673fb65c.async.js.gz +0 -0
- package/static/dist/6367.8b0e838c.async.js.gz +0 -0
- package/static/dist/6431.c50479be.async.js +1 -0
- package/static/dist/6569.55177f6a.async.js.gz +0 -0
- package/static/dist/6610.c111af7e.async.js.gz +0 -0
- package/static/dist/6638.87a163d2.async.js.gz +0 -0
- package/static/dist/6646.95e92533.async.js.gz +0 -0
- package/static/dist/{6872.a503ef55.async.js → 6872.fcc9ce17.async.js} +1 -1
- package/static/dist/6872.fcc9ce17.async.js.gz +0 -0
- package/static/dist/691.187a388c.async.js.gz +0 -0
- package/static/dist/7146.4dc150b1.async.js +1 -0
- package/static/dist/7146.4dc150b1.async.js.gz +0 -0
- package/static/dist/7231.f7e5b668.async.js.gz +0 -0
- package/static/dist/7253.4b9bf133.async.js.gz +0 -0
- package/static/dist/7278.96bf439f.async.js.gz +0 -0
- package/static/dist/7355.fca746f5.async.js.gz +0 -0
- package/static/dist/7384.1bb449d5.async.js.gz +0 -0
- package/static/dist/7508.3fffed15.chunk.css.gz +0 -0
- package/static/dist/7508.d90eac63.async.js.gz +0 -0
- package/static/dist/7802.34255805.async.js.gz +0 -0
- package/static/dist/7984.eaac7402.async.js.gz +0 -0
- package/static/dist/8033.5cb31493.async.js.gz +0 -0
- package/static/dist/8078.8586c875.async.js.gz +0 -0
- package/static/dist/8147.2fb55202.async.js.gz +0 -0
- package/static/dist/8187.48c130d6.async.js.gz +0 -0
- package/static/dist/8495.d53e15ca.async.js.gz +0 -0
- package/static/dist/8844.a0fef08e.async.js.gz +0 -0
- package/static/dist/9308.3202ac13.async.js.gz +0 -0
- package/static/dist/9323.a33f47da.async.js.gz +0 -0
- package/static/dist/965.8d9b1fbd.async.js +1 -0
- package/static/dist/965.8d9b1fbd.async.js.gz +0 -0
- package/static/dist/9761.360a19d8.async.js.gz +0 -0
- package/static/dist/index.html +2 -2
- package/static/dist/layouts__index.86b6bcbe.chunk.css +1 -0
- package/static/dist/layouts__index.86b6bcbe.chunk.css.gz +0 -0
- package/static/dist/layouts__index.c8e9788e.async.js +1 -0
- package/static/dist/layouts__index.c8e9788e.async.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/base/worker/workerMain.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/basic-languages/abap/abap.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/basic-languages/clojure/clojure.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/basic-languages/elixir/elixir.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/basic-languages/freemarker2/freemarker2.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/basic-languages/mysql/mysql.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/basic-languages/pgsql/pgsql.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/basic-languages/powerquery/powerquery.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/basic-languages/redshift/redshift.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/basic-languages/solidity/solidity.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/basic-languages/sql/sql.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/editor/editor.main.css.gz +0 -0
- package/static/dist/monaco-editor/min/vs/editor/editor.main.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.de.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.es.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.fr.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.it.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.ja.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.ko.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.ru.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.zh-cn.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/editor/editor.main.nls.zh-tw.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/language/css/cssMode.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/language/css/cssWorker.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/language/html/htmlMode.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/language/html/htmlWorker.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/language/json/jsonMode.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/language/json/jsonWorker.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/language/typescript/tsMode.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/language/typescript/tsWorker.js.gz +0 -0
- package/static/dist/monaco-editor/min/vs/loader.js.gz +0 -0
- package/static/dist/preload_helper.8b8f6581.js +1 -0
- package/static/dist/src__pages__404.3fd8332e.async.js +1 -0
- package/static/dist/src__pages__config__index.d18d8f95.async.js +1 -0
- package/static/dist/src__pages__crontab__detail.88729e8f.async.js +1 -0
- package/static/dist/src__pages__crontab__detail.88729e8f.async.js.gz +0 -0
- package/static/dist/src__pages__crontab__index.8aa9d297.async.js +1 -0
- package/static/dist/src__pages__crontab__index.8aa9d297.async.js.gz +0 -0
- package/static/dist/src__pages__crontab__logModal.930535e2.async.js.gz +0 -0
- package/static/dist/src__pages__crontab__modal.a2c8fdcc.async.js.gz +0 -0
- package/static/dist/src__pages__crontab__viewCreateModal.7b4f9cbe.async.js.gz +0 -0
- package/static/dist/src__pages__crontab__viewManageModal.cd454ea0.async.js.gz +0 -0
- package/static/dist/src__pages__dashboard__index.c05ce904.async.js +1 -0
- package/static/dist/src__pages__dashboard__index.c05ce904.async.js.gz +0 -0
- package/static/dist/src__pages__dependence__index.5b7fd97d.async.js +1 -0
- package/static/dist/src__pages__dependence__index.5b7fd97d.async.js.gz +0 -0
- package/static/dist/{src__pages__dependence__logModal.154efe7a.async.js → src__pages__dependence__logModal.01729f63.async.js} +1 -1
- package/static/dist/src__pages__dependence__logModal.01729f63.async.js.gz +0 -0
- package/static/dist/src__pages__dependence__modal.ef7ae53b.async.js +1 -0
- package/static/dist/src__pages__dependence__modal.ef7ae53b.async.js.gz +0 -0
- package/static/dist/src__pages__diff__index.4233ea93.async.js +1 -0
- package/static/dist/src__pages__diff__index.4233ea93.async.js.gz +0 -0
- package/static/dist/src__pages__env__index.eddb35bf.async.js +1 -0
- package/static/dist/src__pages__env__index.eddb35bf.async.js.gz +0 -0
- package/static/dist/src__pages__env__modal.4d71adb3.async.js.gz +0 -0
- package/static/dist/src__pages__error__index.66605c72.async.js +1 -0
- package/static/dist/src__pages__initialization__index.9c1c5b76.async.js +1 -0
- package/static/dist/src__pages__initialization__index.9c1c5b76.async.js.gz +0 -0
- package/static/dist/src__pages__log__index.71250e0d.async.js.gz +0 -0
- package/static/dist/src__pages__login__index.58bb4b38.async.js +1 -0
- package/static/dist/src__pages__login__index.58bb4b38.async.js.gz +0 -0
- package/static/dist/src__pages__script__components__UnsupportedFilePreview__index.c347a13a.async.js.gz +0 -0
- package/static/dist/src__pages__script__editModal.d15f8d78.async.js +1 -0
- package/static/dist/src__pages__script__editModal.d15f8d78.async.js.gz +0 -0
- package/static/dist/src__pages__script__editNameModal.789ad87b.async.js.gz +0 -0
- package/static/dist/src__pages__script__historyDrawer.8c58d958.async.js.gz +0 -0
- package/static/dist/src__pages__script__index.96a6d30f.async.js +1 -0
- package/static/dist/src__pages__script__index.96a6d30f.async.js.gz +0 -0
- package/static/dist/{src__pages__setting__about.e6db5090.chunk.css → src__pages__setting__about.0d6ea255.chunk.css} +1 -1
- package/static/dist/src__pages__setting__about.3d3c019f.async.js.gz +0 -0
- package/static/dist/src__pages__setting__checkUpdate.429a42f3.async.js +1 -0
- package/static/dist/src__pages__setting__checkUpdate.429a42f3.async.js.gz +0 -0
- package/static/dist/src__pages__setting__clientIp.3a8711ed.async.js.gz +0 -0
- package/static/dist/{src__pages__setting__dependence.28ecea01.chunk.css → src__pages__setting__dependence.80b183a5.chunk.css} +1 -1
- package/static/dist/src__pages__setting__dependence.c227c0f5.async.js +1 -0
- package/static/dist/src__pages__setting__dependence.c227c0f5.async.js.gz +0 -0
- package/static/dist/src__pages__setting__index.274ad415.async.js +1 -0
- package/static/dist/src__pages__setting__index.274ad415.async.js.gz +0 -0
- package/static/dist/{src__pages__setting__index.7cf46d4a.chunk.css → src__pages__setting__index.46315660.chunk.css} +1 -1
- package/static/dist/src__pages__setting__loginLog.ef135f19.async.js +1 -0
- package/static/dist/src__pages__setting__loginLog.ef135f19.async.js.gz +0 -0
- package/static/dist/src__pages__setting__notifyLog.5ef5b578.async.js +1 -0
- package/static/dist/src__pages__setting__notifyLog.5ef5b578.async.js.gz +0 -0
- package/static/dist/{src__pages__setting__other.28ecea01.chunk.css → src__pages__setting__notifyLog.80b183a5.chunk.css} +1 -1
- package/static/dist/src__pages__setting__other.80b183a5.chunk.css +1 -0
- package/static/dist/src__pages__setting__other.e744c0d1.async.js +1 -0
- package/static/dist/src__pages__setting__other.e744c0d1.async.js.gz +0 -0
- package/static/dist/src__pages__setting__security.e2d71ebb.async.js.gz +0 -0
- package/static/dist/src__pages__setting__systemLog.000bcb5e.async.js +1 -0
- package/static/dist/src__pages__setting__systemLog.000bcb5e.async.js.gz +0 -0
- package/static/dist/src__pages__subscription__index.f556ae4c.async.js +1 -0
- package/static/dist/src__pages__subscription__index.f556ae4c.async.js.gz +0 -0
- package/static/dist/src__pages__subscription__logModal.cdba5139.async.js.gz +0 -0
- package/static/dist/src__pages__subscription__modal.8f04f506.async.js +1 -0
- package/static/dist/umi.73936e34.js +1 -0
- package/static/dist/umi.73936e34.js.gz +0 -0
- package/static/dist/umi.a4d14b92.css.gz +0 -0
- package/version.yaml +11 -14
- package/.dockerignore +0 -13
- package/AGENTS.md +0 -43
- package/SECURITY.md +0 -5
- package/back/protos/cron.proto +0 -33
- package/back/protos/health.proto +0 -22
- package/deploy/kubernetes/README.md +0 -81
- package/deploy/kubernetes/base/kustomization.yaml +0 -5
- package/deploy/kubernetes/base/qinglong.yaml +0 -95
- package/deploy/kubernetes/overlays/example/kustomization.yaml +0 -10
- package/docker/Dockerfile +0 -113
- package/docker/Dockerfile.310 +0 -113
- package/docker/Dockerfile.debian +0 -128
- package/docker/Dockerfile.debian310 +0 -130
- package/docker/build-manifest.cjs +0 -28
- package/docker/docker-compose.yml +0 -10
- package/docker/docker-entrypoint.sh +0 -147
- package/docker/verify-build.cjs +0 -49
- package/docs/PROJECT_ARCHITECTURE.md +0 -550
- package/docs/development/node-cron-migration.md +0 -49
- package/docs/development/task-startup.md +0 -78
- package/docs/releases/2.22.0-validation.md +0 -49
- package/docs/releases/2.22.0.md +0 -62
- package/docs/releases/2.23.0.md +0 -33
- package/docs/script-history.md +0 -53
- package/sample/tool.ts +0 -40
- package/scripts/benchmark-execution.cjs +0 -96
- package/scripts/benchmark-script-history.cjs +0 -39
- package/scripts/publish-static.sh +0 -34
- package/scripts/sync-static.sh +0 -20
- package/scripts/wait-for-mirror.sh +0 -214
- package/scripts/write-build-info.cjs +0 -27
- package/shell/pub.sh +0 -28
- package/static/dist/255.8a80b983.async.js +0 -1
- package/static/dist/2901.2ca95295.async.js +0 -1
- package/static/dist/292.264757f0.async.js +0 -1
- package/static/dist/3600.7637c822.async.js +0 -1
- package/static/dist/445.a65ff63b.async.js +0 -1
- package/static/dist/5970.d3a6e7bd.async.js +0 -1
- package/static/dist/6212.9e6d9913.async.js +0 -1
- package/static/dist/6431.4603ad0e.async.js +0 -1
- package/static/dist/9066.605168f8.async.js +0 -1
- package/static/dist/9313.37acaf13.async.js +0 -1
- package/static/dist/layouts__index.633d3553.async.js +0 -1
- package/static/dist/layouts__index.adf0692f.chunk.css +0 -1
- package/static/dist/preload_helper.01fcd534.js +0 -1
- package/static/dist/src__pages__404.771168fc.async.js +0 -1
- package/static/dist/src__pages__config__index.9aba4054.async.js +0 -1
- package/static/dist/src__pages__crontab__detail.86b2eebb.async.js +0 -1
- package/static/dist/src__pages__crontab__index.ae4e06f2.async.js +0 -1
- package/static/dist/src__pages__dashboard__index.243c5a35.async.js +0 -1
- package/static/dist/src__pages__dependence__index.874d501f.async.js +0 -1
- package/static/dist/src__pages__dependence__modal.0fa8b421.async.js +0 -1
- package/static/dist/src__pages__diff__index.b94e5dc5.async.js +0 -1
- package/static/dist/src__pages__env__index.fd6fd2b0.async.js +0 -1
- package/static/dist/src__pages__error__index.aae50c94.async.js +0 -1
- package/static/dist/src__pages__initialization__index.82a2e967.async.js +0 -1
- package/static/dist/src__pages__login__index.a0fd5ed8.async.js +0 -1
- package/static/dist/src__pages__script__editModal.afabf073.async.js +0 -1
- package/static/dist/src__pages__script__index.fc575945.async.js +0 -1
- package/static/dist/src__pages__setting__checkUpdate.d175b154.async.js +0 -1
- package/static/dist/src__pages__setting__dependence.9c0f749b.async.js +0 -1
- package/static/dist/src__pages__setting__index.cb397741.async.js +0 -1
- package/static/dist/src__pages__setting__loginLog.e0a1f54d.async.js +0 -1
- package/static/dist/src__pages__setting__other.3d0b8492.async.js +0 -1
- package/static/dist/src__pages__setting__systemLog.b3046955.async.js +0 -1
- package/static/dist/src__pages__subscription__index.43086a06.async.js +0 -1
- package/static/dist/src__pages__subscription__modal.30868ba8.async.js +0 -1
- package/static/dist/umi.3a24a9fa.js +0 -1
- package/test/back/advisory-input-security.test.cjs +0 -416
- package/test/back/auth-security.test.cjs +0 -74
- package/test/back/build-provenance.test.cjs +0 -150
- package/test/back/code-scanning-security.test.cjs +0 -189
- package/test/back/cron-log-name.test.cjs +0 -110
- package/test/back/cron-macros.test.cjs +0 -51
- package/test/back/cron-schedule-compatibility.test.cjs +0 -69
- package/test/back/cron-scheduler-routing.test.cjs +0 -59
- package/test/back/cron-validation.test.cjs +0 -45
- package/test/back/dashboard-failures.test.cjs +0 -173
- package/test/back/database-bootstrap.test.cjs +0 -193
- package/test/back/dependence-cache-status.test.cjs +0 -125
- package/test/back/deprecated-file-routes.test.cjs +0 -82
- package/test/back/draft-path-security.test.cjs +0 -235
- package/test/back/ecosystem.test.cjs +0 -28
- package/test/back/env-import-security.test.cjs +0 -91
- package/test/back/env-name-parsing.test.cjs +0 -96
- package/test/back/execution-lifecycle.test.cjs +0 -236
- package/test/back/file-access-scope.test.cjs +0 -180
- package/test/back/file-access-security.test.cjs +0 -47
- package/test/back/fileTreeListing.test.cjs +0 -57
- package/test/back/grpc-cron-response.test.cjs +0 -60
- package/test/back/grpc-mtls-security.test.cjs +0 -136
- package/test/back/http-exclusive-listen.test.cjs +0 -31
- package/test/back/http-security.test.cjs +0 -313
- package/test/back/legacy-cron-recovery.test.cjs +0 -76
- package/test/back/linux-mirror-result.test.cjs +0 -176
- package/test/back/listen-security.test.cjs +0 -68
- package/test/back/log-path-security.test.cjs +0 -158
- package/test/back/logReader.test.cjs +0 -72
- package/test/back/manual-execution.test.cjs +0 -85
- package/test/back/manual-stop-claim.test.cjs +0 -220
- package/test/back/metrics.test.cjs +0 -34
- package/test/back/mirror-status.test.cjs +0 -257
- package/test/back/monitoring.test.cjs +0 -73
- package/test/back/node-cron-migration.test.cjs +0 -65
- package/test/back/node-path-cache.test.cjs +0 -202
- package/test/back/node-path-lock.test.cjs +0 -182
- package/test/back/npm-publication.test.cjs +0 -70
- package/test/back/preload-lazy-notify.test.cjs +0 -168
- package/test/back/primary-apm.test.cjs +0 -24
- package/test/back/process-exit-state.test.cjs +0 -81
- package/test/back/process-stop-signal.test.cjs +0 -77
- package/test/back/protected-path-case.test.cjs +0 -58
- package/test/back/qlServiceLogCommand.test.cjs +0 -128
- package/test/back/queued-cron-invalidation.test.cjs +0 -98
- package/test/back/restart-instance-recovery.test.cjs +0 -116
- package/test/back/retention.test.cjs +0 -131
- package/test/back/role-loading.test.cjs +0 -118
- package/test/back/schedule-health.test.cjs +0 -86
- package/test/back/scheduler-bulk-recovery.test.cjs +0 -40
- package/test/back/scheduler-concurrency.test.cjs +0 -411
- package/test/back/scheduler-file-lock.test.cjs +0 -51
- package/test/back/scheduler-mutation.test.cjs +0 -312
- package/test/back/scheduler-readiness.test.cjs +0 -85
- package/test/back/scheduler-reconciliation.test.cjs +0 -206
- package/test/back/scheduler-rpc-timeout.test.cjs +0 -49
- package/test/back/schema-migrations.test.cjs +0 -127
- package/test/back/script-file-access.test.cjs +0 -210
- package/test/back/script-history-api.test.cjs +0 -551
- package/test/back/script-history.test.cjs +0 -383
- package/test/back/shell-api-parsing.test.cjs +0 -184
- package/test/back/shell-translation-output.test.cjs +0 -16
- package/test/back/shell-upgrade.test.cjs +0 -312
- package/test/back/shellApiToken.test.cjs +0 -151
- package/test/back/sock-polling.test.cjs +0 -297
- package/test/back/sock-security.test.cjs +0 -72
- package/test/back/ssh-config-home.test.cjs +0 -113
- package/test/back/start-env-preservation.test.cjs +0 -53
- package/test/back/static-mirror-trigger.test.cjs +0 -441
- package/test/back/static-mirror.test.cjs +0 -179
- package/test/back/stop-failure-feedback.test.cjs +0 -158
- package/test/back/stop-race.test.cjs +0 -171
- package/test/back/subscription-cleanup.test.cjs +0 -53
- package/test/back/subscription-mutation-lock.test.cjs +0 -83
- package/test/back/subscription-review-regression.test.cjs +0 -607
- package/test/back/subscription-stop-state.test.cjs +0 -66
- package/test/back/subscription-storage-regression.test.cjs +0 -553
- package/test/back/system-dependence-cache.test.cjs +0 -127
- package/test/back/system-export-history.test.cjs +0 -119
- package/test/back/systemTokenRenewal.test.cjs +0 -497
- package/test/back/task-shell-lifecycle.test.cjs +0 -194
- package/test/back/task-time.test.cjs +0 -116
- package/test/back/unique-constraint-error.test.cjs +0 -72
- package/test/back/upgrade-guards.test.cjs +0 -285
- package/test/back/upgrade-lifecycle.test.cjs +0 -288
- package/test/back/upgrade-transaction.test.cjs +0 -133
- package/test/back/user-api.test.cjs +0 -99
- package/test/back/user-security.test.cjs +0 -349
- package/test/back/worker-apm.test.cjs +0 -84
- package/test/back/wpush-grpc.test.cjs +0 -116
- package/test/fixtures/legacy-cron.json +0 -1371
- package/test/front/cron-log-pagination.test.cjs +0 -214
- package/test/front/diff-file-routing.test.cjs +0 -126
- package/test/front/http-auth.test.cjs +0 -152
- package/test/front/http-error.test.cjs +0 -29
- package/test/front/script-history-save.test.cjs +0 -121
- package/test/helpers/load-security-module.cjs +0 -42
- package/test/helpers/upgrade-fixture.cjs +0 -30
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
const test = require('node:test');
|
|
2
|
-
const assert = require('node:assert/strict');
|
|
3
|
-
const fs = require('node:fs/promises');
|
|
4
|
-
const os = require('node:os');
|
|
5
|
-
const path = require('node:path');
|
|
6
|
-
const { spawn } = require('node:child_process');
|
|
7
|
-
const { once } = require('node:events');
|
|
8
|
-
const { setTimeout: delay } = require('node:timers/promises');
|
|
9
|
-
const { Sequelize, DataTypes } = require('sequelize');
|
|
10
|
-
const { status } = require('@grpc/grpc-js');
|
|
11
|
-
const load = require('../helpers/load-security-module.cjs');
|
|
12
|
-
|
|
13
|
-
function gate() {
|
|
14
|
-
let release;
|
|
15
|
-
const promise = new Promise((resolve) => {
|
|
16
|
-
release = resolve;
|
|
17
|
-
});
|
|
18
|
-
return { promise, release };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function fixture(t) {
|
|
22
|
-
const root = await fs.mkdtemp(
|
|
23
|
-
path.join(os.tmpdir(), 'ql-scheduler-mutation-'),
|
|
24
|
-
);
|
|
25
|
-
const db = new Sequelize({
|
|
26
|
-
dialect: 'sqlite',
|
|
27
|
-
storage: ':memory:',
|
|
28
|
-
logging: false,
|
|
29
|
-
});
|
|
30
|
-
const crons = db.define('Cron', {
|
|
31
|
-
name: DataTypes.STRING,
|
|
32
|
-
command: DataTypes.STRING,
|
|
33
|
-
schedule: DataTypes.STRING,
|
|
34
|
-
isDisabled: DataTypes.INTEGER,
|
|
35
|
-
saved: DataTypes.BOOLEAN,
|
|
36
|
-
queued_token: DataTypes.STRING,
|
|
37
|
-
});
|
|
38
|
-
await db.sync();
|
|
39
|
-
t.after(async () => {
|
|
40
|
-
await db.close();
|
|
41
|
-
await fs.rm(root, { recursive: true, force: true });
|
|
42
|
-
});
|
|
43
|
-
const jobs = new Map();
|
|
44
|
-
const client = {
|
|
45
|
-
addCron: async (items, replace) => {
|
|
46
|
-
if (replace) jobs.clear();
|
|
47
|
-
items.forEach((item) => jobs.set(item.id, item.command));
|
|
48
|
-
},
|
|
49
|
-
delCron: async (ids) => ids.forEach((id) => jobs.delete(id)),
|
|
50
|
-
};
|
|
51
|
-
const CronService = load('back/services/cron.ts', {
|
|
52
|
-
'../config': {
|
|
53
|
-
crontabFile: path.join(root, 'crontab.list'),
|
|
54
|
-
logPath: root,
|
|
55
|
-
},
|
|
56
|
-
'../data/cron': {
|
|
57
|
-
CrontabModel: crons,
|
|
58
|
-
Crontab: class {
|
|
59
|
-
constructor(options) {
|
|
60
|
-
Object.assign(this, { isDisabled: 0 }, options);
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
'../data/runningInstance': {},
|
|
65
|
-
'../config/util': { isDemoEnv: () => false },
|
|
66
|
-
'../config/const': {},
|
|
67
|
-
'../schedule/client': client,
|
|
68
|
-
'../shared/pLimit': {},
|
|
69
|
-
'../shared/utils': {},
|
|
70
|
-
'../shared/i18n': { t: (s) => s },
|
|
71
|
-
'../shared/logReader': {},
|
|
72
|
-
'../shared/logStreamManager': {},
|
|
73
|
-
}).default;
|
|
74
|
-
const service = new CronService({ error() {}, warn() {}, info() {} });
|
|
75
|
-
service.getLogName = async () => 'task';
|
|
76
|
-
service.shouldUseCronClient = () => true;
|
|
77
|
-
service.makeCommand = (doc) => doc.command;
|
|
78
|
-
service.crontabs = async () => ({ data: await crons.findAll({ raw: true }) });
|
|
79
|
-
service.setCrontab = async () => {};
|
|
80
|
-
return { service, crons, jobs, client, root };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
for (const operation of ['create', 'update', 'remove', 'disabled', 'enabled']) {
|
|
84
|
-
test(`recovery snapshot cannot overwrite concurrent ${operation}`, async (t) => {
|
|
85
|
-
const { service, crons, jobs } = await fixture(t);
|
|
86
|
-
await crons.create({
|
|
87
|
-
id: 1,
|
|
88
|
-
command: 'old',
|
|
89
|
-
schedule: '* * * * *',
|
|
90
|
-
isDisabled: operation === 'enabled' ? 1 : 0,
|
|
91
|
-
});
|
|
92
|
-
const entered = gate(),
|
|
93
|
-
release = gate();
|
|
94
|
-
let first = true;
|
|
95
|
-
service.setCrontab = async () => {
|
|
96
|
-
if (first) {
|
|
97
|
-
first = false;
|
|
98
|
-
entered.release();
|
|
99
|
-
await release.promise;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
const recovery = service.autosave_crontab(true);
|
|
103
|
-
await entered.promise;
|
|
104
|
-
const before = await crons.findAll({ raw: true });
|
|
105
|
-
const mutation =
|
|
106
|
-
operation === 'create'
|
|
107
|
-
? service.create({ command: 'new', schedule: '* * * * *' })
|
|
108
|
-
: operation === 'update'
|
|
109
|
-
? service.update({ id: 1, command: 'new' })
|
|
110
|
-
: service[operation]([1]);
|
|
111
|
-
await delay(50);
|
|
112
|
-
assert.deepEqual(
|
|
113
|
-
await crons.findAll({ raw: true }),
|
|
114
|
-
before,
|
|
115
|
-
'DB writes must also wait for recovery',
|
|
116
|
-
);
|
|
117
|
-
release.release();
|
|
118
|
-
await Promise.all([recovery, mutation]);
|
|
119
|
-
const rows = await crons.findAll({ raw: true });
|
|
120
|
-
assert.deepEqual(
|
|
121
|
-
[...jobs.entries()].sort(),
|
|
122
|
-
rows
|
|
123
|
-
.filter((row) => !row.isDisabled)
|
|
124
|
-
.map((row) => [String(row.id), row.command])
|
|
125
|
-
.sort(),
|
|
126
|
-
);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
test('recovery waits for an admitted mutation to finish registration before reading the DB', async (t) => {
|
|
131
|
-
const { service, client, jobs } = await fixture(t);
|
|
132
|
-
const entered = gate(),
|
|
133
|
-
release = gate();
|
|
134
|
-
const add = client.addCron;
|
|
135
|
-
client.addCron = async (items, replace) => {
|
|
136
|
-
if (!replace) {
|
|
137
|
-
entered.release();
|
|
138
|
-
await release.promise;
|
|
139
|
-
}
|
|
140
|
-
return add(items, replace);
|
|
141
|
-
};
|
|
142
|
-
const mutation = service.create({ command: 'new', schedule: '* * * * *' });
|
|
143
|
-
await entered.promise;
|
|
144
|
-
let reads = 0;
|
|
145
|
-
const read = service.crontabs;
|
|
146
|
-
service.crontabs = async () => {
|
|
147
|
-
reads++;
|
|
148
|
-
return read();
|
|
149
|
-
};
|
|
150
|
-
const recovery = service.autosave_crontab(true);
|
|
151
|
-
await delay(50);
|
|
152
|
-
assert.equal(reads, 0);
|
|
153
|
-
release.release();
|
|
154
|
-
await Promise.all([mutation, recovery]);
|
|
155
|
-
assert.deepEqual([...jobs.values()], ['new']);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
for (const operation of ['create', 'update', 'enabled']) {
|
|
159
|
-
test(`${operation} preserves scheduler 503 after rollback and releases its lock`, async (t) => {
|
|
160
|
-
const { service, crons, client } = await fixture(t);
|
|
161
|
-
if (operation !== 'create')
|
|
162
|
-
await crons.create({
|
|
163
|
-
id: 1,
|
|
164
|
-
command: 'old',
|
|
165
|
-
schedule: '* * * * *',
|
|
166
|
-
isDisabled: operation === 'enabled' ? 1 : 0,
|
|
167
|
-
});
|
|
168
|
-
const cause = Object.assign(Error('unavailable'), { status: 503 });
|
|
169
|
-
client.addCron = async () => {
|
|
170
|
-
throw cause;
|
|
171
|
-
};
|
|
172
|
-
const mutation =
|
|
173
|
-
operation === 'create'
|
|
174
|
-
? service.create({ command: 'new', schedule: '* * * * *' })
|
|
175
|
-
: operation === 'update'
|
|
176
|
-
? service.update({ id: 1, command: 'new' })
|
|
177
|
-
: service.enabled([1]);
|
|
178
|
-
await assert.rejects(
|
|
179
|
-
mutation,
|
|
180
|
-
(err) =>
|
|
181
|
-
err.status === 503 && err.cause === cause && /回滚/.test(err.message),
|
|
182
|
-
);
|
|
183
|
-
if (operation === 'create') assert.equal(await crons.count(), 0);
|
|
184
|
-
else {
|
|
185
|
-
const row = await crons.findByPk(1);
|
|
186
|
-
assert.equal(row.command, 'old');
|
|
187
|
-
assert.equal(row.isDisabled, operation === 'enabled' ? 1 : 0);
|
|
188
|
-
}
|
|
189
|
-
client.addCron = async () => {};
|
|
190
|
-
await service.autosave_crontab(true);
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
test(
|
|
195
|
-
'scheduler lock excludes a second OS process and leaves no lock after completion',
|
|
196
|
-
{ timeout: 10000 },
|
|
197
|
-
async (t) => {
|
|
198
|
-
const root = await fs.mkdtemp(
|
|
199
|
-
path.join(os.tmpdir(), 'ql-scheduler-process-'),
|
|
200
|
-
);
|
|
201
|
-
t.after(() => fs.rm(root, { recursive: true, force: true }));
|
|
202
|
-
const config = { crontabFile: path.join(root, 'crontab.list') };
|
|
203
|
-
const { withSchedulerMutation } = load(
|
|
204
|
-
'back/shared/schedulerMutationLock.ts',
|
|
205
|
-
{ '../config': config },
|
|
206
|
-
);
|
|
207
|
-
const entered = gate(),
|
|
208
|
-
release = gate();
|
|
209
|
-
const owner = withSchedulerMutation(async () => {
|
|
210
|
-
entered.release();
|
|
211
|
-
await release.promise;
|
|
212
|
-
});
|
|
213
|
-
await entered.promise;
|
|
214
|
-
const child = spawn(
|
|
215
|
-
process.execPath,
|
|
216
|
-
[
|
|
217
|
-
'-e',
|
|
218
|
-
`
|
|
219
|
-
const load = require('./test/helpers/load-security-module.cjs');
|
|
220
|
-
const { withSchedulerMutation } = load('back/shared/schedulerMutationLock.ts', {'../config': JSON.parse(process.argv[1])});
|
|
221
|
-
process.send('attempting');
|
|
222
|
-
withSchedulerMutation(async () => process.send('entered')).then(() => process.disconnect()).catch(err => { console.error(err); process.exit(1); });
|
|
223
|
-
`,
|
|
224
|
-
JSON.stringify(config),
|
|
225
|
-
],
|
|
226
|
-
{ stdio: ['ignore', 'pipe', 'pipe', 'ipc'] },
|
|
227
|
-
);
|
|
228
|
-
t.after(() => {
|
|
229
|
-
if (child.exitCode === null) child.kill('SIGKILL');
|
|
230
|
-
release.release();
|
|
231
|
-
});
|
|
232
|
-
const closed = once(child, 'close');
|
|
233
|
-
assert.equal((await once(child, 'message'))[0], 'attempting');
|
|
234
|
-
let acquired = false;
|
|
235
|
-
const acquisition = once(child, 'message').then(([message]) => {
|
|
236
|
-
acquired = true;
|
|
237
|
-
assert.equal(message, 'entered');
|
|
238
|
-
});
|
|
239
|
-
await delay(150);
|
|
240
|
-
assert.equal(acquired, false);
|
|
241
|
-
release.release();
|
|
242
|
-
await owner;
|
|
243
|
-
await acquisition;
|
|
244
|
-
assert.equal((await closed)[0], 0);
|
|
245
|
-
await assert.rejects(fs.stat(`${config.crontabFile}.scheduler.lock`), {
|
|
246
|
-
code: 'ENOENT',
|
|
247
|
-
});
|
|
248
|
-
},
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
for (const operation of ['update', 'remove', 'disabled']) {
|
|
252
|
-
for (const code of [status.DEADLINE_EXCEEDED, status.UNAVAILABLE]) {
|
|
253
|
-
for (const applied of [false, true]) {
|
|
254
|
-
test(`${operation} aborts on RPC ${code} with deletion applied=${applied} and reconciles the original DB`, async (t) => {
|
|
255
|
-
const { service, crons, client, jobs } = await fixture(t);
|
|
256
|
-
await crons.create({
|
|
257
|
-
id: 1, command: 'old', schedule: '* * * * *', isDisabled: 0,
|
|
258
|
-
});
|
|
259
|
-
jobs.set('1', 'old');
|
|
260
|
-
const before = await crons.findAll({ raw: true });
|
|
261
|
-
const failure = Object.assign(Error('uncertain deletion'), { code, status: 503 });
|
|
262
|
-
let deletes = 0;
|
|
263
|
-
client.delCron = async (ids) => {
|
|
264
|
-
deletes++;
|
|
265
|
-
if (applied) ids.forEach((id) => jobs.delete(id));
|
|
266
|
-
throw failure;
|
|
267
|
-
};
|
|
268
|
-
const add = client.addCron;
|
|
269
|
-
client.addCron = async () => assert.fail('must not register after failed deletion');
|
|
270
|
-
service.setCrontab = async () => assert.fail('must not publish after failed deletion');
|
|
271
|
-
await assert.rejects(
|
|
272
|
-
operation === 'update'
|
|
273
|
-
? service.update({ id: 1, command: 'new' })
|
|
274
|
-
: service[operation]([1]),
|
|
275
|
-
(error) => error === failure && error.status === 503,
|
|
276
|
-
);
|
|
277
|
-
assert.equal(deletes, 1, 'must not replay an uncertain deletion');
|
|
278
|
-
assert.deepEqual(await crons.findAll({ raw: true }), before);
|
|
279
|
-
client.addCron = add;
|
|
280
|
-
service.setCrontab = async () => {};
|
|
281
|
-
await service.autosave_crontab(true);
|
|
282
|
-
assert.deepEqual([...jobs.entries()], [['1', 'old']]);
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
test('configuration rollback cannot restore an obsolete manual queue token', async (t) => {
|
|
289
|
-
const { service, crons, client } = await fixture(t);
|
|
290
|
-
await crons.create({
|
|
291
|
-
id: 1,
|
|
292
|
-
command: 'old',
|
|
293
|
-
schedule: '* * * * *',
|
|
294
|
-
isDisabled: 0,
|
|
295
|
-
queued_token: 'old-token',
|
|
296
|
-
});
|
|
297
|
-
let first = true;
|
|
298
|
-
client.addCron = async () => {
|
|
299
|
-
if (first) {
|
|
300
|
-
first = false;
|
|
301
|
-
await crons.update({ queued_token: 'new-token' }, { where: { id: 1 } });
|
|
302
|
-
throw Object.assign(Error('unavailable'), { status: 503 });
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
await assert.rejects(
|
|
306
|
-
service.update({ id: 1, command: 'new' }),
|
|
307
|
-
(err) => err.status === 503,
|
|
308
|
-
);
|
|
309
|
-
const row = await crons.findByPk(1);
|
|
310
|
-
assert.equal(row.command, 'old');
|
|
311
|
-
assert.equal(row.queued_token, 'new-token');
|
|
312
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
const test=require('node:test');
|
|
2
|
-
const assert=require('node:assert/strict');
|
|
3
|
-
const {setTimeout:sleep}=require('node:timers/promises');
|
|
4
|
-
const {SchedulerReadiness}=require('../../back/shared/schedulerReadiness');
|
|
5
|
-
const load=require('../helpers/load-security-module.cjs');
|
|
6
|
-
const fs=require('node:fs');
|
|
7
|
-
const ts=require('typescript');
|
|
8
|
-
|
|
9
|
-
test('readiness stays false through failed restoration and retries without idle polling',async()=>{
|
|
10
|
-
let probes=0,restores=0,fail=true;
|
|
11
|
-
const state=new SchedulerReadiness(async()=>{probes++;},10);
|
|
12
|
-
state.configure(async()=>{restores++;if(fail)throw Error('registration failed');});
|
|
13
|
-
assert.equal(await state.recover(),false);assert.equal(await state.check(),false);
|
|
14
|
-
fail=false;await sleep(40);assert.equal(await state.check(),true);assert.ok(restores>=2);
|
|
15
|
-
const before=probes;await sleep(40);assert.equal(probes,before);
|
|
16
|
-
});
|
|
17
|
-
test('single-flight recovery cannot mark an invalidated generation ready',async()=>{
|
|
18
|
-
let release,restores=0;
|
|
19
|
-
const state=new SchedulerReadiness(async()=>{},10);
|
|
20
|
-
state.configure(async()=>{if(++restores===1)await new Promise(r=>release=r);});
|
|
21
|
-
const a=state.recover();assert.equal(state.recover(),a);await sleep(1);
|
|
22
|
-
state.invalidate();release();assert.equal(await a,false);assert.equal(await state.check(),false);
|
|
23
|
-
await sleep(30);assert.equal(await state.check(),true);assert.equal(restores,2);
|
|
24
|
-
});
|
|
25
|
-
test('mutation waiting is bounded, a later recovery can succeed',async()=>{
|
|
26
|
-
let release;
|
|
27
|
-
const state=new SchedulerReadiness(async()=>{},10);state.configure(()=>new Promise(r=>release=r));
|
|
28
|
-
await assert.rejects(state.ensureReady(15),e=>e.status===503);
|
|
29
|
-
release();await sleep(1);assert.equal(await state.check(),true);
|
|
30
|
-
});
|
|
31
|
-
test('probe failure immediately invalidates a previously ready scheduler',async()=>{
|
|
32
|
-
let fail=false;
|
|
33
|
-
const state=new SchedulerReadiness(async()=>{if(fail)throw Error('unavailable');},10);
|
|
34
|
-
state.configure(async()=>{});assert.equal(await state.recover(),true);
|
|
35
|
-
fail=true;assert.equal(await state.check(),false);
|
|
36
|
-
fail=false;await sleep(40);assert.equal(await state.check(),true);
|
|
37
|
-
});
|
|
38
|
-
test('health uses actual readiness and returns HTTP 503 until recovery',async(t)=>{
|
|
39
|
-
let ready=false;const express=require('express');
|
|
40
|
-
const {HealthService}=load('back/services/health.ts',{
|
|
41
|
-
typedi:{Service:()=>x=>x},'../loaders/logger':{error(){}},'./http':{},
|
|
42
|
-
'../schedule/client':{readiness:{check:async()=>ready}},
|
|
43
|
-
});
|
|
44
|
-
const service=new HealthService({getServer:()=>({})});
|
|
45
|
-
const app=express();load('back/api/health.ts',{
|
|
46
|
-
typedi:{get:()=>service},'../services/health':{HealthService},'../loaders/logger':{error(){}},
|
|
47
|
-
}).default(app);
|
|
48
|
-
const server=app.listen(0,'127.0.0.1');await new Promise(r=>server.once('listening',r));
|
|
49
|
-
t.after(()=>new Promise(r=>{server.close(r);server.closeAllConnections();}));
|
|
50
|
-
for(const expected of [503,200,503]){
|
|
51
|
-
ready=expected===200;const r=await fetch(`http://127.0.0.1:${server.address().port}/health`);const b=await r.json();
|
|
52
|
-
assert.equal(r.status,expected);assert.equal(b.code,expected);assert.equal(b.data.services.grpc,ready);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
test('recovery registration errors propagate while ordinary autosave retains file synchronization',async()=>{
|
|
56
|
-
const source=fs.readFileSync('back/services/cron.ts','utf8');const a=source.indexOf(' public async autosave_crontab('),z=source.indexOf(' public async bootTask',a);
|
|
57
|
-
const js=ts.transpileModule('class Fixture {\n'+source.slice(a,z)+'}\nmodule.exports=Fixture;', {compilerOptions:{target:ts.ScriptTarget.ES2020}}).outputText;
|
|
58
|
-
const module={exports:{}};let files=0;
|
|
59
|
-
new Function('module','isDemoEnv','cronClient','withSchedulerMutation',js)(module,()=>false,{addCron:async()=>{throw Error('registration unavailable');}},fn=>fn());
|
|
60
|
-
const fixture=new module.exports();fixture.crontabs=async()=>({data:[]});fixture.setCrontab=async()=>{files++;};fixture.logger={warn(){}};
|
|
61
|
-
await fixture.autosave_crontab();assert.equal(files,1);
|
|
62
|
-
await assert.rejects(fixture.autosave_crontab(true),/registration unavailable/);assert.equal(files,2);
|
|
63
|
-
});
|
|
64
|
-
test('scheduler probe uses the cron channel and failed writes are not replayed',async()=>{
|
|
65
|
-
const calls=[];const fake={
|
|
66
|
-
waitForReady(deadline,cb){calls.push(['wait',deadline]);cb();},
|
|
67
|
-
makeUnaryRequest(path,serialize,deserialize,request,options,cb){calls.push(['probe',path,request,options]);cb(null,{status:1});},
|
|
68
|
-
addCron(request,metadata,options,cb){calls.push(['add',request,options]);cb(Object.assign(Error('invalid'),{code:3}));},
|
|
69
|
-
};
|
|
70
|
-
const client=load('back/schedule/client.ts',{
|
|
71
|
-
'../protos/cron':{CronClient:class{constructor(){return fake;}}},
|
|
72
|
-
'../config':{grpcPort:5500},'../config/grpcCerts':{getGrpcCerts:()=>({caCert:'ca',clientKey:'key',clientCert:'cert'})},
|
|
73
|
-
'@grpc/grpc-js':{...require('@grpc/grpc-js'),credentials:{createSsl:()=>({})},status:{UNAVAILABLE:14},Metadata:class{}},
|
|
74
|
-
}).default;
|
|
75
|
-
client.readiness.configure(async()=>{});assert.equal(await client.readiness.recover(),true);
|
|
76
|
-
assert.ok(calls.filter(x=>x[0]==='probe').every(x=>x[1]==='/com.ql.health.Health/Check'&&x[2].service==='scheduler'&&x[3].deadline>Date.now()));
|
|
77
|
-
await assert.rejects(client.addCron([]),/invalid/);assert.equal(calls.filter(x=>x[0]==='add').length,1);
|
|
78
|
-
});
|
|
79
|
-
test('scheduler health probe never calls back into HTTP health',async()=>{
|
|
80
|
-
const {check}=load('back/schedule/health.ts',{
|
|
81
|
-
'../config':{},undici:{request:()=>{throw Error('recursive HTTP health call');}},
|
|
82
|
-
});
|
|
83
|
-
const result=await new Promise(resolve=>check({request:{service:'scheduler'}},(error,response)=>resolve({error,response})));
|
|
84
|
-
assert.equal(result.error,null);assert.deepEqual(result.response,{status:1});
|
|
85
|
-
});
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
const test = require('node:test');
|
|
2
|
-
const assert = require('node:assert/strict');
|
|
3
|
-
const fs = require('node:fs');
|
|
4
|
-
const ts = require('typescript');
|
|
5
|
-
const load = require('../helpers/load-security-module.cjs');
|
|
6
|
-
const { SchedulerReadiness } = require('../../back/shared/schedulerReadiness');
|
|
7
|
-
const { AddCronRequest } = require('../../back/protos/cron');
|
|
8
|
-
const { getInvalidCronSchedules } = require('../../back/shared/cronSchedule');
|
|
9
|
-
|
|
10
|
-
function fixture(client) {
|
|
11
|
-
const source = fs.readFileSync('back/services/cron.ts', 'utf8');
|
|
12
|
-
const a = source.indexOf(' public async autosave_crontab(');
|
|
13
|
-
const z = source.indexOf(' public async bootTask', a);
|
|
14
|
-
const js = ts.transpileModule(
|
|
15
|
-
'class Fixture {\n' + source.slice(a, z) + '}\nmodule.exports=Fixture;',
|
|
16
|
-
{ compilerOptions: { target: ts.ScriptTarget.ES2020 } },
|
|
17
|
-
).outputText;
|
|
18
|
-
const module = { exports: {} };
|
|
19
|
-
new Function('module', 'isDemoEnv', 'cronClient', 'withSchedulerMutation', 'getInvalidCronSchedules', js)(
|
|
20
|
-
module,
|
|
21
|
-
() => false,
|
|
22
|
-
client,
|
|
23
|
-
(fn) => fn(),
|
|
24
|
-
getInvalidCronSchedules,
|
|
25
|
-
);
|
|
26
|
-
const service = new module.exports();
|
|
27
|
-
service.setCrontab = async () => {};
|
|
28
|
-
service.logger = { warn() {} };
|
|
29
|
-
service.shouldUseCronClient = () => true;
|
|
30
|
-
service.makeCommand = () => 'true';
|
|
31
|
-
return service;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
test('recovery reconciles a surviving scheduler after missed deletes and disables, including an empty DB', async () => {
|
|
35
|
-
const cancelled = [];
|
|
36
|
-
const stacks = new Map(
|
|
37
|
-
['removed', 'disabled', 'kept'].map((id) => [
|
|
38
|
-
id,
|
|
39
|
-
[{ cancel: () => cancelled.push(id) }],
|
|
40
|
-
]),
|
|
41
|
-
);
|
|
42
|
-
const { addCron } = load('back/schedule/addCron.ts', {
|
|
43
|
-
'./data': { scheduleStacks: stacks },
|
|
44
|
-
'../shared/cronScheduler': {
|
|
45
|
-
createCronJob: (_schedule, _callback, options) => ({
|
|
46
|
-
start() {}, cancel: () => cancelled.push(options.name.split(':')[0]),
|
|
47
|
-
}),
|
|
48
|
-
},
|
|
49
|
-
'../shared/runCron': {},
|
|
50
|
-
'../loaders/logger': { info() {}, warn() {} },
|
|
51
|
-
'../shared/i18n': { tf: (s) => s },
|
|
52
|
-
});
|
|
53
|
-
const client = {
|
|
54
|
-
addCron: async (crons, replace) => {
|
|
55
|
-
// Exercise the real protobuf field, not just a JavaScript-only flag.
|
|
56
|
-
const request = AddCronRequest.decode(
|
|
57
|
-
AddCronRequest.encode({ crons, replace }).finish(),
|
|
58
|
-
);
|
|
59
|
-
await new Promise((resolve, reject) =>
|
|
60
|
-
addCron({ request }, (err) => (err ? reject(err) : resolve())),
|
|
61
|
-
);
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
const service = fixture(client);
|
|
65
|
-
let rows = [
|
|
66
|
-
{ id: 'kept', schedule: '* * * * *', isDisabled: 0 },
|
|
67
|
-
{ id: 'disabled', schedule: '* * * * *', isDisabled: 1 },
|
|
68
|
-
];
|
|
69
|
-
service.crontabs = async () => ({ data: rows });
|
|
70
|
-
const state = new SchedulerReadiness(async () => {});
|
|
71
|
-
state.configure(() => service.autosave_crontab(true));
|
|
72
|
-
assert.equal(await state.recover(), true);
|
|
73
|
-
assert.equal(await state.check(), true);
|
|
74
|
-
assert.deepEqual([...stacks.keys()], ['kept']);
|
|
75
|
-
assert.deepEqual(cancelled.sort(), ['disabled', 'kept', 'removed']);
|
|
76
|
-
rows = [];
|
|
77
|
-
state.invalidate();
|
|
78
|
-
assert.equal(await state.recover(), true);
|
|
79
|
-
assert.equal(stacks.size, 0);
|
|
80
|
-
assert.equal(await state.check(), true);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test('invalid replacement leaves the previous schedule intact', async () => {
|
|
84
|
-
const stacks = new Map([
|
|
85
|
-
[
|
|
86
|
-
'old',
|
|
87
|
-
[
|
|
88
|
-
{
|
|
89
|
-
cancel: () => {
|
|
90
|
-
throw Error('must not cancel');
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
],
|
|
95
|
-
]);
|
|
96
|
-
const { addCron } = load('back/schedule/addCron.ts', {
|
|
97
|
-
'./data': { scheduleStacks: stacks },
|
|
98
|
-
'../shared/runCron': {},
|
|
99
|
-
'../loaders/logger': {},
|
|
100
|
-
'../shared/i18n': { tf: (s) => s },
|
|
101
|
-
});
|
|
102
|
-
await assert.rejects(
|
|
103
|
-
new Promise((resolve, reject) =>
|
|
104
|
-
addCron(
|
|
105
|
-
{
|
|
106
|
-
request: {
|
|
107
|
-
replace: true,
|
|
108
|
-
crons: [{ id: 'bad', schedule: 'not a cron', extra_schedules: [] }],
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
(err) => (err ? reject(err) : resolve()),
|
|
112
|
-
),
|
|
113
|
-
),
|
|
114
|
-
);
|
|
115
|
-
assert.deepEqual([...stacks.keys()], ['old']);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
test('invalid persisted schedules cannot block recovery, valid jobs or HTTP health', async (t) => {
|
|
119
|
-
const stacks = new Map();
|
|
120
|
-
const warnings = [];
|
|
121
|
-
const { addCron } = load('back/schedule/addCron.ts', {
|
|
122
|
-
'./data': { scheduleStacks: stacks },
|
|
123
|
-
'../shared/runCron': {},
|
|
124
|
-
'../loaders/logger': { info() {}, warn() {} },
|
|
125
|
-
'../shared/i18n': { tf: require('node:util').format },
|
|
126
|
-
});
|
|
127
|
-
const client = { addCron: (crons, replace) => new Promise((resolve, reject) => {
|
|
128
|
-
addCron({ request: { crons, replace } }, (error) => error ? reject(error) : resolve());
|
|
129
|
-
}) };
|
|
130
|
-
const service = fixture(client);
|
|
131
|
-
let snapshot;
|
|
132
|
-
service.setCrontab = async (tabs) => { snapshot = tabs.data; };
|
|
133
|
-
service.logger.warn = (...args) => warnings.push(require('node:util').format(...args));
|
|
134
|
-
let rows = [
|
|
135
|
-
{ id: 'good', name: 'valid', schedule: '0 0/30 * * * ?', isDisabled: 0 },
|
|
136
|
-
{ id: 'bad-main', name: 'bad main', schedule: 'not a cron', isDisabled: 0 },
|
|
137
|
-
{ id: 'bad-extra', name: 'bad extra', schedule: '* * * * *', extra_schedules: [{ schedule: '0 70 * * * ?' }], isDisabled: 0 },
|
|
138
|
-
{ id: 'unsupported', name: 'unsupported', schedule: 'H * * * *', isDisabled: 0 },
|
|
139
|
-
{ id: 'disabled', name: 'disabled', schedule: 'bad', isDisabled: 1 },
|
|
140
|
-
];
|
|
141
|
-
service.crontabs = async () => ({ data: rows });
|
|
142
|
-
const state = new SchedulerReadiness(async () => {}, 60000);
|
|
143
|
-
t.after(() => {
|
|
144
|
-
clearTimeout(state.retry);
|
|
145
|
-
for (const jobs of stacks.values()) for (const job of jobs) job.cancel();
|
|
146
|
-
});
|
|
147
|
-
state.configure(() => service.autosave_crontab(true));
|
|
148
|
-
assert.equal(await state.recover(), true);
|
|
149
|
-
assert.deepEqual([...stacks.keys()], ['good']);
|
|
150
|
-
assert.deepEqual(snapshot.map((x) => x.id), ['good', 'disabled']);
|
|
151
|
-
assert.equal(rows.length, 5, 'persisted rows are preserved for editing');
|
|
152
|
-
assert.equal(rows[1].isDisabled, 0);
|
|
153
|
-
assert.equal(warnings.length, 3);
|
|
154
|
-
assert.match(warnings.join('\n'), /bad-main.*bad main.*not a cron/);
|
|
155
|
-
assert.match(warnings.join('\n'), /bad-extra.*0 70/);
|
|
156
|
-
const { HealthService } = load('back/services/health.ts', {
|
|
157
|
-
typedi: { Service: () => (x) => x }, './http': {},
|
|
158
|
-
'../schedule/client': { readiness: state }, '../loaders/logger': { error() {} },
|
|
159
|
-
});
|
|
160
|
-
const health = new HealthService({ getServer: () => ({}) });
|
|
161
|
-
assert.equal((await health.check()).status, 'ok');
|
|
162
|
-
rows = rows.filter((x) => x.id !== 'good');
|
|
163
|
-
assert.equal(await state.recover(), true, 'even all-invalid snapshots can recover');
|
|
164
|
-
assert.equal(stacks.size, 0);
|
|
165
|
-
assert.equal((await health.check()).status, 'ok');
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
test('pre-RPC channel failures invalidate readiness and return 503 without executing or replaying writes', async () => {
|
|
169
|
-
for (const method of ['addCron', 'delCron']) {
|
|
170
|
-
let invalidations = 0,
|
|
171
|
-
writes = 0;
|
|
172
|
-
const fake = {
|
|
173
|
-
waitForReady: (_deadline, cb) => cb(Error('channel unavailable')),
|
|
174
|
-
addCron: () => writes++,
|
|
175
|
-
delCron: () => writes++,
|
|
176
|
-
};
|
|
177
|
-
const client = load('back/schedule/client.ts', {
|
|
178
|
-
'../protos/cron': {
|
|
179
|
-
CronClient: class {
|
|
180
|
-
constructor() {
|
|
181
|
-
return fake;
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
'../config': { grpcPort: 5500 },
|
|
186
|
-
'../config/grpcCerts': {
|
|
187
|
-
getGrpcCerts: () => ({
|
|
188
|
-
caCert: 'ca',
|
|
189
|
-
clientKey: 'key',
|
|
190
|
-
clientCert: 'cert',
|
|
191
|
-
}),
|
|
192
|
-
},
|
|
193
|
-
'@grpc/grpc-js': {
|
|
194
|
-
...require('@grpc/grpc-js'),
|
|
195
|
-
credentials: { createSsl: () => ({}) },
|
|
196
|
-
},
|
|
197
|
-
}).default;
|
|
198
|
-
client.readiness.invalidate = () => invalidations++;
|
|
199
|
-
await assert.rejects(
|
|
200
|
-
client[method]([]),
|
|
201
|
-
(err) => err.status === 503 && /channel unavailable/.test(err.message),
|
|
202
|
-
);
|
|
203
|
-
assert.equal(invalidations, 1);
|
|
204
|
-
assert.equal(writes, 0);
|
|
205
|
-
}
|
|
206
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const test = require('node:test');
|
|
2
|
-
const assert = require('node:assert/strict');
|
|
3
|
-
const grpc = require('@grpc/grpc-js');
|
|
4
|
-
const load = require('../helpers/load-security-module.cjs');
|
|
5
|
-
|
|
6
|
-
for (const method of ['addCron', 'delCron']) {
|
|
7
|
-
test(`${method} invalidates an uncertain timed-out write without replaying it`, async () => {
|
|
8
|
-
let writes = 0;
|
|
9
|
-
let invalidations = 0;
|
|
10
|
-
const timeout = Object.assign(new Error('response deadline exceeded'), {
|
|
11
|
-
code: grpc.status.DEADLINE_EXCEEDED,
|
|
12
|
-
});
|
|
13
|
-
const fake = {
|
|
14
|
-
waitForReady: (_deadline, callback) => callback(),
|
|
15
|
-
[method]: (_request, _metadata, _options, callback) => {
|
|
16
|
-
// The server may have applied the write before the response was lost.
|
|
17
|
-
writes++;
|
|
18
|
-
callback(timeout);
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
const client = load('back/schedule/client.ts', {
|
|
22
|
-
'../protos/cron': {
|
|
23
|
-
CronClient: class {
|
|
24
|
-
constructor() {
|
|
25
|
-
return fake;
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
'../config': { grpcPort: 5500 },
|
|
30
|
-
'../config/grpcCerts': {
|
|
31
|
-
getGrpcCerts: () => ({
|
|
32
|
-
caCert: 'ca',
|
|
33
|
-
clientKey: 'key',
|
|
34
|
-
clientCert: 'cert',
|
|
35
|
-
}),
|
|
36
|
-
},
|
|
37
|
-
'@grpc/grpc-js': { ...grpc, credentials: { createSsl: () => ({}) } },
|
|
38
|
-
}).default;
|
|
39
|
-
client.readiness.invalidate = () => invalidations++;
|
|
40
|
-
await assert.rejects(client[method]([]), (error) => error === timeout);
|
|
41
|
-
assert.equal(
|
|
42
|
-
invalidations,
|
|
43
|
-
1,
|
|
44
|
-
'reconcile from the DB after an uncertain RPC result',
|
|
45
|
-
);
|
|
46
|
-
assert.equal(timeout.status, 503);
|
|
47
|
-
assert.equal(writes, 1, 'do not replay an uncertain mutation');
|
|
48
|
-
});
|
|
49
|
-
}
|