grandma

Load testing CLI tool

Usage no npm install needed!

<script type="module">
  import grandma from 'https://cdn.skypack.dev/grandma';
</script>

README

grandma

Linux Build Windows Build Test Coverage Code Climate Downloads Version Dependency Status

This is a load testing library and CLI tool. It is inspired by the good parts of Vegeta and JMeter, but hopefully leaves out the bad parts of both.

Install

You can install grandma as a global CLI tool:

npm install grandma

Test files

Here is a quick example of a test file:

module.exports = {
    beforeAll: function(done) {
        process.nextTick(done);
    },
    beforeEach: function(done) {
        process.nextTick(done);
    },
    test: function(done) {
        process.nextTick(done);
    },
    afterEach: function(done) {
        process.nextTick(done);
    },
    afterAll: function(done) {
        process.nextTick(done);
    }
};

All functions other than test are optional, and you can exclude them if you do not need them. All functions are asynchronous, and you must call the done callback to continue. For more information about writing tests, see the test files help topic.

CLI

To see the most up-to-date CLI, type:

grandma help

The following commands are available.

grandma run <testname> --duration=<duration> --rate=<rate> [options]
grandma report [glob=stdin] [options]
grandma list [options]

To see help on these commands, you can type one of:

grandma run --help
grandma report --help

The following options are available as flags (some are only relevant for the run command):

grandma list

Lists all the tests in your test suite. You can use these names in grandma run to run the test. See more information bout it in the granda list CLI page.

grandma run

Run a test named "pineapples" for 10 minutes at a rate of 500 tests per second:

grandma run pineapples --duration 10m --rate 500 --out pineapples.log

Run a test named "peaches" for one and a half hours, running 100 concurrent tests:

grandma run peaches --duration 1h30m --concurrent 100 --out peaches.log

To find out more about the CLI, please see the grandma run CLI page.

Note: I will assume that you have configured the test directory in the .grandmarc file, so it was not included it in these examples.

grandma report

Print a plain text report of the previously-described test run:

grandma report pineapples.log

You can also create an HTML page containing an interactive graph of the results:

grandma report pineapples.log --type html --out pineapples.html

By default, all reports will print to standard output, unless you specify a file in the --out flag.

You can find more information about the available reports and the data they provide in the grandma report CLI page.

grandma diff

Compares two or more test runs, calculating the difference in timing among them.

grandma diff --logs one.log two.log three.log

.grandmarc file

You can set up an RC file to help with managing some of the setting, such as the directory of test files. Here is the content a sample file.

To find out more, see the .grandmarc doc page.

API

Grandma exposes the run and report commands as an API.

var grandma = require('grandma');

grandma.run

See more information about using run in the grandma.run API page.

grandma.report

See more information about using report in the grandma.report API page.