These slides is from a session about load testing. It starts with an introduction to non-functional testing then demonstrating the phases and criteria of load testing with K6.
4. Non-Functional
Tests the readiness of a system as per
nonfunctional parameters which are not
covered by functional testing. We conduct
non-functional testing to make sure that
users expectations are met.
Testing
Functional
Functional testing verifies that a program is
operating according to the technical and business
requirements. Functional testers main concern is
checking the functionality.
Testing
5. Functional Testing
Tests what a product does
Either present or not present
Validated against requirements
Requirements are easy to specify
Non-functional Testing
Tests how a product works
Evaluated on a scale
Validated against end-user expectations
Requirements are hard to specify
8. Why Use Performance
Testing?
• Performance testing can be used as a diagnostic
aid to locate computing or communications
bottlenecks within a system.
• Performance testing can also verify that a system
meets the specifications claimed by its
manufacturer or vendor..
Performance Testing
9. Performance Testing
Metrics
Processor Usage.
Amount of time processor
spends executing non-idle
threads
Memory Use.
Amount of physical memory
available to processes on a
computer.
Disk Time.
Amount of time disk is busy
executing a read or write
request.
10. Performance Testing
Metrics
Bandwidth.
shows the bits per second
used by a network interface.
Response Time.
time from when a user
enters a request until the
first character of the
response is received.
Throughput.
rate a computer or network
receives requests per
second.
11. Performance Testing
Metrics
Hit Ratio.
The number of SQL
statements that are handled
by cached data instead of
expensive I/O operations.
Database Locks.
Monitoring locking of tables
and databases to be
carefully tuned.
Max. Active Sessions.
The maximum number of
sessions that can be active
at once.
12. Types of Performance Testing
Performance Testing
Load Testing
• Checks the application’s ability to perform under anticipated
user loads. The objective is to identify performance bottlenecks
before the software application goes live.
Stress Testing
• Involves testing an application under extreme workloads to see
how it handles high traffic or data processing. The objective is to
identify the breaking point of an application.
Endurance Testing
• Is done to make sure the software can handle the expected load
over a long period of time.
Spike Testing
• Tests the software’s reaction to sudden large spikes in the load
generated by users.
Volume Testing
• Under Volume Testing large no. of. Data is populated in a database
and the overall software system’s behavior is monitored. The objective
is to check software application’s performance under varying database
volumes.
Scalability Testing
• The objective of scalability testing is to determine the software
application’s effectiveness in “scaling up” to support an increase in
user load. It helps plan capacity addition to your software system.
14. Load Testing Goals
LOAD TESTING
• Response time for each request
• Performance of the system components under
different loads
• Performance of database components under
different loads
• Network delay between the client and the server
• Software design issues
• Server configuration issues like a web server,
application server, database server etc.
• Hardware limitation issues like CPU
maximization, memory limitations, network
bottleneck, etc.
15. 01
Architecture Validation
Takes place early in the development
after a prototype of the app is created.
This guarantees the viability of the
selected architectural framework.
02
Performance Benchmarking
Sets and creates the benchmark tests for
the initial version of the app.
Gives the Eng. and the QA groups a set
of metrics to quantify the scalability.
Dev. team will either maintain metrics or
improve upon it through the subsequent
milestones.
03
Performance Regression.
Ensures that the changes made to the
app do not result in degradation of
performance.
Executed when key milestones have been
reached or architectural modifications
have been made.
Load Testing
Phases
LOAD TESTING
16. 04
Acceptance and Tuning
The final load testing phase prior to the
official launch.
Different scenarios of real-life usage are
emulated and the performance of the
final configuration is validated.
These scenarios are also used to
configure the HW and SW components
to yield optimal performance.
05
Performance Monitoring
After the app is deployed, it is essential
to monitor the performance of the
system so that crashes or slow-downs
can be spotted before they become
problematic.
Data related to real life usage can be
collected to help refine future tests for
accurate emulation of load.
Load Testing
Phases
LOAD TESTING
17. Load Testing
Criteria
• Produce load that stresses all layers of a multi-layer app.
• Allow for the emulation of a realistic mix of different groups
performing different types of business transaction on the
app during peak periods.
• Emulate page and resource request patterns.
• Validate the responses coming back from the web server for
each of the thousands of concurrent users to ensure that
the correct pages are being returned by the Web
application under stress.
LOAD TESTING
18. Load Testing
Criteria
• Allow for easy maintenance of the scripts testing script.
• Dynamic Dial-up of users - this capability allows you to add
new users to the load test without stopping the current test.
• Real-Time Virtual User Debugger: the load testing tool
should have some capability to allow you to visually monitor
the progress of a user at any given point in time.
• Real-Time Graphs that allow you to understand the
scalability characteristics of the application as the load test
is in progress.
LOAD TESTING
19. Load Testing
Criteria
• Allow for distributing load tests from a number of machines.
• Allow the load tests to be executed with recorded think
times, random think times (following some kind of
statistical distribution), and with no think times.
• Measure response times of entire business transactions in
addition to individual objects.
• Allow for simulation of different types of caching behaviors.
• Allow for complex scheduling to allow for different
scenarios of starting, stopping, and ramp-up.
LOAD TESTING
21. What is K6
K6 Testing Tool
• K6 is an open source load testing tool that
is developed by Grafana Labs and the
community.
• CLI tool with developer-friendly APIs.
• Test scripting is done in JavaScript
ES2015/ES6.
• The tool itself is written in Go to achieve
maximum performance.
22. How to Install
K6 Testing Tool
It can be installed on Linux, MacOS,
Windows and of course Docker
24. Scenario
A scenario load test is for testing a real-world
flow of interactions, e.g.. a user logging in,
starting some activity, waiting for progress,
and then logging out. The goal here is to test
the target system with traffic that is
consistent with what you’d see in the real
world in terms of URLs/endpoints being hit.
Load Testing
Unit
A unit load test is testing a single unit, like an API
endpoint, in isolation. You might primarily be
interested in how the endpoint’s performance
trends over time, and be alerted to performance
regressions.
Load Testing
26. Test Life Cycle: Init and VU
The bare minimum for any test is to have default
function. Which act as the entry point for the VU.
Code inside default is called "VU code", and is run as
long as the test is running. Code outside of it is called
"init code", and is run only once per VU.
You can't load anything from your local filesystem, or
import any other modules. This all has to be done from
the init code.
You can use this to reuse data between iterations (but
only for the same VU).
K6 Testing Tool
27. Test Life Cycle: Setup and
Teardown
setup and teardown are only called once for a test.
function signature of the default function and
teardown function can take an argument, This
argument will be whatever is returned in the setup
function.
Any requests made in the setup and teardown stages
will be counted in the end-of-test summary. Those
requests will be tagged appropriately with the ::setup
and ::teardown
K6 Testing Tool
28. HTTP Requests
K6 Testing Tool
• The first step of creating a load test is
defining HTTP request.
• K6 HTTP module support all HTTP
methods
30. Test Results: Metric Types
K6 Testing Tool
• A metric that cumulatively
sums added values.
Counter
• Best used to show a range,
it stores the min, max and
last values added to it.
Gauge
• A metric that tracks the
percentage of values, in our
case it will be non-zero
values
Rate
• A pattern found in time
series datasets; used to
describe data movement
either upward or downward.
Trend
32. Test Results: Custom
Metrics
K6 Testing Tool
• K6 allows you to create custom metrics
of any type.
• Custom Metrics are reported at the end
of the test.
35. Test Results: Thresholds
K6 Testing Tool
• Thresholds are a pass/fail checks used to verify
that the expected performance is met.
36. Test Results: Thresholds
K6 Testing Tool
Metric Type Aggregation Method
Counter count and rate
Gauge value
Rate rate
Trend
avg, min, max, med
and p(N)
37. External Output
K6 Testing Tool
• The test summary provides a general
overview of your test results. By default,
the summary prints to stdout.
• K6 supports various built-in outputs
39. Filtering Results
K6 Testing Tool
• Groups: organize your load script around
common business transaction.
• Tags: categorize your checks, thresholds,
custom metrics and requests with tags for
in-depth filtering.
40. Filtering Results: Groups
K6 Testing Tool
• Groups can be nested
• All metrics emitted in a group will have the
tag group with a value of all group names
wrapping it separated by '::' (two colons).
• The default/root group with the name ''
(empty string) which means that if you just
have a single group named 'cool
requests' the actual value of the group tag
will be ::cool requests
{
41. Filtering Results: Tags
K6 Testing Tool
K6 provides two types of tags:
• User-defined tags: the ones you've
added when writing your script.
• System tags: tags automatically assigned
by k6.
42. Filtering Results: Tags
K6 Testing Tool
K6 provides two types of tags:
• User-defined tags: the ones you've
added when writing your script.
• System tags: tags automatically assigned
by k6.
43. Scripts
K6 Testing Tool
• Multiple scenarios can be declared in the same
script, and each one can independently execute a
different JavaScript function.
• Every scenario can use a distinct VU and iteration
scheduling pattern.
• They can be configured to run in sequence or
parallel.
• Different environment variables and metric tags
can be set per scenario.
44. Scripts
K6 Testing Tool
• Multiple scenarios can be declared in the same
script, and each one can independently execute a
different JavaScript function.
• Every scenario can use a distinct VU and iteration
scheduling pattern.
• They can be configured to run in sequence or
parallel.
• Different environment variables and metric tags
can be set per scenario.