feat: add service discovery, OTel instrumentation, and k6 load tests (#1)
This commit was merged in pull request #1.
This commit is contained in:
36
k6/load-test.js
Normal file
36
k6/load-test.js
Normal file
@@ -0,0 +1,36 @@
|
||||
// FALLBACK k6 load-test script.
|
||||
// This static skeleton is only used when The Watcher agent fails to generate
|
||||
// a bespoke k6 script tailored to the application's detected HTTP endpoints.
|
||||
// When generation succeeds, the agent produces a custom script that replaces
|
||||
// this file in the scaffolded output repository.
|
||||
import http from 'k6/http';
|
||||
import { check, sleep } from 'k6';
|
||||
|
||||
export const options = {
|
||||
scenarios: {
|
||||
load_test: {
|
||||
executor: 'ramping-vus',
|
||||
startVUs: 0,
|
||||
stages: [
|
||||
{ duration: '${{ values.k6_ramp_up | default("10s") }}', target: ${{ values.k6_virtual_users | default(10) }} },
|
||||
{ duration: '${{ values.k6_duration | default("30s") }}', target: ${{ values.k6_virtual_users | default(10) }} },
|
||||
{ duration: '5s', target: 0 },
|
||||
],
|
||||
},
|
||||
},
|
||||
thresholds: {
|
||||
http_req_duration: ['p(95)<500'],
|
||||
http_req_failed: ['rate<0.01'],
|
||||
},
|
||||
};
|
||||
|
||||
const BASE_URL = `http://${{ values.frontend_service_name | default("frontend") }}.${{ values.destination_namespace }}.svc.cluster.local:${{ values.frontend_service_port | default(80) }}`;
|
||||
|
||||
export default function () {
|
||||
const res = http.get(`${BASE_URL}${{ values.k6_target_path | default("/") }}`);
|
||||
check(res, {
|
||||
'status is 200': (r) => r.status === 200,
|
||||
'response time < 500ms': (r) => r.timings.duration < 500,
|
||||
});
|
||||
sleep(0.5);
|
||||
}
|
||||
36
k6/testrun.yaml
Normal file
36
k6/testrun.yaml
Normal file
@@ -0,0 +1,36 @@
|
||||
# FALLBACK k6 TestRun CRD — reference template for load testing ${{ values.component_id }}.
|
||||
# This static skeleton is only used when The Watcher agent fails to generate
|
||||
# a bespoke k6 script. When generation succeeds, the agent produces a custom
|
||||
# TestRun CRD that replaces this file in the scaffolded output repository.
|
||||
#
|
||||
# TestRun CRDs are committed to the repo as a reference. They are created
|
||||
# dynamically from Backstage (not auto-synced by ArgoCD) because they are
|
||||
# ephemeral one-shot resources.
|
||||
apiVersion: k6.io/v1alpha1
|
||||
kind: TestRun
|
||||
metadata:
|
||||
name: k6-${{ values.component_id }}
|
||||
namespace: ${{ values.destination_namespace }}
|
||||
labels:
|
||||
app: ${{ values.component_id }}
|
||||
backstage.io/component: ${{ values.component_id }}
|
||||
app.kubernetes.io/managed-by: backstage
|
||||
app.kubernetes.io/component: load-testing
|
||||
spec:
|
||||
parallelism: 1
|
||||
script:
|
||||
configMap:
|
||||
name: k6-test-${{ values.component_id }}
|
||||
file: load-test.js
|
||||
runner:
|
||||
image: grafana/k6:latest
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: k6-test-${{ values.component_id }}
|
||||
env:
|
||||
- name: K6_OTEL_SERVICE_NAME
|
||||
value: k6-${{ values.component_id }}
|
||||
- name: TEST_VUS
|
||||
value: "10"
|
||||
- name: TEST_DURATION
|
||||
value: "30s"
|
||||
Reference in New Issue
Block a user