Skip to content

HabitaNexus/monorepo / skills/system-reliability-engineering/load-testing-performance

load-testing-performance

Unverified

scripts/k6/stress-test.js

View on GitHub
/**
 * k6 Stress Test
 *
 * Stress test to find system breaking points.
 * Gradually increases load beyond normal capacity.
 *
 * Usage:
 *   k6 run stress-test.js
 *   k6 run stress-test.js --env BASE_URL=https://api.example.com
 */

import http from 'k6/http';
import { check } from 'k6';

export const options = {
  stages: [
    { duration: '2m', target: 100 },
    { duration: '5m', target: 100 },
    { duration: '2m', target: 200 },
    { duration: '5m', target: 200 },
    { duration: '2m', target: 300 },
    { duration: '5m', target: 300 },
    { duration: '2m', target: 400 },
    { duration: '5m', target: 400 },
    { duration: '10m', target: 0 }, // Recovery
  ],
  thresholds: {
    http_req_failed: ['rate<0.05'], // Allow up to 5% errors under stress
    http_req_duration: ['p(95)<2000'], // Relaxed under stress
  },
};

export default function () {
  const baseUrl = __ENV.BASE_URL || 'https://api.example.com';

  const response = http.get(`${baseUrl}/api/v1/data`);

  check(response, {
    'status is 200': (r) => r.status === 200,
  });
}
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall