Quick Start

Learn how to create your first test case

The main test approach with StormForge Performance Testing is to model clients (or users) that will arrive at your system in a given time. Each client that arrives will perform one session and then leaves again – just like in real life.

Anatomy of a Test

Tests consist of one test case, describing the test setup, parameters etc., and test runs, which represent test executions of a test case. This is structured this way to ensure that you can link every test execution to a specific test configuration.

A test case has at least one target which is under test and at least one arrival phase which determines the load progression during your test run. Each client that is launched, will pick one session to execute where a session consists of declarative description of which steps to perform.

The following sections will briefly describe all concepts.

Targets

Each test case has to have at least one target. A target specifies the endpoint you want to test, including the host name, port and protocol (http or https). Targets are specified by providing a URL to definition.setTarget:

definition.setTarget("http://api.example.com");
// or
definition.setTargets(["https://api.example.com", "https://api2.exaple.com:8081"]);

Arrival Phases

Arrival Phases specify the load progression of your test. It will determine how many clients will arrive at your targets during the test. You need at least one, but you can have as many phases as you wish.

Every phase has a duration (in seconds) and a rate (in clients per second, can be a float value). Additionally you can specify how many clients are allowed to launch during this phase using max_clients.

definition.setArrivalPhases([
  {
    duration: 5 * 60,  // duration in seconds
    rate: 2.5,         // clients to launch per seconds
    max_clients: 100   // optional; launch up to 100 clients in this phase
  },
]);

The sum of all durations will determine the upper bound of your test duration. Your test will end when:

  1. no more clients should be launched -AND-
  2. all previously launched clients have completed their session

Sessions

Each test case has to have at least one session, which describes what a newly launched client will do.

A Session has a descriptive name and a step definition function. name is an identifier, that you can freely choose.

definition.session("hit status api", function(session) {
  // your step definition code goes here.
});

Step Definition

The step definition function will operate on the given argument session. You can do all kinds of requests, let the client wait a moment, extract content of a response, implement simple control structures like conditions, loops etc.

Making Requests

You can make GET, POST, PUT, PATCH, DELETE and HEAD requests. Each HTTP verb has a corresponding method defined on session: session.get("/path") or session.post("/users/create").

All requests require at least the request path and can have additional options.

session.get("/users/sign_up", requestOptions);

Where requestsOptions are optional. The following options are available:

session.post("/path", {
  // Create a payload ...
  // sent as application/x-www-form-urlencoded
  payload: {
    email: "user@example.com",
    password: "geheim",
  },

  // -OR- as a JSON
  // note that most servers want an
  // application/json Content-Type header
  // to receive JSON
  payload: JSON.stringify({
    productId: "myGreatProduct",
    amount: 1
  }),

  // -OR- as a plain string
  payload: "payload string",

  // use gzip compression, default: false
  gzip: true,

  // Adds `X-Requested-With: XMLHttpRequest`-header for Ajax Requests
  xhr: true,

  // Ensures that a request is preceded by a preflight CORS Options Request.
  // The following headers will be used for the Options Request:
  //
  // Access-Control-Request-Method: <the-method-defined>
  // Access-Control-Request-Headers: <comma-separated-list-of-all-defined-headers>
  // Origin: https://mydomain.com
  cors: { origin: "https://mydomain.com" },

  // set arbitrary as needed
  headers: {
    "X-AwesomeApp-Token": "letmein",
    "X-AwesomeApp-Mail": "user@example.com",
  },

  // tag this request; a tag may consist
  // of letters, numbers, underscores
  // and dashes and has to start with a letter.
  tag: "logout",

  // use HTTP basic access authentication
  authentication: {
    username: "tisba",
    password: "letmein",
  },

  // use response content extraction
  extraction: {
    jsonpath: {
      "accessToken": "authorization.token",
    }
  }
});

You can get more details on requests in the request reference.

Next Steps

  1. Read up on different load testing variations in our Stress Testing, Soak Testing and Spike Testing guides
  2. Sign-up at app.stormforge.io and schedule your first test case
  3. Install the forge CLI
Last modified May 25, 2022