add cluster testing
parent
16097862fc
commit
8dbaf9534a
|
|
@ -32,6 +32,9 @@ jobs:
|
|||
- name: Copy Test Config
|
||||
run: cp ./data/config.testing.js ./data/config.js
|
||||
|
||||
- name: Test Application Startup
|
||||
run: npm run test:startup
|
||||
|
||||
- name: Code Climate (Before)
|
||||
if: ${{ github.event_name != 'pull_request' && env.CC_TEST_REPORTER_ID != '' && matrix.node == 16 }}
|
||||
run: |
|
||||
|
|
|
|||
18
bin/www.js
18
bin/www.js
|
|
@ -11,9 +11,15 @@ const directoryName = dirname(fileURLToPath(import.meta.url));
|
|||
const processCount = Math.min(configFunctions.getProperty('application.maximumProcesses'), os.cpus().length);
|
||||
debug(`Primary pid: ${process.pid}`);
|
||||
debug(`Launching ${processCount} processes`);
|
||||
cluster.setupPrimary({
|
||||
const clusterSettings = {
|
||||
exec: directoryName + '/wwwProcess.js'
|
||||
});
|
||||
};
|
||||
if (cluster.setupPrimary) {
|
||||
cluster.setupPrimary(clusterSettings);
|
||||
}
|
||||
else {
|
||||
cluster.setupMaster(clusterSettings);
|
||||
}
|
||||
for (let index = 0; index < processCount; index += 1) {
|
||||
cluster.fork();
|
||||
}
|
||||
|
|
@ -48,3 +54,11 @@ if (ntfyStartupConfig) {
|
|||
void ntfyPublish(ntfyShutdownMessage);
|
||||
});
|
||||
}
|
||||
if (process.env.STARTUP_TEST === 'true') {
|
||||
const killSeconds = 10;
|
||||
debug(`Killing processes in ${killSeconds} seconds...`);
|
||||
setTimeout(() => {
|
||||
debug('Killing processes');
|
||||
process.exit(0);
|
||||
}, 10000);
|
||||
}
|
||||
|
|
|
|||
23
bin/www.ts
23
bin/www.ts
|
|
@ -23,9 +23,15 @@ const processCount = Math.min(
|
|||
debug(`Primary pid: ${process.pid}`)
|
||||
debug(`Launching ${processCount} processes`)
|
||||
|
||||
cluster.setupPrimary({
|
||||
const clusterSettings = {
|
||||
exec: directoryName + '/wwwProcess.js'
|
||||
})
|
||||
}
|
||||
|
||||
if (cluster.setupPrimary) {
|
||||
cluster.setupPrimary(clusterSettings)
|
||||
} else {
|
||||
cluster.setupMaster(clusterSettings)
|
||||
}
|
||||
|
||||
for (let index = 0; index < processCount; index += 1) {
|
||||
cluster.fork()
|
||||
|
|
@ -69,3 +75,16 @@ if (ntfyStartupConfig) {
|
|||
void ntfyPublish(ntfyShutdownMessage)
|
||||
})
|
||||
}
|
||||
|
||||
if (process.env.STARTUP_TEST === 'true') {
|
||||
const killSeconds = 10
|
||||
|
||||
debug(`Killing processes in ${killSeconds} seconds...`)
|
||||
|
||||
setTimeout(() => {
|
||||
debug('Killing processes')
|
||||
|
||||
// eslint-disable-next-line no-process-exit, unicorn/no-process-exit
|
||||
process.exit(0)
|
||||
}, 10_000)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,13 @@
|
|||
"build:version": "npx genversion --es6 --semi version.js",
|
||||
"start": "cross-env NODE_ENV=production node ./bin/www",
|
||||
"dev:test": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* TEST_DATABASES=true nodemon ./bin/www.js",
|
||||
"dev:test:process": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* TEST_DATABASES=true nodemon ./bin/wwwProcess.js",
|
||||
"dev:live": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* nodemon ./bin/www.js",
|
||||
"cy:open": "cypress open --config-file cypress.config.js",
|
||||
"cy:run": "cypress run --config-file cypress.config.js",
|
||||
"cy:run:firefox": "cypress run --config-file cypress.config.js --browser firefox",
|
||||
"test": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* TEST_DATABASES=true mocha --timeout 30000 --exit",
|
||||
"test:startup": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* TEST_DATABASES=true STARTUP_TEST=true node ./bin/www.js",
|
||||
"coverage": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* TEST_DATABASES=true c8 --reporter=lcov --reporter=text --reporter=text-summary mocha --timeout 30000 --exit",
|
||||
"temp:legacy:importFromCsv": "cross-env NODE_ENV=dev DEBUG=lot-occupancy-system:* TEST_DATABASES=true node ./temp/legacy.importFromCsv.js",
|
||||
"temp:so:exportMaps": "node ./temp/so.exportMaps.js"
|
||||
|
|
|
|||
Loading…
Reference in New Issue