Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eddeccc/k6-java-test
Using k6 load tests with Java
https://github.com/eddeccc/k6-java-test
grafana influxdb k6 opentelemetry-collector testing
Last synced: 26 days ago
JSON representation
Using k6 load tests with Java
- Host: GitHub
- URL: https://github.com/eddeccc/k6-java-test
- Owner: EddeCCC
- Created: 2022-09-28T11:36:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-07T08:48:35.000Z (almost 2 years ago)
- Last Synced: 2023-07-06T13:25:41.002Z (over 1 year ago)
- Topics: grafana, influxdb, k6, opentelemetry-collector, testing
- Language: Java
- Homepage:
- Size: 18.7 MB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# k6 Load Testing - Java Example
The repository provides
- Local API for load testing
- k6 Mappers
- OTLP Exporter
- InfluxDB
- GrafanaThe application will parse a JSON configuration into a javascript
file, which will be executed by k6. The `k6 run` command will be executed
**automatically** after Spring is initialized and the API has started.
By default, the API runs at `localhost:8080/books`.[The repository is also available in **Kotlin**.](https://github.com/dqualizer/dqualizer-automated-load-testing-spike)
### Breakpoint Test
If the property `test.breakpoint` is set true, the load test will rerun with increased load after it´s finished.
This will continue until a threshold is not met or the maximum amount of loops are reached.**Be aware** that the test configuration needs to follow a specific pattern to make breakpoint testing possible.
[See here for more information.](docu/BreakpointConfiguration.md)---
## SetUpYou can run the application in Docker or install k6 manually.
You can find the installation instructions here: https://k6.io/docs/get-started/installation/The application needs a JSON configuration to create a k6 script.
The configuration will be loaded from a fake server (by default: `localhost:8080/config`).> Please take a look at the [documentation](docu/TestConfiguration.md) for the configuration
Furthermore, all values in [application.properties](src/main/resources/application.properties) have to be defined.
You can also use the default values.- `otel.host`: Host to run the OpenTelemetry collector on _(default: localhost)_
- `test.output`: What file format should be used for the results (json or csv) _(default: json)_
- `test.breakpoint`: Should Breakpoint Testing be enabled _(default: false)_
- `test.loops`: How often should the test be repeated (The loops will stop, if a [threshold](https://k6.io/docs/using-k6/thresholds/) is not met) _(default: 1)_
- `path.config`: Location of the test configuration (relative to [resources](src/main/resources)) _(default: config/exampleConfig.json)_All **created** files will be located relative to `./target/classes`.
---
### DockerYou can run the whole application with: `docker-compose up --build`
You can run all containers except the API with: `docker-compose -f docker-compose-no-api.yml up`
Generated **output** will be stored in `./docker-output`.
You can configure all the docker containers in [docker-config](docker-config) and [env](env).---
### OpenTelemetryThe result of the test will be saved in a local file. Those metrics will be exported via OTLP
to an OpenTelemetry Collector after the test has finished.
The Collector further exports those metrics to InfluxDB.---
### InfluxDB (v2)URL: `localhost:8086`
Default login: username > k6, password > telegrafYou can change it in the [.env](env/.env) file.
The organization, bucket and token are configured here, too.---
### GrafanaURL: `localhost:3030`
Default login: username > admin, password > adminYou can view the test results in the dashboard: [Load_Test_Results](docker-config/grafana/my-dashboards/home.json)
If you use JSON for the test results, there will also be a visualized threshold.
---
### More Information about k6- k6 in general: https://k6.io/docs/
- k6 options: https://k6.io/docs/using-k6/k6-options/reference/
- k6 metrics: https://k6.io/docs/using-k6/metrics/
- k6 params: https://k6.io/docs/javascript-api/k6-http/params/
- k6 responses: https://k6.io/docs/javascript-api/k6-http/response/---
## Implemented Features| k6 Features | Implemented |
|----------------------------|-------------|
| Configuration (options) | ☑ |
| Payload | ☑ |
| Params | ☑ |
| CSV Output | ☑ |
| JSON Output | ☑ |
| Custom metrics | ☐ |
| Groups | ☐ |
| k6 Cloud | ☐ |
| ###### | ###### |
| Http GET | ☑ |
| Http POST | ☑ |
| Http PUT | ☑ |
| Http DELETE | ☑ |
| Http PATCH | ☐ |
| Http HEAD | ☐ |
| Http OPTIONS | ☐ |
| Http BATCH | ☐ |
| ###### | ###### |
| GraphQL | ☐ |
| WebSocket | ☐ |
| gRPC | ☐ |
| ###### | ###### |
| Check response status | ☑ |
| Check alternative status | ☑ |
| Check body min length | ☑ |
| Check body includes | ☑ |
| Check error_code | ☑ |
| Check more body attributes | ☐ |
| Check error_text | ☐ |
| Check cookies | ☐ |
| Check headers | ☐ |
| Check status_text | ☐ |
| Check timings | ☐ |
| Check tls_version | ☐ |
| Check tls_cipher_suite | ☐ |
| Check remote_ip | ☐ |
| Check remote_port | ☐ |
| Check ocsp | ☐ |
| ###### | ###### |
| ... more? | ☐ |