cluster

Infrastructure files for Nordgedanken and Midnightthoughts.
git clone git://archive.git.mtrnord.blog/MTRNord/cluster.git
Log | Files | Refs | README

health.js (863B)


      1 /**
      2  * Health endpoint load test — establishes a baseline for server throughput
      3  * separate from federation logic (which is network-bound).
      4  *
      5  * Run:
      6  *   k6 run k6/health.js
      7  *   BASE_URL=http://prod:8080 k6 run k6/health.js
      8  */
      9 
     10 import http from 'k6/http';
     11 import { check, sleep } from 'k6';
     12 import { BASE_URL, DEFAULT_THRESHOLDS } from './config.js';
     13 
     14 export const options = {
     15   scenarios: {
     16     health_check: {
     17       executor: 'constant-vus',
     18       vus: 20,
     19       duration: '30s',
     20     },
     21   },
     22   thresholds: {
     23     ...DEFAULT_THRESHOLDS,
     24     // Health endpoint should be much faster than federation checks
     25     http_req_duration: ['p(95)<500'],
     26   },
     27 };
     28 
     29 export default function () {
     30   const res = http.get(`${BASE_URL}/healthz`);
     31   check(res, {
     32     'status 200': (r) => r.status === 200,
     33     'body is ok': (r) => r.body.trim() === 'ok',
     34   });
     35   sleep(0.1);
     36 }