Full-Stack
You have got some API you would like to test. Your language of choice is Node.js.
Asynchronously generate multiple workers. Each worker is a child process invoked with a command-line. Listen to worker stdout and worker exit.
var async = require('async');
var numWorkers = 200;
// construct multiple workers
async.times(numWorkers, function(n, next) {
// construct args
createChild(n, args, next);
});
function createChild(n, args, next) {
var commandLine = ['./test/worker.js', n, args];
var child = spawn('node', commandLine);
child.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
child.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
});
child.on('close', (code) => {
console.log(`child process exited with code ${code}`);
next(code);
});
}
// worker.js
var n = process.argv[2];
var args = process.argv[3];
// do something
Yoram Kornatzky