feat(k6): add bespoke load test ConfigMap
This commit is contained in:
58
overlays/deploy/k6-configmap.yaml
Normal file
58
overlays/deploy/k6-configmap.yaml
Normal file
@@ -0,0 +1,58 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: k6-test-petclinic
|
||||
namespace: demo-apps
|
||||
labels:
|
||||
app: petclinic
|
||||
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://petclinic.demo-apps.svc.cluster.local:80';\n\nexport default function\
|
||||
\ () {\n group('System API', () => {\n let 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 });\n\n res = http.get(`${BASE_URL}/oups`);\n\
|
||||
\ check(res, {\n 'status is 500': (r) => r.status === 500,\n });\n\
|
||||
\ });\n\n sleep(0.5);\n\n group('Owner API', () => {\n let res = http.get(`${BASE_URL}/owners/new`);\n\
|
||||
\ check(res, {\n 'status is 200': (r) => r.status === 200,\n });\n\n\
|
||||
\ res = http.post(`${BASE_URL}/owners/new`, JSON.stringify({\n firstName:\
|
||||
\ 'John',\n lastName: 'Doe',\n address: '123 Main St',\n city:\
|
||||
\ 'Springfield',\n telephone: '1234567890',\n }), {\n headers: {\
|
||||
\ 'Content-Type': 'application/json' },\n });\n check(res, {\n 'status\
|
||||
\ is 302': (r) => r.status === 302,\n });\n\n res = http.get(`${BASE_URL}/owners/find`);\n\
|
||||
\ check(res, {\n 'status is 200': (r) => r.status === 200,\n });\n\n\
|
||||
\ res = http.get(`${BASE_URL}/owners`);\n check(res, {\n 'status is\
|
||||
\ 200': (r) => r.status === 200,\n });\n\n res = http.get(`${BASE_URL}/owners/1/edit`);\n\
|
||||
\ check(res, {\n 'status is 200': (r) => r.status === 200,\n });\n\n\
|
||||
\ res = http.post(`${BASE_URL}/owners/1/edit`, JSON.stringify({\n firstName:\
|
||||
\ 'Jane',\n lastName: 'Doe',\n address: '456 Elm St',\n city: 'Springfield',\n\
|
||||
\ telephone: '9876543210',\n }), {\n headers: { 'Content-Type': 'application/json'\
|
||||
\ },\n });\n check(res, {\n 'status is 302': (r) => r.status === 302,\n\
|
||||
\ });\n\n res = http.get(`${BASE_URL}/owners/1`);\n check(res, {\n \
|
||||
\ 'status is 200': (r) => r.status === 200,\n });\n\n res = http.get(`${BASE_URL}/owners/1/pets/new`);\n\
|
||||
\ check(res, {\n 'status is 200': (r) => r.status === 200,\n });\n\n\
|
||||
\ res = http.post(`${BASE_URL}/owners/1/pets/new`, JSON.stringify({\n \
|
||||
\ name: 'Buddy',\n birthDate: '2020-01-01',\n type: { id: 1, name: 'Dog'\
|
||||
\ },\n }), {\n headers: { 'Content-Type': 'application/json' },\n });\n\
|
||||
\ check(res, {\n 'status is 302': (r) => r.status === 302,\n });\n\n\
|
||||
\ res = http.get(`${BASE_URL}/owners/1/pets/1/edit`);\n check(res, {\n \
|
||||
\ 'status is 200': (r) => r.status === 200,\n });\n\n res = http.post(`${BASE_URL}/owners/1/pets/1/edit`,\
|
||||
\ JSON.stringify({\n name: 'Buddy',\n birthDate: '2020-01-01',\n \
|
||||
\ type: { id: 1, name: 'Dog' },\n }), {\n headers: { 'Content-Type':\
|
||||
\ 'application/json' },\n });\n check(res, {\n 'status is 302': (r)\
|
||||
\ => r.status === 302,\n });\n\n res = http.get(`${BASE_URL}/owners/1/pets/1/visits/new`);\n\
|
||||
\ check(res, {\n 'status is 200': (r) => r.status === 200,\n });\n\n\
|
||||
\ res = http.post(`${BASE_URL}/owners/1/pets/1/visits/new`, JSON.stringify({\n\
|
||||
\ description: 'Routine check-up',\n }), {\n headers: { 'Content-Type':\
|
||||
\ 'application/json' },\n });\n check(res, {\n 'status is 302': (r)\
|
||||
\ => r.status === 302,\n });\n });\n\n sleep(0.5);\n\n group('Vet API',\
|
||||
\ () => {\n let res = http.get(`${BASE_URL}/vets.html`);\n check(res, {\n\
|
||||
\ 'status is 200': (r) => r.status === 200,\n });\n\n res = http.get(`${BASE_URL}/vets`);\n\
|
||||
\ check(res, {\n 'status is 200': (r) => r.status === 200,\n });\n\
|
||||
\ });\n\n sleep(0.5);\n}\n"
|
||||
Reference in New Issue
Block a user