k6 Load Testing #10 (Finale): Daily Workflow, CI Exit Codes and Common Pitfalls
Code & Test Automation
0:00 / 0:00
k6 Load Testing #10 (Finale): Daily Workflow, CI Exit Codes and Common Pitfalls
5 просмотров · 21 ч назад
Code & Test Automation
21 подписчик
5 просмотров · 21 ч назад
Code & Test Automation | / @codetestautomation
The k6 series finale: one Grafana k6 test with smoke and load profiles from the same file, thresholds as SLOs, setup login with a check, groups and a custom checkout metric, a CI script that stops the build on a non-zero exit code (99 when thresholds are crossed), --summary-export, and the most common pitfalls with real runs, like checks that never fail a build. Every run is real k6 output against a small local practice server.
In this video:
The shape of a good k6 test
Smoke and load profiles with -e PROFILE
A CI script with exit codes
--summary-export and what true means
Docker (typed only)
Pitfall: no thresholds = exit 0
More pitfalls and a practice plan
Video 10 of 10 in the k6 Load Testing series with Grafana k6, for freshers and experienced test engineers on Windows, macOS and Linux: install, scripts, checks, thresholds, stages, scenarios and executors, test data, custom metrics, setup and teardown, and CI workflows. Almost every minute is a real terminal session with real k6 output, run only against a local practice server.
CHAPTERS
0:00 Introduction
0:55 Start the practice server
1:10 The shape of a good test
1:43 Reuse the helpers
1:58 One test, two profiles
2:46 Thresholds for both
3:11 Setup with a check
3:28 The business steps
4:01 The smoke run
5:05 The load run
6:00 A CI script
7:00 Run the CI script
7:25 A broken change
8:17 The summary file
9:02 Docker
9:33 Pitfall: no thresholds
10:48 More pitfalls
11:56 Your practice plan
12:23 Looking back
13:08 Reading results every day
13:39 Stop the server
13:49 The final test
14:07 Recap
14:47 Thanks for watching
HOW THE DEMOS WERE MADE
Everything between the title card and the recap is a live screen recording of a real terminal: bash 5.2 in xfce4-terminal on Debian Linux, with the official k6 v2.3.0 release binary from GitHub (checksum verified) and the GNU nano 8.4 editor. Every script was typed at a human pace and every line of k6 output is real; nothing was edited in afterwards. SAFETY: every test in this video sends load ONLY to a small practice server (ShopKart, a Python standard-library app in the project zip) running on localhost on the same machine. Where the course notes use the public demo site test.k6.io, the video uses the local server instead and shows the original line as TYPED ONLY. Load is kept small (a few virtual users for seconds). No account was used: no sign-in to Grafana Cloud, no k6 cloud command, and anonymous usage reporting is switched off with K6_NO_USAGE_REPORT=true. Commands that were not run here (package managers that need sudo or admin rights, Docker, cloud commands, public URLs) are shown as TYPED ONLY: typed on screen, never run, and cancelled with Ctrl+C, so no output is ever invented.
CORRECTIONS TO THE COURSE NOTES
'Store the summary or use k6 Cloud for trends': k6 Cloud needs a Grafana Cloud account; this series stays local and stores the summary with --summary-export=summary.json (or handleSummary()). No account, no k6 cloud command.
In the --summary-export file (legacy format), a threshold value of true means the threshold was CROSSED (failed), not passed: "rate›0.99": true in a failed run.
Failing checks alone never change the exit code: a run with 0/3 checks and 100% http_req_failed exits 0. Add a threshold such as checks: ['rate›0.99'] so CI fails (exit 99).
k6 exit codes used in CI: 0 = passed, 99 = thresholds crossed, 107 = script error. Pass extra options through a wrapper with "$@" (e.g. bash ci.sh -e PASSWORD=wrong).
Docker ('grafana/k6') is shown TYPED ONLY; the video runs the local k6 binary. 'Loading large data inside the default function': open() only works in the init stage, see video 7 (SharedArray).
The notes' 'typical structure' is built as shop-test.js with smoke and load profiles from one file (-e PROFILE=load). checkout_time uses res.timings.duration of the two checkout requests. Load is at most 3 VUs for 20 s, against the local practice server only.
PRACTICE
1. Start the practice server: python3 server/shop_server.py &
2. bash ci.sh and bash ci.sh -e PASSWORD=wrong
3. k6 run -q -e PROFILE=load shop-test.js
4. Add a third profile, stress, with 3 VUs for 30s
5. Week 1: checks + a threshold + stages. Week 2: a scenario, SharedArray and a custom metric.
Practice tip: install k6, unzip the project, start the local ShopKart practice server, and type every script right after you see it. Only ever point load tests at a server you own or have written permission to test; this series uses a local server on localhost for every run.
That completes the k6 Load Testing series: all 10 videos.
#k6 #LoadTesting #PerformanceTesting #GrafanaK6 #CodeAndTestAutomation
Subscribe to Code & Test Automation for more k6, performance testing, Java, coding and test automation tutorials: / @codetestautomation