Files
petclinic-demo-jonathan-scaf-2/overlays/deploy/k6-configmap.yaml
demo-bot bf0e0f5f38
All checks were successful
Build and Push to ACR / Build and Push (push) Has been skipped
Build and Publish TechDocs / build-and-publish (push) Successful in 1m16s
feat: add service discovery, OTel instrumentation, and k6 load tests (#1)
2026-05-05 10:01:35 +00:00

69 lines
5.2 KiB
YAML

apiVersion: v1
kind: ConfigMap
metadata:
name: k6-test-petclinic-demo-jonathan-scaf-2
namespace: demo-apps
labels:
app: petclinic-demo-jonathan-scaf-2
app.kubernetes.io/managed-by: backstage
app.kubernetes.io/component: load-testing
data:
K6_OUT: opentelemetry
K6_OTEL_GRPC_EXPORTER_INSECURE: 'true'
K6_OTEL_GRPC_EXPORTER_ENDPOINT: otel-collector.monitoring.svc.cluster.local:4317
K6_OTEL_METRIC_PREFIX: k6_
K6_OTEL_FLUSH_INTERVAL: '1000'
K6_OTEL_EXPORT_INTERVAL: '5000'
K6_OTEL_SERVICE_NAME: k6-petclinic-demo-jonathan-scaf-2
load-test.js: "import http from 'k6/http';\nimport { check, sleep, group } from\
\ 'k6';\n\nconst vus = parseInt(__ENV.TEST_VUS || '10');\nconst duration = __ENV.TEST_DURATION\
\ || '30s';\nconst targetUrl = __ENV.TARGET_URL || 'http://frontend.demo-apps.svc.cluster.local:80';\n\
\nexport const options = {\n scenarios: {\n load_test: {\n executor:\
\ 'ramping-vus',\n startVUs: 0,\n stages: [\n { duration: '10s',\
\ target: vus },\n { duration: duration, target: vus },\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\nhttp.setResponseCallback(http.expectedStatuses({\
\ min: 200, max: 399 }));\n\nexport default function () {\n group('Owner API',\
\ () => {\n check(http.get(`${targetUrl}/owners/new`), {\n 'status is\
\ 200': (r) => r.status === 200,\n 'response time < 500ms': (r) => r.timings.duration\
\ < 500,\n });\n\n check(http.post(`${targetUrl}/owners/new`, 'firstName=John&lastName=Doe&address=123+Main+St&city=Springfield&telephone=1234567890'),\
\ {\n 'status is 302': (r) => r.status === 302,\n 'response time < 500ms':\
\ (r) => r.timings.duration < 500,\n });\n\n check(http.get(`${targetUrl}/owners/find`),\
\ {\n 'status is 200': (r) => r.status === 200,\n 'response time < 500ms':\
\ (r) => r.timings.duration < 500,\n });\n\n check(http.get(`${targetUrl}/owners`),\
\ {\n 'status is 200': (r) => r.status === 200,\n 'response time < 500ms':\
\ (r) => r.timings.duration < 500,\n });\n\n check(http.get(`${targetUrl}/owners/1/edit`),\
\ {\n 'status is 200': (r) => r.status === 200,\n 'response time < 500ms':\
\ (r) => r.timings.duration < 500,\n });\n\n check(http.post(`${targetUrl}/owners/1/edit`,\
\ 'firstName=Jane&lastName=Doe&address=456+Elm+St&city=Springfield&telephone=9876543210'),\
\ {\n 'status is 302': (r) => r.status === 302,\n 'response time < 500ms':\
\ (r) => r.timings.duration < 500,\n });\n\n check(http.get(`${targetUrl}/owners/1`),\
\ {\n 'status is 200': (r) => r.status === 200,\n 'response time < 500ms':\
\ (r) => r.timings.duration < 500,\n });\n });\n\n sleep(0.5);\n\n group('Pet\
\ API', () => {\n check(http.get(`${targetUrl}/owners/1/pets/new`), {\n \
\ 'status is 200': (r) => r.status === 200,\n 'response time < 500ms':\
\ (r) => r.timings.duration < 500,\n });\n\n check(http.post(`${targetUrl}/owners/1/pets/new`,\
\ 'name=Buddy&birthDate=2020-01-01&type=Dog'), {\n 'status is 302': (r) =>\
\ r.status === 302,\n 'response time < 500ms': (r) => r.timings.duration\
\ < 500,\n });\n\n check(http.get(`${targetUrl}/owners/1/pets/1/edit`),\
\ {\n 'status is 200': (r) => r.status === 200,\n 'response time < 500ms':\
\ (r) => r.timings.duration < 500,\n });\n\n check(http.post(`${targetUrl}/owners/1/pets/1/edit`,\
\ 'name=Buddy&birthDate=2019-01-01&type=Dog'), {\n 'status is 302': (r) =>\
\ r.status === 302,\n 'response time < 500ms': (r) => r.timings.duration\
\ < 500,\n });\n });\n\n sleep(0.5);\n\n group('Visit API', () => {\n \
\ check(http.get(`${targetUrl}/owners/1/pets/1/visits/new`), {\n 'status\
\ is 200': (r) => r.status === 200,\n 'response time < 500ms': (r) => r.timings.duration\
\ < 500,\n });\n\n check(http.post(`${targetUrl}/owners/1/pets/1/visits/new`,\
\ 'date=2023-10-01&description=Routine+checkup'), {\n 'status is 302': (r)\
\ => r.status === 302,\n 'response time < 500ms': (r) => r.timings.duration\
\ < 500,\n });\n });\n\n sleep(0.5);\n\n group('Vet API', () => {\n check(http.get(`${targetUrl}/vets.html`),\
\ {\n 'status is 200': (r) => r.status === 200,\n 'response time < 500ms':\
\ (r) => r.timings.duration < 500,\n });\n\n check(http.get(`${targetUrl}/vets`),\
\ {\n 'status is 200': (r) => r.status === 200,\n 'response time < 500ms':\
\ (r) => r.timings.duration < 500,\n });\n });\n\n sleep(0.5);\n\n group('System\
\ API', () => {\n check(http.get(`${targetUrl}/oups`, { responseCallback: http.expectedStatuses(500)\
\ }), {\n 'status is 500': (r) => r.status === 500,\n 'response time\
\ < 500ms': (r) => r.timings.duration < 500,\n });\n\n check(http.get(`${targetUrl}/`),\
\ {\n 'status is 200': (r) => r.status === 200,\n 'response time < 500ms':\
\ (r) => r.timings.duration < 500,\n });\n });\n\n sleep(0.5);\n}"