Skip to content

Commit

Permalink
feat: K6 perf test adjustments (#6065)
Browse files Browse the repository at this point in the history
* discardResponseBodies

* k6 perf test - gcp added

* k6 perf test - gcp-discard-response-bodies

* k6 perf test - updated definitions

* k6 perf test - revision fixed
  • Loading branch information
tkonieczny authored Dec 3, 2024
1 parent bcabeae commit 9dce5f2
Show file tree
Hide file tree
Showing 3 changed files with 217 additions and 14 deletions.
209 changes: 195 additions & 14 deletions test/examples/k6-perf/k6-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ spec:
paths:
- test/k6/executor-tests/k6-perf-test.js
container:
# resources:
# requests:
# cpu: 128m
# memory: 128Mi
resources:
requests:
cpu: 15
memory: 25Gi
workingDir: /data/repo/test/k6/executor-tests
config:
vus: {type: integer, default: 20}
Expand All @@ -38,6 +38,46 @@ spec:
paths:
- '*'
---
# Simple
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: k6-perf-test-gcp
spec:
content:
git:
uri: https://github.com/kubeshop/testkube
revision: main
paths:
- test/k6/executor-tests/k6-perf-test-gcp.js
container:
resources:
requests:
cpu: 15
memory: 25Gi
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-gcp.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:
Expand All @@ -63,11 +103,11 @@ spec:
- from: /data/artifacts
use:
- name: distribute/evenly
# container:
# resources:
# requests:
# cpu: 128m
# memory: 128Mi
container:
resources:
requests:
cpu: 15
memory: 25Gi
paused: true # synchronise running all workers
run:
image: grafana/k6:0.49.0
Expand All @@ -85,6 +125,96 @@ spec:
---
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: k6-perf-test-workers-gcp
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-gcp.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: 15
memory: 25Gi
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-gcp.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-gcp-discard-response-bodies
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-gcp-discard-response-bodies.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: 15
memory: 25Gi
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-gcp-discard-response-bodies.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:
Expand All @@ -108,11 +238,11 @@ spec:
- from: /data/artifacts
use:
- name: distribute/evenly
# container:
# resources:
# requests:
# cpu: 128m
# memory: 128Mi
container:
resources:
requests:
cpu: 15
memory: 25Gi
paused: true # synchronise running all workers
run:
image: grafana/k6:0.49.0
Expand All @@ -133,3 +263,54 @@ spec:
workingDir: /data/artifacts
paths:
- '*.html'
---
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: k6-perf-test-gcp-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-gcp.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: 15
memory: 25Gi
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-gcp.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'
11 changes: 11 additions & 0 deletions test/k6/executor-tests/k6-perf-test-gcp-discard-response-bodies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import http from 'k6/http';
import { check } from 'k6';

export const options = {
discardResponseBodies: true,
};

export default function () {
const res = http.get('https://storage.googleapis.com/perf-test-static-page-bucket/testkube-test-page-lorem-ipsum/index.html');
check(res, { 'status was 200': (r) => r.status == 200 });
}
11 changes: 11 additions & 0 deletions test/k6/executor-tests/k6-perf-test-gcp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import http from 'k6/http';
import { check } from 'k6';

export default function () {
const res = http.get('https://storage.googleapis.com/perf-test-static-page-bucket/testkube-test-page-lorem-ipsum/index.html');
check(res, { 'status was 200': (r) => r.status == 200 });
check(res, {
'verify partial text': (r) =>
r.body.includes('Testkube test page - Lipsum'),
});
}

0 comments on commit 9dce5f2

Please sign in to comment.