feat: wrapper to a single entrypoint to the stress test

This commit is contained in:
Sérgio Salgado 2021-01-14 17:17:22 +00:00 committed by Josh Harvey
parent 7794b91d20
commit 722a3d2853
4 changed files with 34 additions and 10 deletions

View file

@ -11,17 +11,23 @@ async function createMachines (numberOfMachines) {
)
}
function startServer () {
const forked = fork('test-server.js')
forked.send('start')
}
async function run (args = minimist(process.argv.slice(2))) {
const NUMBER_OF_MACHINES = args._[0]
const HAS_VARIANCE = args.v || false
startServer()
await createMachines(NUMBER_OF_MACHINES)
for (let i = 1; i <= NUMBER_OF_MACHINES; i++) {
const forked = fork('child.js')
forked.send({ machineIndex: i, hasVariance: HAS_VARIANCE })
forked.on('message', msg => {
console.log(`Message from child ${i}: ${msg}`)
console.log(`Machine ${i} || ${msg}`)
})
}
}