From 87fb00a1ed99421a1b84a38da19e9c2fb9ac7cb1 Mon Sep 17 00:00:00 2001 From: demo-bot Date: Tue, 13 Oct 2026 16:06:11 +0000 Subject: [PATCH] =?UTF-8?q?Placement=20decision:=20PLACED=20on=20Public=20?= =?UTF-8?q?cloud=20=C2=B7=20US=20East=20-=20for=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- k6/load-test.js | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 k6/load-test.js diff --git a/k6/load-test.js b/k6/load-test.js new file mode 100644 index 0000000..2e2e540 --- /dev/null +++ b/k6/load-test.js @@ -0,0 +1,110 @@ +import http from 'k6/http'; +import { check, sleep, group } from 'k6'; + +const vus = parseInt(__ENV.TEST_VUS || '10'); +const duration = __ENV.TEST_DURATION || '30s'; +const targetUrl = __ENV.TARGET_URL || 'http://frontend.demo-apps.svc.cluster.local:80'; + +export const options = { + scenarios: { + load_test: { + executor: 'ramping-vus', + startVUs: 0, + stages: [ + { duration: '10s', target: vus }, + { duration: duration, target: vus }, + { duration: '5s', target: 0 }, + ], + }, + }, + thresholds: { + http_req_duration: ['p(95)<500'], + http_req_failed: ['rate<0.01'], + }, +}; + +http.setResponseCallback(http.expectedStatuses({ min: 200, max: 399 })); + +export default function () { + group('System API', () => { + const resWelcome = http.get(`${targetUrl}/`); + check(resWelcome, { + 'status is 200': (r) => r.status === 200, + 'response time < 500ms': (r) => r.timings.duration < 500, + }); + + const resCrash = http.get(`${targetUrl}/oups`, { responseCallback: http.expectedStatuses(500) }); + check(resCrash, { + 'status is 500': (r) => r.status === 500, + }); + }); + + sleep(0.5); + + group('Owner API', () => { + const resFindOwners = http.get(`${targetUrl}/owners/find`); + check(resFindOwners, { + 'status is 200': (r) => r.status === 200, + 'response time < 500ms': (r) => r.timings.duration < 500, + }); + + const resOwners = http.get(`${targetUrl}/owners`); + check(resOwners, { + 'status is 200': (r) => r.status === 200, + 'response time < 500ms': (r) => r.timings.duration < 500, + }); + + const resOwnerDetails = http.get(`${targetUrl}/owners/1`); + check(resOwnerDetails, { + 'status is 200': (r) => r.status === 200, + 'response time < 500ms': (r) => r.timings.duration < 500, + }); + + const resCreateOwner = http.post(`${targetUrl}/owners/new`, 'firstName=John&lastName=Doe&address=123+Main+St&city=Springfield&telephone=1234567890'); + check(resCreateOwner, { + 'status is 302': (r) => r.status === 302, + }); + + const resEditOwner = http.post(`${targetUrl}/owners/1/edit`, 'firstName=Jane&lastName=Doe&address=456+Elm+St&city=Springfield&telephone=9876543210'); + check(resEditOwner, { + 'status is 302': (r) => r.status === 302, + }); + }); + + sleep(0.5); + + group('Pet API', () => { + const resCreatePet = http.post(`${targetUrl}/owners/1/pets/new`, 'name=Buddy&birthDate=2023-01-01&type=Dog'); + check(resCreatePet, { + 'status is 302': (r) => r.status === 302, + }); + + const resEditPet = http.post(`${targetUrl}/owners/1/pets/1/edit`, 'name=Buddy&birthDate=2023-01-01&type=Dog'); + check(resEditPet, { + 'status is 302': (r) => r.status === 302, + }); + + const resCreateVisit = http.post(`${targetUrl}/owners/1/pets/1/visits/new`, 'date=2023-12-01&description=Routine+checkup'); + check(resCreateVisit, { + 'status is 302': (r) => r.status === 302, + }); + }); + + sleep(0.5); + + group('Vet API', () => { + const resVetList = http.get(`${targetUrl}/vets.html`); + check(resVetList, { + 'status is 200': (r) => r.status === 200, + 'response time < 500ms': (r) => r.timings.duration < 500, + }); + + const resVetJson = http.get(`${targetUrl}/vets`); + check(resVetJson, { + 'status is 200': (r) => r.status === 200, + 'response time < 500ms': (r) => r.timings.duration < 500, + }); + }); + + sleep(0.5); +} \ No newline at end of file