Skip to content

Commit

Permalink
feat: k6 perf example (#6039)
Browse files Browse the repository at this point in the history
* k6 example perf test

* k6 example perf test

* k6 perf test - additinal requests

* k6 perf test - additinal requests removed

* k6 perf - workflows, values (prometheus + grafana)

* branch updated

* k6 workflow with prometheus - native histogram, K6_PROMETHEUS_RW_TREND_STATS

* k6 test updated

* k6 perf - prometheus values - native-histograms enabled
  • Loading branch information
tkonieczny authored Nov 20, 2024
1 parent 6b5a087 commit 6276c1c
Show file tree
Hide file tree
Showing 4 changed files with 2,840 additions and 0 deletions.
135 changes: 135 additions & 0 deletions test/examples/k6-perf/k6-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Simple
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: k6-perf-test
spec:
content:
git:
uri: https://github.com/kubeshop/testkube
revision: main
paths:
- test/k6/executor-tests/k6-perf-test.js
container:
# resources:
# requests:
# cpu: 128m
# memory: 128Mi
workingDir: /data/repo/test/k6/executor-tests
config:
vus: {type: integer, default: 20}
duration: {type: string, default: '1m'}
steps:
- name: Run test
container:
image: grafana/k6:0.49.0
steps:
- run:
shell: mkdir /data/artifacts && k6 run k6-perf-test.js --vus {{ config.vus }} --duration {{ config.duration }}
env:
- name: K6_WEB_DASHBOARD
value: "true"
- name: K6_WEB_DASHBOARD_EXPORT
value: "/data/artifacts/k6-test-report.html"
steps:
- name: Saving artifacts
workingDir: /data/artifacts
artifacts:
paths:
- '*'
---
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: k6-perf-test-workers
spec:
config:
vus: {type: integer, default: 20}
duration: {type: string, default: '1m'}
workers: {type: integer, default: 3}
content:
git:
uri: https://github.com/kubeshop/testkube
revision: main
paths:
- test/k6/executor-tests/k6-perf-test.js
steps:
- name: Run test
parallel:
count: 'config.workers'
transfer:
- from: /data/repo
fetch:
- from: /data/artifacts
use:
- name: distribute/evenly
# container:
# resources:
# requests:
# cpu: 128m
# memory: 128Mi
paused: true # synchronise running all workers
run:
image: grafana/k6:0.49.0
workingDir: /data/repo/test/k6/executor-tests
shell: mkdir /data/artifacts && k6 run k6-perf-test.js --vus {{ config.vus }} --duration {{ config.duration }} --execution-segment '{{ index }}/{{ count }}:{{ index + 1 }}/{{ count }}'
env:
- name: K6_WEB_DASHBOARD
value: "true"
- name: K6_WEB_DASHBOARD_EXPORT
value: "/data/artifacts/k6-test-report-worker-{{ index + 1}}.html"
artifacts:
workingDir: /data/artifacts
paths:
- '*.html'
---
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: k6-perf-test-workers-prometheus
spec:
config:
vus: {type: integer, default: 20}
duration: {type: string, default: '1m'}
workers: {type: integer, default: 3}
content:
git:
uri: https://github.com/kubeshop/testkube
revision: main
paths:
- test/k6/executor-tests/k6-perf-test.js
steps:
- name: Run test
parallel:
count: 'config.workers'
transfer:
- from: /data/repo
fetch:
- from: /data/artifacts
use:
- name: distribute/evenly
# container:
# resources:
# requests:
# cpu: 128m
# memory: 128Mi
paused: true # synchronise running all workers
run:
image: grafana/k6:0.49.0
workingDir: /data/repo/test/k6/executor-tests
shell: mkdir /data/artifacts && k6 run k6-perf-test.js -o experimental-prometheus-rw --vus {{ config.vus }} --duration {{ config.duration }} --execution-segment '{{ index }}/{{ count }}:{{ index + 1 }}/{{ count }}' --tag testid=worker-{{ index + 1}}
env:
- name: K6_WEB_DASHBOARD
value: "true"
- name: K6_WEB_DASHBOARD_EXPORT
value: "/data/artifacts/k6-test-report-worker-{{ index + 1}}.html"
- name: K6_PROMETHEUS_RW_SERVER_URL
value: 'http://prometheus-server.prometheus-grafana.svc.cluster.local:80/api/v1/write'
- name: K6_PROMETHEUS_RW_TREND_STATS
value: 'p(95),p(99),min,max'
- name: K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM
value: "true"
artifacts:
workingDir: /data/artifacts
paths:
- '*.html'
Loading

0 comments on commit 6276c1c

Please # to comment.