How to use loadtest - 5 common examples

To help you get started, we’ve selected a few loadtest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wework / we-js-logger / test / stress / index.js View on Github external
it('express server with requestLogger and scrubFields does not lock up under load', (done) => {
    loadtest.loadTest(loadOptions, (error, results) => {
      if (error) {
        done(error);
        return;
      }

      printResults(results);

      expect(results.totalErrors).to.eql(0, 'there are no request errors');
      expect(results.meanLatencyMs).to.be.lte(10, 'mean response is less than 10ms');
      expect(results.percentiles['99']).to.be.lte(20, '99% of responses under 20ms');
      // expect(results.maxLatencyMs).to.be.lte(40, 'max response is less than 40ms');
      done();
    });
  });
});
github haroldtreen / epub-press / tests / stress.js View on Github external
];

const options = {
  statusCallback,
  // requestGenerator,
  method: 'post',
  concurrency: 6,
  body: {
    urls
  },
  url: 'http://localhost:3000/api/books',
  contentType: 'application/json',
  maxRequests: 300
};

loadtest.loadTest(options, (error, result) => {
  if (error) {
    return console.error('Got an error: %s', error);
  }
  console.log('Tests run successfully');
  console.log(result);
  return undefined;
});
github eclipse / codewind / src / performance / loadrunner / runload.js View on Github external
* which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v20.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
const loadtest = require('loadtest');

if(process.argv.length <= 2) {
    console.log("Options needed, got " + JSON.stringify(process.argv))
    process.exit(1);
}
try {
    let options = JSON.parse(process.argv[2])
    // do some validation?
    loadtest.loadTest(options, function(error, result) {
        if (error) {
            console.error('Load test return an error: %s', error);
            process.exit(1);
        }
        console.log(result);
    });
} catch (err) {
    console.error(err);
    process.exit(1);
}
github EthanRBrown / web-development-with-node-and-express / ch16 / qa / tests-stress.js View on Github external
test('Homepage should handle 50 requests in under a second', function(done){
          var options = {
              url: 'http://localhost:3000',
              concurrency: 4,
              maxRequests: 50,
          };
          loadtest.loadTest(options, function(err,result){
            expect(!err);
            expect(result.totalTimeSeconds < 1);
            done();
          });
      });
github binaris / binaris / sdk / perf.js View on Github external
const report = await new Promise((res, rej) => {
    loadTest(options, (err, result) => {
      if (err) {
        rej(err);
      } else {
        res(result);
      }
    });
  });
  logger.debug('Perf report', { report });

loadtest

Run load tests for your web application. Mostly ab-compatible interface, with an option to force requests per second. Includes an API for automated load testing.

MIT
Latest version published 1 day ago

Package Health Score

78 / 100
Full package analysis

Popular loadtest functions