feat: prepare v1.1 deploy and presenter load test
- build and push v1.1 images from the service main worktrees - switch manifests to :v1.1; add web control Secret refs - configure API BOOTSTRAP_REFRESH=60s and remove unused DATA_DIR - add k6 presenter scenario with a mid-run control POST - require control credentials in make load; update runbook and drills
This commit is contained in:
1 parent
40bc8e47d0
commit
b98a1bab42
12 files changed
+264
-117
No files matched your search
@@ -6,23 +6,31 @@
|
||||
// stock k6 binary. Build the pinned binary once:
|
||||
// make k6-build
|
||||
//
|
||||
// The `presenter` scenario starts at 2m30s (configurable) and POSTs one
|
||||
// scenario change so scenario propagation through Cloudflare is measured.
|
||||
//
|
||||
// Run:
|
||||
// API_URL=https://api-pulse.noelsabia.dev ./k6/k6-sse run k6/sse.js
|
||||
// source ~/.config/pulsecast/control-auth.env
|
||||
// API_URL=https://api-pulse.noelsabia.dev CONTROL_USER="$CONTROL_USER" \
|
||||
// CONTROL_PASS="$CONTROL_PASS" ./k6/k6-sse run k6/sse.js
|
||||
// make load
|
||||
//
|
||||
// Recorded metrics:
|
||||
// sse_connections_opened counter, expected >= SSE_VUS (120)
|
||||
// sse_connections_closed counter, expected to equal connections_opened
|
||||
// sse_connections_closed counter, expected >= SSE_VUS
|
||||
// sse_open_success rate of VUs that opened a stream
|
||||
// sse_event_latency p95 server-timestamp-to-client latency, ms
|
||||
// sse_scenario_latency same, scenario events only (if any occur)
|
||||
// sse_scenario_latency p95 scenario-event latency, ms
|
||||
// sse_ping_latency same, heartbeat events only
|
||||
// sse_events_received total events
|
||||
// presenter_post_success rate of the single scenario POST
|
||||
// presenter_post_duration duration of the scenario POST, ms
|
||||
//
|
||||
// Each VU closes its stream after SSE_HOLD_PINGS heartbeats (20 * 15 s = 5 min).
|
||||
// That keeps 120 streams open for the full window and closes cleanly.
|
||||
import http from 'k6/http';
|
||||
import sse from 'k6/x/sse';
|
||||
import encoding from 'k6/encoding';
|
||||
import { check } from 'k6';
|
||||
import { Counter, Rate, Trend } from 'k6/metrics';
|
||||
|
||||
@@ -31,6 +39,11 @@ const STREAM_URL = __ENV.SSE_URL || `${API_URL}/api/stream`;
|
||||
const VUS = Math.max(1, Number(__ENV.SSE_VUS || 120));
|
||||
const HOLD_PINGS = Math.max(1, Number(__ENV.SSE_HOLD_PINGS || 20));
|
||||
const MAX_DURATION = __ENV.SSE_MAX_DURATION || '6m';
|
||||
const CONTROL_USER = __ENV.CONTROL_USER || '';
|
||||
const CONTROL_PASS = __ENV.CONTROL_PASS || '';
|
||||
const PRESENTER_SCENARIO = __ENV.PRESENTER_SCENARIO || 'rainy-saturday';
|
||||
const PRESENTER_AT = __ENV.PRESENTER_AT || '2m30s';
|
||||
const PRESENTER_TIMEOUT = __ENV.PRESENTER_TIMEOUT || '10s';
|
||||
|
||||
const connectionsOpened = new Counter('sse_connections_opened');
|
||||
const connectionsClosed = new Counter('sse_connections_closed');
|
||||
@@ -40,12 +53,18 @@ const eventsReceived = new Counter('sse_events_received');
|
||||
const eventLatency = new Trend('sse_event_latency', true);
|
||||
const scenarioLatency = new Trend('sse_scenario_latency', true);
|
||||
const pingLatency = new Trend('sse_ping_latency', true);
|
||||
const presenterSuccess = new Rate('presenter_post_success');
|
||||
const presenterLatency = new Trend('presenter_post_duration', true);
|
||||
|
||||
const thresholds = {
|
||||
sse_open_success: ['rate>=0.99'],
|
||||
sse_event_latency: ['p(95)<2000'],
|
||||
sse_scenario_latency: ['p(95)<2000'],
|
||||
presenter_post_success: ['rate==1'],
|
||||
sse_connection_errors: ['count==0'],
|
||||
};
|
||||
thresholds[`sse_connections_opened`] = [`count>=${VUS}`];
|
||||
thresholds[`sse_connections_closed`] = [`count>=${VUS}`];
|
||||
|
||||
export const options = {
|
||||
scenarios: {
|
||||
@@ -56,6 +75,15 @@ export const options = {
|
||||
maxDuration: MAX_DURATION,
|
||||
gracefulStop: '30s',
|
||||
},
|
||||
presenter: {
|
||||
executor: 'shared-iterations',
|
||||
vus: 1,
|
||||
iterations: 1,
|
||||
startTime: PRESENTER_AT,
|
||||
maxDuration: '30s',
|
||||
gracefulStop: '5s',
|
||||
exec: 'presenter',
|
||||
},
|
||||
},
|
||||
thresholds,
|
||||
// Every VU owns one long-lived connection; do not pool them.
|
||||
@@ -71,6 +99,39 @@ export function setup() {
|
||||
return { api: API_URL, stream: STREAM_URL, vus: VUS };
|
||||
}
|
||||
|
||||
// One presenter action during the run. This is deliberately separate from the
|
||||
// SSE VUs so the POST does not block a client connection.
|
||||
export function presenter() {
|
||||
if (!CONTROL_USER || !CONTROL_PASS) {
|
||||
throw new Error(
|
||||
'CONTROL_USER and CONTROL_PASS are required for the presenter scenario; source ~/.config/pulsecast/control-auth.env',
|
||||
);
|
||||
}
|
||||
|
||||
const payload = JSON.stringify({
|
||||
scenario: PRESENTER_SCENARIO,
|
||||
weather: { temp_delta_c: 4, precip_mm: 0 },
|
||||
});
|
||||
const basic = encoding.b64encode(`${CONTROL_USER}:${CONTROL_PASS}`);
|
||||
const res = http.post(`${API_URL}/api/scenario`, payload, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Basic ${basic}`,
|
||||
},
|
||||
timeout: PRESENTER_TIMEOUT,
|
||||
tags: { endpoint: 'presenter' },
|
||||
});
|
||||
|
||||
presenterLatency.add(res.timings.duration);
|
||||
const ok = check(res, {
|
||||
'presenter scenario 200': (r) => r.status === 200,
|
||||
});
|
||||
presenterSuccess.add(ok);
|
||||
if (!ok) {
|
||||
console.error(`presenter POST failed: status=${res.status} body=${res.body}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default function () {
|
||||
let opened = false;
|
||||
let closedByUs = false;
|
||||
|
||||
Reference in new issue
Block a user