Load-test rig: k6 swarm script + in-cluster target drone
This commit is contained in:
38
manifests/loadtest/k6-script.yaml
Normal file
38
manifests/loadtest/k6-script.yaml
Normal file
@@ -0,0 +1,38 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: loadtest
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: k6-script
|
||||
namespace: loadtest
|
||||
data:
|
||||
test.js: |
|
||||
// Generic load generator. Configured by env:
|
||||
// TARGET_URL - full URL to hit
|
||||
// VUS - virtual users per pod (default 20)
|
||||
// DURATION - k6 duration string (default "60s")
|
||||
import http from 'k6/http';
|
||||
import { check, sleep } from 'k6';
|
||||
|
||||
const target = __ENV.TARGET_URL || 'http://example.com';
|
||||
const vus = parseInt(__ENV.VUS || '20');
|
||||
const duration = __ENV.DURATION || '60s';
|
||||
|
||||
export const options = {
|
||||
stages: [
|
||||
{ duration: '10s', target: vus },
|
||||
{ duration: duration, target: vus },
|
||||
{ duration: '5s', target: 0 },
|
||||
],
|
||||
thresholds: { http_req_failed: ['rate<0.01'] },
|
||||
noConnectionReuse: false,
|
||||
};
|
||||
|
||||
export default function () {
|
||||
const res = http.get(target, { timeout: '10s' });
|
||||
check(res, { 'status 2xx/3xx': (r) => r.status < 300 });
|
||||
sleep(1 / vus * 10);
|
||||
}
|
||||
Reference in New Issue
Block a user