Skip to main content

Load Testing with k6

A practical k6 workflow against the Pizza Playground, from install to a full load model. This track follows Performance Testing Fundamentals — read that first if you have not already, the test types and NFR vocabulary carry straight into the scripts here.

Important: This track is in progress, written and validated against k6 v2.2.0. Every code sample lives in k6/sample/ and the status table below says which pages have been run for real against a running playground and which have not.

The Sample Project​

Everything shown in these pages runs from the sample project. Download it, unzip it, and run from the k6/sample folder inside. The Sample Project page lists every script and -e switch.

⬇ Download the k6 sample (.zip)

The zip is rebuilt from k6/sample/ in the repository every time the site is built, so it always matches these pages.

unzip k6-sample.zip
cd k6/sample
k6 run 01-first-test.js

Status​

PageWrittenValidatedScreenshots
1. Install ToolsYesYesNo
2. Understand RequirementsYesYesN/A
3. k6 ConceptsYesYesN/A
4. RecordingYesYesNo
5. Auth, Correlation and DataYesYesNo
6. Checks and ThresholdsYesYesNo
7. DebugYesYesNo
8. Load ModelYesValidated (scaled)No
9. Execute and AnalyzeYesValidated (scaled)No
10. ReportingYesValidated (scaled)No
99. Sample ProjectYesYesnone needed
99. Future / To ExploreYesn/anone needed

Basics​

#TopicDescription
1Install ToolsThe k6 binary, Docker image, and running the first script
2Understand Requirements and FlowTurning NFRs into thresholds, executors and VUs
3k6 ConceptsLifecycle, VUs vs. iterations, options vs. CLI vs. env vars
4RecordingRecord a HAR with Playwright codegen, convert it with har-to-k6, and why a green replay can lie
5Auth, Correlation and DataLogging in, correlating ids, SharedArray test data
6Checks and ThresholdsPass/fail criteria inside the script
7DebugMaking a failing script tell you why

Applying Load​

#TopicDescription
8Load ModelStages, executors and profiles from the Performance Testing module
9Execute and Analyze ResultsRunning scripts and reading the summary and output
10ReportingCommunicating findings

Appendix​

TopicDescription
Sample ProjectDownload the runnable sample, what is inside, and every -e switch
Future / To ExploreGrafana Cloud output, the browser module, xk6 extensions