Git Product home page Git Product logo

grandma's Introduction

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

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):

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

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.

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.

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

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

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');

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

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

grandma's People

Contributors

0xflotus avatar catdad avatar stezu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

grandma's Issues

`grandma run` demand does not work with aliases

.command('run <testname> [options]', 'Run a test by name.', function(yargs) {
    return yargs
        .demand(2, ['duration', 'rate'], 'Example: --duration=10m --rate=50')
        .example('grandma run testname --duration=2m --rate=200');
})

Even thought there are aliases for duration and rate, those aliases to not satisfy the demands and the command does not run.

custom metrics

Use the context object to allow things like this.metric.myName = 1234.

  • Numeric metrics only
  • Consider what happens when the metric is left undefined by some test runs
  • Report on custom metrics

detect outliers

Detect outliers and do one/all of these:

  • remove them from the data set entirely
  • calculate summaries with and without them
  • display plots without outliers

issue with `grandma report` cli help

Seems like yargs does not like what I am doing here:

.command('report <glob> [options]', 'Summarize the content of report files.', function(yargs) {
    return yargs
        .demand('glob', 'The files to report. Example: *.txt');
})

decide on default directory

I am thinking "perf".

Also, consider a .grandmarc file to use for the default options, instead of following the mocha model.

set a timeout for the tests

Right now, grandma will wait for any existing test to finish after reaching the test duration before exiting. If the tests get stuck, grandma will never exit. It needs a max timeout to wait before exiting, because sanity.


  • add configurable timeout
  • use Duration-js for CLI timeout duration
  • unit tests
  • update README
  • update API doc
  • add to CLI help

list available tests

grandma list

  • consider allowing custom name tests instead of using the file name
  • consider allowing custom test description to be used in the list command

See text-table for making tables.

concurrency mode

Allow a maximum concurrency mode instead of rate.

"Run x number of tests at the same time for y period of time."

implement faster stats

Current stats are super slow on large data sets... probably due to the 3 percentile calls.

support for beforeAll and afterAll test methods

Since execution is done in threads, it is hard to have a shared beforeAll and afterAll.

  1. One option would be to execute those in the parent before and after the test runs, but that would not allow the scope to be shared. Ideally, we would want the scope to be shared between the separate threads as well.
  2. Another option would be to ignore scope for those methods.

Do note that if the test module itself tries to set a global variable in beforeAll, that variable won't be available to all threads running the test, since each one requires the module individually.

smaller output files

Text files get really big really quickly. Think about something that would make these smaller... maybe gzipping?

generate reports for the tests

grandma report {glob}

  • Consider API that allows combining multiple test output files in order to generate one report.
  • Keep in mind that these test outputs can be super long.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.