This document provides an overview and demonstration of K6, an open-source load testing tool. It discusses key aspects of K6 including what it is, why it should be used, and how to perform load testing with its various components. The document demonstrates K6's capabilities for load testing APIs, microservices, and websites using JavaScript scripts. It also shows how to integrate K6 with CI/CD pipelines using GitHub Actions.
2. KnolX Etiquettes
Punctuality
Respect Knolx session timings,
you are requested not to join
sessions after a 5 minutes
threshold post the session start
time.
Feedback
Make sure to submit a
constructive feedback for all
sessions as it is very helpful for
the presenter.
Mute
Please keep your window on
mute.
Avoid Disturbance
Avoid leaving your window
unmuted after asking a question
3. What is Performance testing?
What is K6?
Why k6?
➤
➤
➤
Agenda
CI/CD in K6
➤
➤ Demo
4. ● It is a non-functional software testing technique that determines the
stability,speed, and scalability of an application.
PERFORMANCE TESTING
● In Performance testing,we evaluating the Application
output,Speed,Velocity, Network bandwidth,maximum concurrent
users, common response time etc.
5. Normal and expected
load
Higher than expected
load
Sudden increase load
Huge volume of
load
Monitor database
load
Different Types Of Performance Testing
7. ● k6 is an open-source load testing tool for testing the performance of APIs,
microservices, and websites.
● This tool is scriptable and support the Javascript language.
● k6 was initially released on GitHub in 2017 by Load Impact as an
open-source.
● It’s written in Go Language.
K6
8. Load Testing in K6
Load Testing is primarily concerned with assessing the current
performance of your system in terms of concurrent users or
requests per second.
● Options
● Checks & Thresholds
● Modules
● Metrics
● Groups & Tags
Components:-
9. Checks
Checks
VUs Duration Stages
A fixed number of
VUs execute as
many iterations as
possible for a
specified amount of
time.
A string specifying
the total duration a
test run should be
run for.
Array of objects that
specify the target
number of VUs to
ramp up or down to.
Options in K6
10. ● Checks are asserts, but differ in that they don't halt the execution. Instead, they store the result of
the check, pass or fail, and let the script execution continue.
● Checks are great for codifying assertions relating to HTTP requests/responses, such as making
sure the response code is an HTTP.
CHECKS
● In the script,need to import the check -’import {check} from K6’
Syntax:-
check(res,{
'is status 200': (r) => r.status === 200,
});
11. Threshold
● Thresholds are a pass/fail criteria used to specify the performance expectations
of the system under test.
● Thresholds analyze the performance metrics and determine the final test result
(pass/fail).
export const thres = {
thresholds: {
http_req_failed: ['rate<0.01'], // http errors should be less than 1%
http_req_duration: ['p(95)<200'], // 95% of requests should be below 200ms
},
};
Syntax:-
12. Modules
While writing test scripts, it's common to import different
modules, or part of modules, for usage throughout the script. In
k6, it is possible to import three different kinds of modules:
● Built-in modules
● Local filesystem modules
● Remote HTTP(S) modules
14. Groups & Tags
Groups:- Groups are optional, and it allows you to “group” a large
load script to help you with the test result analysis. Groups can be
nested, allowing you the BDD-style of testing.
Tags:- Tags are a simple and powerful way to categorize your k6
entities for later results filtering.
17. CI/CD in K6
In k6,it is possible to integrate with CI/CD tools with the help of Github actions because github
actions has own advantages.To integrate k6 with GitHub action we need k6 based test script.
Integration K6 with Github Actions
GitHub actions more powerful and most effortless CI/CD tools among which we have
earlier tools like Jenkins, etc.