Public Welfare Eligibility Calculation API Load and Stress Test Script
Author a k6 load and chaos test script for public assistance benefit eligibility calculation engines.
Use this template when validating the resilience, throughput, and error boundaries of statutory public benefits services under peak surge conditions. It produces an automated k6 performance test script that simulates mass enrollment surges with fault injection.
Role: Staff Site Reliability Test Engineer specializing in mission-critical public assistance infrastructure.
Context
- Assistance Program: {{benefit_program_name}}
- Endpoint Specifications: {{api_endpoint_definitions}}
- Peak Concurrency: {{peak_concurrent_applicants}}
- Chaos Perturbation Rate: {{failure_injection_rate}}
- Performance Target: {{latency_slo_threshold}}
- Identity Authority: {{auth_token_provider}}
Task
Develop a production-grade k6 performance and chaos testing script that simulates massive applicant surge traffic against civic welfare calculation microservices while injecting transient infrastructure faults.
Method
- Define realistic virtual user arrival rate curves that ramp to {{peak_concurrent_applicants}} to simulate open-enrollment spikes for {{benefit_program_name}}.
- Structure authorization workflows that refresh transient bearer tokens against {{auth_token_provider}} across simulated client threads.
- Construct parameter-driven request payloads mirroring complex household income, dependent verification, and eligibility claims from {{api_endpoint_definitions}}.
- Introduce randomized network jitter, malformed payloads, and aborted TCP connections at a rate of {{failure_injection_rate}} to stress error-handling paths.
- Implement custom k6 metrics tracking p95 and p99 response times against {{latency_slo_threshold}}.
- Evaluate eligibility calculation response payloads for data corruption, unexpected 5xx crashes, or concurrency deadlocks.
- Generate structured summary metrics highlighting threshold breaches, throughput drops, and recovery times.
Constraints
- The test script MUST abort execution if error rates exceed 15% within a 30-second sliding window.
- Synthetic applicant profiles MUST NOT collide on unique identification fields during concurrent requests.
- Do not hardcode static authentication tokens that expire mid-execution.
- Custom thresholds MUST fail the CI pipeline if p95 latency exceeds {{latency_slo_threshold}}.
Output format
A single, standalone JavaScript k6 script featuring:
- K6 scenario options with ramping arrival rates and failure thresholds.
- Token acquisition setup lifecycle function.
- Default execution loop with payload generators and chaos injection.
- Teardown and custom metric summary reporter.
Self-review
- Validate that virtual user ramp stages peak exactly at {{peak_concurrent_applicants}}.
- Ensure chaos perturbations strictly observe the {{failure_injection_rate}} ratio.
- Verify all endpoints from {{api_endpoint_definitions}} are covered in test iterations.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.