feat: add service discovery, OTel instrumentation, and k6 load tests #1

Merged
demo-bot merged 6 commits from backstage/batch-1777975281130 into main 2026-05-05 10:01:36 +00:00
Showing only changes of commit 760b395dec - Show all commits

133
k6/load-test.js Normal file
View File

@@ -0,0 +1,133 @@
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('Owner API', () => {
check(http.get(`${targetUrl}/owners/new`), {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
check(http.post(`${targetUrl}/owners/new`, 'firstName=John&lastName=Doe&address=123+Main+St&city=Springfield&telephone=1234567890'), {
'status is 302': (r) => r.status === 302,
'response time < 500ms': (r) => r.timings.duration < 500,
});
check(http.get(`${targetUrl}/owners/find`), {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
check(http.get(`${targetUrl}/owners`), {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
check(http.get(`${targetUrl}/owners/1/edit`), {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
check(http.post(`${targetUrl}/owners/1/edit`, 'firstName=Jane&lastName=Doe&address=456+Elm+St&city=Springfield&telephone=9876543210'), {
'status is 302': (r) => r.status === 302,
'response time < 500ms': (r) => r.timings.duration < 500,
});
check(http.get(`${targetUrl}/owners/1`), {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
});
sleep(0.5);
group('Pet API', () => {
check(http.get(`${targetUrl}/owners/1/pets/new`), {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
check(http.post(`${targetUrl}/owners/1/pets/new`, 'name=Buddy&birthDate=2020-01-01&type=Dog'), {
'status is 302': (r) => r.status === 302,
'response time < 500ms': (r) => r.timings.duration < 500,
});
check(http.get(`${targetUrl}/owners/1/pets/1/edit`), {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
check(http.post(`${targetUrl}/owners/1/pets/1/edit`, 'name=Buddy&birthDate=2019-01-01&type=Dog'), {
'status is 302': (r) => r.status === 302,
'response time < 500ms': (r) => r.timings.duration < 500,
});
});
sleep(0.5);
group('Visit API', () => {
check(http.get(`${targetUrl}/owners/1/pets/1/visits/new`), {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
check(http.post(`${targetUrl}/owners/1/pets/1/visits/new`, 'date=2023-10-01&description=Routine+checkup'), {
'status is 302': (r) => r.status === 302,
'response time < 500ms': (r) => r.timings.duration < 500,
});
});
sleep(0.5);
group('Vet API', () => {
check(http.get(`${targetUrl}/vets.html`), {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
check(http.get(`${targetUrl}/vets`), {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
});
sleep(0.5);
group('System API', () => {
check(http.get(`${targetUrl}/oups`, { responseCallback: http.expectedStatuses(500) }), {
'status is 500': (r) => r.status === 500,
'response time < 500ms': (r) => r.timings.duration < 500,
});
check(http.get(`${targetUrl}/`), {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
});
sleep(0.5);
}