Files
vote/overlays/deploy/k6-configmap.yaml
demo-bot 319b09b1f2
Some checks failed
Build and Publish TechDocs / build-and-publish (push) Has been cancelled
CI Pipeline / Build and Test (push) Has been cancelled
feat(k6): add bespoke load test ConfigMap
2026-03-23 17:40:40 +00:00

23 lines
1.1 KiB
YAML

apiVersion: v1
kind: ConfigMap
metadata:
name: k6-test-vote
namespace: demo-apps
labels:
app: vote
app.kubernetes.io/managed-by: backstage
app.kubernetes.io/component: load-testing
data:
load-test.js: "import http from 'k6/http';\nimport { check, sleep, group } from\
\ 'k6';\n\nexport const options = {\n scenarios: {\n load_test: {\n executor:\
\ 'ramping-vus',\n startVUs: 0,\n stages: [\n { duration: ''10s'',\
\ target: 10 },\n { duration: ''30s'', target: 10 },\n { duration:\
\ '5s', target: 0 },\n ],\n },\n },\n thresholds: {\n http_req_duration:\
\ ['p(95)<500'],\n http_req_failed: ['rate<0.01'],\n },\n};\n\nconst BASE_URL\
\ = 'http://vote.demo-apps.svc.cluster.local:80';\n\nexport default function ()\
\ {\n group('Main Page', () => {\n const res = http.get(`${BASE_URL}/`);\n\
\ check(res, {\n 'status is 200': (r) => r.status === 200,\n 'response\
\ time < 500ms': (r) => r.timings.duration < 500,\n 'body contains HTML':\
\ (r) => r.body.includes('<!DOCTYPE html>'),\n });\n });\n\n sleep(0.5);\n\
}"