Load testing - bcgov/SIMS GitHub Wiki
Goal
- Anticipate possible production issues due to a high application load in main areas as much as possible.
- Adjust PODs resources (CPU/Memory) and HorizontalPodAutoscaler configurations.
- Tests will initially be conducted on the DEV environment that has the same resources right now as production.
- Tests will be initially executed from a local machine but they can also be executed from GitHub actions (K6 also has a Cloud available to execute tests).
Framework
- K6 will be used to execute the load tests to be created and be available in the GitHub repository.
- The test scenarios should be available to be executed at any point.
Reasons to choose K6
- It has an Open Souce version.
- Out-of-box output visualization can be extended (https://k6.io/blog/ways-to-visualize-k6-results).
- It seems to be a well-known and largely used framework.
- Extensive documentation and articles about it.
- Tests can be written in javascript. "JavaScript is not generally well suited for high performance. To achieve maximum performance, the tool itself is written in Go, embedding a JavaScript runtime allowing for easy test scripting." (source https://k6.io/docs/).
- The Javascript will be transpiled from Typescript keeping the overall test structure close to the other packages in SIMS.
- More information can be found on the ticket that contains the initial effort to enable load testing #2407.
Recommended reading to understand the basics of the tests
Source code structure
- Load tests are created under sources/packages/load-test.
- The tests are created in specific folders using unique names that will later be used by Webpack to create the javascript bundle to be executed.
- Every new test scenario should have an associated
npm
command, for instance,npm run form-io-application-submission
.
How to run a load test
- Download the SIMS repository.
- Navigate to the folder sources/packages/load-test
- Execute
npm i
. - Every test can require sensitive information configuration. Look for files like
config.env.ts.sample
and follow the instructions. - Install K6 following the instructions here: https://k6.io/docs/get-started/installation
- Execute one of the available tests. The list can be found in the
package.json
scripts
section.
How a simple load test output looks like
To know more about these values please see: https://k6.io/docs/get-started/results-output/
How to run workflow load test
Running workflow load test means, load testing the whole workflow process ecosystem which has camunda workflows, workers and the sims database. Load tests for workflow happen through load-test-gateway a non prod environment application which hosts APIs which are used by K6 framework to load test.
-
Please go though the above section How to run a load test to have k6 installed in your machine and source code downloaded from sims repository.
-
Make sure that following properties are set to right values in
config.env.ts
(rename the sample file) KEY_CLOAK_TOKEN_URLBASE_LOAD_TEST_GATEWAY_URL(To run a load test use a non prod openshift environment)
LOAD_TEST_GATEWAY_CLIENT_SECRET(This secret will be available in keycloak for the client
load-test-gateway
) -
Navigate to the folder sources/packages/load-test
-
Execute
npm i
. -
Execute
npm run workflow-assessment-submission