https://github.com/besughi/elixir-k6
Quick and painless load testing for Elixir applications.
https://github.com/besughi/elixir-k6
elixir k6 load-testing
Last synced: 3 months ago
JSON representation
Quick and painless load testing for Elixir applications.
- Host: GitHub
- URL: https://github.com/besughi/elixir-k6
- Owner: besughi
- License: mit
- Created: 2021-09-13T23:06:47.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-14T19:58:39.000Z (over 2 years ago)
- Last Synced: 2025-09-06T04:07:17.609Z (5 months ago)
- Topics: elixir, k6, load-testing
- Language: Elixir
- Homepage:
- Size: 113 KB
- Stars: 40
- Watchers: 5
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
Elixir-K6
Quick and painless load testing for Elixir applications.
Generate and run load tests via a local installation of k6.
Originally developed at SpawnFest 2021.
## Installation
The package can be installed by adding `k6` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:k6, "~> 0.2.1"}
]
end
```
## Usage
To generate new k6 tests run:
```shell
mix k6.gen.test
```
By default k6 tests will be placed under the `priv/k6` directory of your project.
The template to use for the test can be set via the `--type` argument.
Supported types are `rest` (default), `graphql`, `grpc`, `websocket`, `phoenix-channel` (experimental) and `liveview` (experimental).
Run `mix help k6.gen.test` for more info on generating tests.
To execute k6 tests run:
```shell
mix k6 run .js
```
Run `mix help k6` for more info on running k6.
### Configuration
`elixir-k6` can be configured via `config.exs` as follows:
```elixir
config :k6,
version: "vX.Y.Z",
env: [VAR_KEY: "some value"],
workdir: "priv/my_load_tests_dir"
```
The supported configuration parameters are:
- `version`: the desired version of k6. Defaults to `v0.39.0`.
- `env`: environment variables to pass to load tests. K6 will expose those variables to load test scripts within the `__ENV` object.
- `workdir`: path of the directory that contains k6 load tests. Relative to the project, defaults to `priv/k6`.
### K6 installation
K6 is automatically installed the first time you run k6 tests, and it is stored in `_build/k6`.
In case you want to explicitly install it before running any test, you can run `mix k6.install`.
At the moment the following architectures are supported:
| OS | Architecture |
| :---: | :----------------: |
| MacOs | amd64 |
| MacOs | arm64 (not tested) |
| Linux | amd64 |
| Linux | arm64 (not tested) |
By default the installation task will install k6 version `v0.39.0`.
You can override this in your config file, as documented above.
## Contributing
Issues and contributions are welcome!
To run static analysis run:
```shell
mix check
```
To execute tests run:
```shell
mix test
```
The test suite also includes some end-to-end tests, which are not executed by default as they are much slower.
To execute all tests run:
```shell
mix test --include end_to_end
```