1.0.2 • Published 3 years ago

performance-tests v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Performance Tests

Performance tests are a set of configurations and templates used for the implementation of smoke, load, stress, edurance, spike, volume, and scalability testing. This document will walk you through any requirements and steps needed to set up and run those tests, so that you can ensure that your service adheres to an acceptable level of performance quality. For more information about these tests, look here.

Prerequisites

Before beginning your installation of the performance tests, you will need to install the following tools:

Installation

  1. Clone this repository and open it in the IDE of your choice.
  2. Install dependencies using: npm install

Running Tests Locally

To run one of these tests locally, use the following command:

npm run k6

This will run the tests with a base URL of http://localhost:3000/. To run the tests with a different base URL, you would do the following:

K6_BASE_URL=http://ad1def89e7f414a2b91746cb4cff132d-1039291563.us-east-1.elb.amazonaws.com/data-events/ npm run k6

By default, the verify tests will run. To run another type of test, you must define some options configurations. To define an option configuration, add the K6_OPTIONS environment variable specifying one of the files that exists in the ./src/options/ folder. For example, in order to run a load test, you would do the following:

K6_BASE_URL=http://ad1def89e7f414a2b91746cb4cff132d-1039291563.us-east-1.elb.amazonaws.com/data-events/ K6_OPTIONS=load-test npm run k6

Folder Structure

./src/ folder

All of the code can be found in the src folder. It is written in TypeScript using types provided by k6.

./src/lib/ folder

This folder contains helper functions.

The ./src/types/ folder

This folder contains custom types.

./src/options/ folder

This folder contains the different options that can be loaded at runtime.

./src/actions/ folder

The actions folder contains a script file for each user action. Each script file contains the requests that are sent when a user performs that particular action (e.g. login).

./src/data/ folder

The data folder contains test data used to generate payloads utilized within the test scritps.

./src/roles/ folder

The roles folder contains a file for each user type and the actions they can perform.

./src/tests/ folder

This is where you create your performance tests using the modules from the rest of the framework. actions are never called directly. Rather, they are always called through the role performing them (see the actions and roles folders above).

Adding a new test

If you want to add a new test, take the following steps:

  1. Add a test script file within the ./src/tests/ folder. Make sure test script exports a default function
  2. Import new test script in ./src/main.ts
  3. Add new imported function into the default function of ./src/main.ts

References