Performance Testing
The CI/CD job called Performance Testing is run on the latest version of the Ubuntu operating system and depends on the E2E Testing job that has been run before. It is intended to run performance tests, generate test reports and upload the reports as artefacts for later use.
Pipeline job snippet
Description
Checkout repository: uses the actions/checkout@v4 action to download the content of the repository to the working environment. This step ensures that the repository will be available for further steps in the workflow.
Setup node.js: uses the actions/setup-node@v4 action to set up the Node.js environment. The version of Node.js (node-version: 18.x) to be used in this work is specified.
Use cached node_modules: executes the command "npm ci --cache ~/.npm" to use cached npm modules. This step ensures faster dependency installation as it uses caching.
Build application: executes the "npm run build" command to build the application. This step prepares the application for launching and testing.
Install k6: executes the command "curl https://github.com/grafana/k6/releases/download/v0.47.0/k6-v0.47.0-linux-amd64.tar.gz -L | tar xvz --strip-components 1" to install the k6 tool. This tool is used to perform performance tests.
Start server and run performance tests: execute the command "npm start & npx wait-on http://localhost:3000; ./k6 run tests /performance/test.js --vus 50 --duration 15s --out json=performance-testing-report.json" to start the server and run the performance tests. This step starts the server, waits until the server is available and then runs the performance tests with the k6 tool, using 50 virtual users for a period of 15 seconds. The results of the testing are saved in the performance-testing-report.json file.
Upload performance report: uses the actions/upload-artifact@v4 action to upload the performance testing report as an artifact. The report (performance-testing-report.json) is uploaded, allowing later review and analysis of the performance testing results.