Skip to content

Instantly share code, notes, and snippets.

@ltk
Created February 2, 2016 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ltk/8b02621996d6377db0f8 to your computer and use it in GitHub Desktop.
Save ltk/8b02621996d6377db0f8 to your computer and use it in GitHub Desktop.
BaaS at Scale | Load Test Process Spawning
const spawn = require('child_process').spawn
// How many connections to build with Firebase
const maxChildren = 1250
// How long to keep child processes alive
const timeout = 10 * 60 * 1000 // 10 minutes
for (var i = 0; i < maxChildren; i++) {
// your-test.js should contain your application-specific test
var child = spawn('node', ['your-test.js', `--id=${i}`, '--timeout=${timeout}'])
child.stdout.on('data', (data) => {
console.log(`stdout: ${data}`)
});
child.stderr.on('data', (data) => {
console.log(`stderr: ${data}`)
});
child.on('close', (code) => {
if (code !== 0) console.log(`Child ${i} process exited with an error. Code ${code}`)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment