Skip to content

Perfomancing testing

Joep Verhoeven edited this page Jun 10, 2021 · 14 revisions

Performance testing

Performance testing was implemented after researching the subject in spring 2021 this research document can be found in the drive of Dex The reason why Dex uses performance tests is that it can be used to detect performance bottlenecks earlier on in the development cycle. This makes it easier to eliminate bottlenecks. Performance tests are software tests that are focused on testing: speed, scalability, stability, and reliability of a system. Usually, the product owners or stakeholders decide what type of performance tests system a system should use and what is important enough to be tested. Setting up these kinds of tests takes effort and time, but it could give an insight about how an app is performing with each version, this could decrease the risk of bad user experience and/or problematic performance. There are many tools available to test API’s and websites, some of them are less suitable to be used in DEX, though most of these tools will probably suffice just fine.

For now Dex uses K6, K6 is a cli that is based on the programming language GO. K6 executes javascript files for it's tests. The test files developers will write are the code that each virtual user (VU) will execute. For example you may write a script that calls an endpoint each second and then check if the response time was below 500ms and the statuscode was 200. This single script can now be run by multiple VU's at the same time.

To visualize the performance Dex makes use of Grafana this application is used for creating dashboards with live data. The Data is written from a timestamp based database called Influx-db. K6 writes data during tests to InfluxDb while Grafana automatically refreshes it's data every 5 seconds by default (this can be increased or decreased). K6+Grafana+InfluxDb

The tests (and visualization tools) are run through Docker using multiple Docker-Compose files. Each Docker-Compose file executes a different kind of test: load, stress, volume, etc. so for example to execute load tests a user would execute a command like docker-compose -f docker-compose-load-tests.yml (or --file docker-compose-load-tests.yml) up. This will run all applications through docker and the performance of the staging enviroment (by default) will be tested.

How to execute performance tests

As mentioned earlier the tests and infrastructure for testing is all run through Docker. Therefore you will need to have Docker installed for your OS including the Docker-Compose functionality. Further more you will also need the source code from git on your system. To execute each type of test the user needs to navigate to the root directory of DEX and then navigate to the PerformanceTests directory on Windows this can be done with cd "YOUR_ROOT_DIRECTORY"/PerformanceTests.

Then the user can enter the following command the execute the available tests docker-compose -f docker-compose-[testtype].tests.yml up The test type is one of the following: load, 'stress'.

Docker will now start 3 containers for the K6-cli, Grafana and Influx-DB users can then navigate to https://localhost:3000 to view the performance in Grafana.

Congratulations you are now succesfully running performance tests! 🥳

Note: you can change the http(s) address to test in the .env file

How to write performance tests

ToDo