Генератор скриптов K6
Создавайте готовые к продакшену k6-скрипты для load / stress / spike / soak / smoke со стадиями, запросами, проверками, порогами и CSV-данными.
Steady, realistic traffic to validate everyday performance.
const at the top of the script) and optional CSV files.No CSV files declared. Add one if your test reads tabular data via SharedArray.
VUs over time
import http from 'k6/http';
import { check, sleep } from 'k6';
// --- Generated k6 script. URLs, headers, and payloads are inlined. ---
export const options = {
stages: [
{ duration: '2m', target: 10 },
{ duration: '3m', target: 50 },
{ duration: '5m', target: 50 },
{ duration: '5m', target: 100 },
{ duration: '10m', target: 100 },
{ duration: '5m', target: 0 },
],
thresholds: {
http_req_failed: ['rate<0.01'],
http_req_duration: ['p(95)<500'],
checks: ['rate>0.95'],
},
};
export default function () {
// 1. GET https://example.com/
let res = http.get('https://example.com/');
check(res, {
'Status code is 200': (r) => res.status === 200,
'Response time < 500ms': (r) => res.timings.duration < 500,
'Response body contains "success"': (r) => res.body && res.body.includes("success"),
});
sleep(1);
// 2. POST https://example.com/api/login
res = http.post('https://example.com/api/login', '{\n "username": "[email protected]",\n "password": "password123"\n}');
check(res, {
'Status code is 200': (r) => res.status === 200,
'Response time < 500ms': (r) => res.timings.duration < 500,
'Response body contains "success"': (r) => res.body && res.body.includes("success"),
});
sleep(1);
// 3. GET https://example.com/api/users
res = http.get('https://example.com/api/users', { headers: {
'Authorization': 'Bearer your_token_here',
} });
check(res, {
'Status code is 200': (r) => res.status === 200,
'Response time < 500ms': (r) => res.timings.duration < 500,
'Response body contains "success"': (r) => res.body && res.body.includes("success"),
});
sleep(1);
// 4. POST https://example.com/api/users
res = http.post('https://example.com/api/users', '{\n "name": "Alice"\n}', { headers: {
'Authorization': 'Bearer your_token_here',
} });
check(res, {
'Status code is 200': (r) => res.status === 200,
'Response time < 500ms': (r) => res.timings.duration < 500,
'Response body contains "success"': (r) => res.body && res.body.includes("success"),
});
sleep(1);
}
The K6 script generator turns a short form into a runnable script.js for Grafana k6. Pick a scenario template, declare endpoints, set thresholds, and download a file you can drop into CI or run from your laptop. No hand-written boilerplate, no forgotten import lines.
A single script.js with k6's standard layout: imports, inlined variables, an options block (stages or constant VUs, thresholds, tags), HTTP requests, and check assertions. Optional CSV data is loaded via SharedArray so virtual users iterate through rows without re-reading the file.
Backend engineers writing baseline load tests, QA leads building release gates, SREs preparing capacity plans, and platform teams that need a reproducible script to share with vendors or auditors. Junior developers can start from a working template instead of a blank file.
Before launches and during release sign-off. After a major refactor when hot-path latency might have changed. When sizing the next infrastructure tier. After an incident, to add a regression test that reproduces the breaking request mix. As a quick smoke test inside every PR pipeline.
k6 is a single binary. Run the generated script locally on macOS, Linux, or Windows; in a Docker container; or in CI with grafana/k6 on GitHub Actions, GitLab CI, CircleCI, or Jenkins. Output integrates with InfluxDB, Prometheus, Grafana Cloud k6, and Datadog.
Boilerplate drift is real: missing imports, forgotten tags, threshold values that quietly become aspirational. A generator emits the same shape every time, so reviewers compare intent (your config) instead of plumbing. Inlined variables also mean the script runs without environment setup — k6 run script.js just works.
script.js.k6 run script.js.order_id), and feed user credentials from a CSV.Load tests confirm everyday performance. Stress tests find break points. Spike tests verify autoscaling. Soak tests reveal memory leaks. Smoke tests are tiny pre-flight checks for your CI pipeline.
Each stage has a duration and target VU count. k6 linearly interpolates between the previous and next target. Always add a final ramp-down stage to 0 for a graceful shutdown so in-flight requests finish cleanly.
Thresholds are pass/fail rules. Common defaults: HTTP failure rate < 1%, p(95) latency < 500 ms, and checks pass rate > 95%. CI fails the test when any threshold is breached, which is exactly what you want for an automated gate.
Base URL, tokens, and credentials are written directly into generated URLs, headers, and payloads. The file runs without any shell setup or runtime template variables. Edit the values in the UI or directly in script.js after download.
k6 run script.js — all values are inlined, no shell setup needed.k6 is an open-source load testing tool by Grafana Labs. You write JavaScript test scripts and execute them with the k6 CLI to drive virtual users (VUs) against an HTTP endpoint, gRPC service, or browser flow.
No. The generator builds a script.js file you download and run locally with the k6 binary. Your URLs, payloads, and credentials never leave the browser.
Install k6 (Homebrew, apt, choco, or the official installer) and run k6 run script.js. All values are inlined into the script — no shell setup needed. The Setup Instructions tab shows the exact commands per OS.
All values are hardcoded as const at the top of script.js by design — fastest path to a runnable file. If you commit it to git, swap secret values for placeholders or move them to __ENV reads after download.
Always assert HTTP status, response duration, and a body invariant. Add domain-specific assertions (auth token returned, item count > 0, etc.) so a bad deploy fails the test instead of slipping through.