From 92b42b9e53f30bdd4e220bfe334bda7f93c4724d Mon Sep 17 00:00:00 2001 From: Tomasz Konieczny Date: Tue, 26 Nov 2024 21:57:57 +0100 Subject: [PATCH 1/5] discardResponseBodies --- test/k6/executor-tests/k6-perf-test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/k6/executor-tests/k6-perf-test.js b/test/k6/executor-tests/k6-perf-test.js index ec72656f5c..11f9729834 100644 --- a/test/k6/executor-tests/k6-perf-test.js +++ b/test/k6/executor-tests/k6-perf-test.js @@ -1,11 +1,15 @@ import http from 'k6/http'; import { check } from 'k6'; +export const options = { + discardResponseBodies: true, +}; + export default function () { const res = http.get('https://testkube-test-page-lipsum.pages.dev/'); check(res, { 'status was 200': (r) => r.status == 200 }); - check(res, { - 'verify partial text': (r) => - r.body.includes('Testkube test page - Lipsum'), - }); + // check(res, { + // 'verify partial text': (r) => + // r.body.includes('Testkube test page - Lipsum'), + // }); } From 1a3f84c83954d11de1622e6495862d086b7c8821 Mon Sep 17 00:00:00 2001 From: Tomasz Konieczny Date: Wed, 27 Nov 2024 13:03:23 +0100 Subject: [PATCH 2/5] k6 perf test - gcp added --- test/k6/executor-tests/k6-perf-test-gcp.js | 15 +++++++++++++++ test/k6/executor-tests/k6-perf-test.js | 14 +++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 test/k6/executor-tests/k6-perf-test-gcp.js diff --git a/test/k6/executor-tests/k6-perf-test-gcp.js b/test/k6/executor-tests/k6-perf-test-gcp.js new file mode 100644 index 0000000000..ffc274c8f5 --- /dev/null +++ b/test/k6/executor-tests/k6-perf-test-gcp.js @@ -0,0 +1,15 @@ +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 }); + check(res, { + 'verify partial text': (r) => + r.body.includes('Testkube test page - Lipsum'), + }); +} diff --git a/test/k6/executor-tests/k6-perf-test.js b/test/k6/executor-tests/k6-perf-test.js index 11f9729834..5ec3c95fcb 100644 --- a/test/k6/executor-tests/k6-perf-test.js +++ b/test/k6/executor-tests/k6-perf-test.js @@ -1,15 +1,15 @@ import http from 'k6/http'; import { check } from 'k6'; -export const options = { - discardResponseBodies: true, -}; +// export const options = { +// discardResponseBodies: true, +// }; export default function () { const res = http.get('https://testkube-test-page-lipsum.pages.dev/'); check(res, { 'status was 200': (r) => r.status == 200 }); - // check(res, { - // 'verify partial text': (r) => - // r.body.includes('Testkube test page - Lipsum'), - // }); + check(res, { + 'verify partial text': (r) => + r.body.includes('Testkube test page - Lipsum'), + }); } From 0ac779effbe567823391ea7e369c8c58342ab7e3 Mon Sep 17 00:00:00 2001 From: Tomasz Konieczny Date: Wed, 27 Nov 2024 14:36:30 +0100 Subject: [PATCH 3/5] k6 perf test - gcp-discard-response-bodies --- test/examples/k6-perf/k6-crd.yaml | 215 ++++++++++++++++-- ...6-perf-test-gcp-discard-response-bodies.js | 11 + test/k6/executor-tests/k6-perf-test-gcp.js | 4 - test/k6/executor-tests/k6-perf-test.js | 4 - 4 files changed, 209 insertions(+), 25 deletions(-) create mode 100644 test/k6/executor-tests/k6-perf-test-gcp-discard-response-bodies.js diff --git a/test/examples/k6-perf/k6-crd.yaml b/test/examples/k6-perf/k6-crd.yaml index ac72c31f1e..56774cfc1d 100644 --- a/test/examples/k6-perf/k6-crd.yaml +++ b/test/examples/k6-perf/k6-crd.yaml @@ -7,14 +7,14 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - revision: main + revision: k6-per-test-adjustments 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} @@ -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: k6-per-test-adjustments + 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: @@ -50,7 +90,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - revision: main + revision: k6-per-test-adjustments paths: - test/k6/executor-tests/k6-perf-test.js steps: @@ -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 @@ -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: k6-per-test-adjustments + 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: k6-per-test-adjustments + 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: @@ -95,7 +225,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - revision: main + revision: k6-per-test-adjustments paths: - test/k6/executor-tests/k6-perf-test.js steps: @@ -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 @@ -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: k6-per-test-adjustments + 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' diff --git a/test/k6/executor-tests/k6-perf-test-gcp-discard-response-bodies.js b/test/k6/executor-tests/k6-perf-test-gcp-discard-response-bodies.js new file mode 100644 index 0000000000..1d81b66665 --- /dev/null +++ b/test/k6/executor-tests/k6-perf-test-gcp-discard-response-bodies.js @@ -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 }); +} diff --git a/test/k6/executor-tests/k6-perf-test-gcp.js b/test/k6/executor-tests/k6-perf-test-gcp.js index ffc274c8f5..ef7dffca62 100644 --- a/test/k6/executor-tests/k6-perf-test-gcp.js +++ b/test/k6/executor-tests/k6-perf-test-gcp.js @@ -1,10 +1,6 @@ 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 }); diff --git a/test/k6/executor-tests/k6-perf-test.js b/test/k6/executor-tests/k6-perf-test.js index 5ec3c95fcb..ec72656f5c 100644 --- a/test/k6/executor-tests/k6-perf-test.js +++ b/test/k6/executor-tests/k6-perf-test.js @@ -1,10 +1,6 @@ import http from 'k6/http'; import { check } from 'k6'; -// export const options = { -// discardResponseBodies: true, -// }; - export default function () { const res = http.get('https://testkube-test-page-lipsum.pages.dev/'); check(res, { 'status was 200': (r) => r.status == 200 }); From 5f0422688962578171055edaf22661753e84982f Mon Sep 17 00:00:00 2001 From: Tomasz Konieczny Date: Tue, 3 Dec 2024 13:15:54 +0100 Subject: [PATCH 4/5] k6 perf test - updated definitions --- test/examples/k6-perf/k6-crd.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/examples/k6-perf/k6-crd.yaml b/test/examples/k6-perf/k6-crd.yaml index 56774cfc1d..aa93251b65 100644 --- a/test/examples/k6-perf/k6-crd.yaml +++ b/test/examples/k6-perf/k6-crd.yaml @@ -7,7 +7,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - revision: k6-per-test-adjustments + main paths: - test/k6/executor-tests/k6-perf-test.js container: @@ -47,7 +47,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - revision: k6-per-test-adjustments + main paths: - test/k6/executor-tests/k6-perf-test-gcp.js container: @@ -90,7 +90,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - revision: k6-per-test-adjustments + main paths: - test/k6/executor-tests/k6-perf-test.js steps: @@ -135,7 +135,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - revision: k6-per-test-adjustments + main paths: - test/k6/executor-tests/k6-perf-test-gcp.js steps: @@ -180,7 +180,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - revision: k6-per-test-adjustments + main paths: - test/k6/executor-tests/k6-perf-test-gcp-discard-response-bodies.js steps: @@ -225,7 +225,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - revision: k6-per-test-adjustments + main paths: - test/k6/executor-tests/k6-perf-test.js steps: @@ -276,7 +276,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - revision: k6-per-test-adjustments + main paths: - test/k6/executor-tests/k6-perf-test-gcp.js steps: From 144e11e5b7e3bb39f616b844bc1d25a4ce4aa23c Mon Sep 17 00:00:00 2001 From: Tomasz Konieczny Date: Tue, 3 Dec 2024 13:23:20 +0100 Subject: [PATCH 5/5] k6 perf test - revision fixed --- test/examples/k6-perf/k6-crd.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/examples/k6-perf/k6-crd.yaml b/test/examples/k6-perf/k6-crd.yaml index aa93251b65..03f8a91dde 100644 --- a/test/examples/k6-perf/k6-crd.yaml +++ b/test/examples/k6-perf/k6-crd.yaml @@ -7,7 +7,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - main + revision: main paths: - test/k6/executor-tests/k6-perf-test.js container: @@ -47,7 +47,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - main + revision: main paths: - test/k6/executor-tests/k6-perf-test-gcp.js container: @@ -90,7 +90,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - main + revision: main paths: - test/k6/executor-tests/k6-perf-test.js steps: @@ -135,7 +135,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - main + revision: main paths: - test/k6/executor-tests/k6-perf-test-gcp.js steps: @@ -180,7 +180,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - main + revision: main paths: - test/k6/executor-tests/k6-perf-test-gcp-discard-response-bodies.js steps: @@ -225,7 +225,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - main + revision: main paths: - test/k6/executor-tests/k6-perf-test.js steps: @@ -276,7 +276,7 @@ spec: content: git: uri: https://github.com/kubeshop/testkube - main + revision: main paths: - test/k6/executor-tests/k6-perf-test-gcp.js steps: