Skip to content

beincom/bic-notification-perf-load

Repository files navigation

banner

Test with K6

BIC E2E and Performance test.

Installation

  1. Install dependencies
yarn
  1. Set environment variables
$ cp .example.env .env

# open .env and modify the environment variables (if needed)

Running the Test using Makefile

  1. Build k6 with extensions
make build-extension
  1. Run test with parameters
make run extensions="dashboard,elasticsearch" report="dashboard/report.html"

Recognized parameters:

  • extensions: K6 extensions for output (separate by ,, options: dashboard, elasticsearch).
  • report: File name for exporting the report (used if dashboard extension is included).

If using elasticsearch metrics are stored in the index k6-metrics, which is automatically created by the xk6-output-elasticsearch extension.

Running the Test manual

  1. Build script test
yarn build
  1. Build k6 with extensions

For Linux

docker run --rm -it -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" grafana/xk6 build v0.43.1 --with github.com/oleiade/xk6-kv --with github.com/grafana/xk6-dashboard@v0.7.3-alpha.1 --with github.com/Juandavi1/xk6-prompt@0.0.2 --with github.com/gpiechnik2/xk6-httpagg@v1.0.0 --with github.com/elastic/xk6-output-elasticsearch@v0.3.0

For MacOS

docker run --rm -it -e GOOS=darwin -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" grafana/xk6 build v0.43.1 --with github.com/oleiade/xk6-kv --with github.com/grafana/xk6-dashboard@v0.7.3-alpha.1 --with github.com/Juandavi1/xk6-prompt@0.0.2 --with github.com/gpiechnik2/xk6-httpagg@v1.0.0 --with github.com/elastic/xk6-output-elasticsearch@v0.3.0

For Windows

docker run --rm -it -e GOOS=windows -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" grafana/xk6 build v0.43.1 --output k6.exe --with github.com/oleiade/xk6-kv --with github.com/grafana/xk6-dashboard@v0.7.3-alpha.1 --with github.com/Juandavi1/xk6-prompt@0.0.2 --with github.com/gpiechnik2/xk6-httpagg@v1.0.0 --with github.com/elastic/xk6-output-elasticsearch@v0.3.0
  1. Run the test
./k6 run --out dashboard=report=dashboard/report.html dist/main.test.js

Run with output elasticsearch. The metrics are stored in the index k6-metrics which will be automatically created by extension xk6-output-elasticsearch

export K6_ELASTICSEARCH_URL=xxx
export K6_ELASTICSEARCH_USER=xxx
export K6_ELASTICSEARCH_PASSWORD=xxx

./k6 run --out dashboard=report=dashboard/report.html --out output-elasticsearch dist/main.test.js

Output Results

  • By default, the httpagg report is exported to dashboard/httpagg-report.html.
  • By default, the dashboard report is exported to dashboard/report.html.

  • If the report parameter is provided when running the test, the report is exported to the specified path.

  • Metrics are stored in the index k6-metrics, automatically created by the xk6-output-elasticsearch extension.

Writing own tests

House rules for writing tests:

  • The test code is located in src folder
  • The entry points for the tests need to have "test" word in the name to distinguish them from auxiliary files. You can change the entry here.
  • If static files are required then add them to ./assets folder. Its content gets copied to the destination folder (dist) along with compiled scripts.

Steps to run the seed data

  1. Change config
  • Update config in config.ts if you need.
  • Update communityIndex in scripts/main.script.ts to change the community for create contents.
  1. Run the seed
yarn create-data

Transpiling and Bundling

By default, k6 can only run ES5.1 JavaScript code. To use TypeScript, we have to set up a bundler that converts TypeScript to JavaScript code.

This project uses Babel and Webpack to bundle the different files - using the configuration of the webpack.config.js file.

If you want to learn more, check out Bundling node modules in k6.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published