Load or stress testing in nodes

I am using nodejs with expression.

I have created a registration form with some fields. I want to check when there are 1000 user subscribers at the same time. What will happen? Is there any module or any simple example. How to enter fake data.

How can I write a test case for this. I searched for it, but I got no result.

thank

+3


source to share


1 answer


Use faker to generate fake data and request to send data to the server. You can use async.each

1000 registrations simultaneously to asynchronously execute.



var faker = require('faker');
var async = require('async');

var number_of_signups = 1000;
var identities = [];

for (var i=0; i < number_of_signups; i++) {
  identities.push({
    name: faker.name.findName(),
    email: faker.internet.email(),
    password: faker.internet.password()
  });
}

function submit(identity, callback) {
  var opts = {
    url: 'http://youdomain.com/signup-endpoint',
    method: 'POST',
    json: identity
  };
  request(opts, function(err, connection, body) {
    if(err) return callback(err);
    callback();
  });
}

async.each(identities, submit, function(err) {
  if(err) throw err;
  console.log('done...');
  process.exit();
});

      

+3


source







All Articles