Skip to content

alexanderbikk/k6-investigation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k6-investigation

smoke-testing

Is a smoke test example for basic CRUD functionality using k6 test Api.

The test will do the following

  • Creates one new user for all VUs.
  • Logins with created user credentials
  • Creates new crocodile from the input-data.json file. The crocodile number will be selected based on VU index in test. For the 1st user - #1, 5th user - #5, 6th user - #1, #10th user - #5.
  • Updates created crocodile by Id.
  • Deletes crocodile.

Test uses per-vu-interations scenario - vu*interations. Configuration can be found in options.json file.

    "scenarios": {
        "simple-iterations": {
            "executor": "per-vu-iterations",
            "vus": 10,
            "iterations": 1,
            "maxDuration": "20s"
        }
    },

load-testing

Is a load test example from k6 documenation using crocodile get endpoint.

Test uses ramping-vus scenario - users will be added and removed based on stages. Configuration can be found in options.json file.

     "scenarios": {
        "rump-up": {
            "executor": "ramping-vus",
            "startVUs": 1,
            "stages": [
                {
                    "duration": "10s",
                    "target": 10
                },
                {
                    "duration": "20s",
                    "target": 20
                },
                {
                    "duration": "5s",
                    "target": 1
                }
            ],
            "gracefulRampDown": "5s"
        }
    },

For smoke-testing and load-testing summary will be added to test_results_summary.json (in addtion to console log). The detail results will be added in test_results_details.json.

How to run

  1. Install k6 open source locally for your OS using this link

For Windows choco install k6

  1. To run smoke-testing or load-testing sript the following command should be used.
cd smoke-testing
k6 run --config options.json --out json=test_results_details.json script.js

Options can be update in options.json.

To test basic script in the root folder

k6 run script.js

or with custom options 

k6 run --vus 10 --duration 15s script.js
  1. The results will be available in test_results_details.json (in addition to console output)

Concepts

Users

From documentation

k6 works with the concept of virtual users (VUs), which run your test scripts. VUs are essentially parallel while(true) loops. Scripts are written in JavaScript, as ES6 modules, so you can break larger tests into smaller pieces or make reusable pieces as you like.

Stages

From documentation

You can ramp the number of VUs up and down during the test. To configure ramping, use the options.stages property.

It is a shortcut option for a single scenario with a ramping VUs executor.

Scenarios

From documentation

Scenarios configure how VUs and iteration schedules in granular detail. With scenarios, you can model diverse workloads, or traffic patterns in load tests.

Options

Options can be passed in CLI directly

For example set 10 VUs and duration for the test k6 run --vus 10 --duration 30s script.js

Options also can be create in script code or provided as a separate .json file. We can pass file in CLI or read it inside setup section in script.

For example k6 run --config options.json script.js (see options.json in source code)

All options can be found here

Reports

The End-of-test summary can be customized in script.

The results could be expoted in CSV, Json files. Also streaming to cloud supported.
More information about possible results

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published