-
-
Save gabrielfsousa/c734d5bd87a31003ac36e7acf60f37cf to your computer and use it in GitHub Desktop.
k6 Performance Test Script - Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { sleep, group, check } from "k6"; | |
import http from "k6/http"; | |
export let options = { | |
thresholds: { | |
// 95% of requests must finish within 500 ms & 99% within 1500 ms | |
http_req_duration: ['p(95) < 500', 'p(99) < 1500'], | |
}, | |
}; | |
export default function performanceTest() { | |
group("GET: Home Page", function () { | |
let res = http.get("https://nakov-mvc-node-app.herokuapp.com/"); | |
check(res, { 'HTTP status == 200': (r) => r.status == 200 }); | |
sleep(2); | |
}); | |
group("GET: Students Page", function () { | |
let res = http.get("https://nakov-mvc-node-app.herokuapp.com/students"); | |
check(res, { 'HTTP status == 200': (r) => r.status == 200 }); | |
sleep(3); | |
}); | |
group("GET, POST: Add Students Page", function () { | |
let res = http.get("https://nakov-mvc-node-app.herokuapp.com/add-student"); | |
check(res, { 'HTTP status == 200': (r) => r.status == 200 }); | |
sleep(3); | |
let uniqueNum = new Date().getTime(); | |
let body = { name: "New" + uniqueNum, email: uniqueNum + "@gmail.com" }; | |
http.post("https://nakov-mvc-node-app.herokuapp.com/add-student", body); | |
sleep(2); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
k6 --vus 5000 --duration 20s run script.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/\ |‾‾| /‾‾/ /‾‾/ | |
/\ / \ | |/ / / / | |
/ \/ \ | ( / ‾‾\ | |
/ \ | |\ \ | (‾) | | |
/ __________ \ |__| \__\ \_____/ .io | |
execution: local | |
script: script.js | |
output: - | |
scenarios: (100.00%) 1 scenario, 500 max VUs, 50s max duration (incl. graceful stop): | |
* default: 500 looping VUs for 20s (gracefulStop: 30s) | |
running (53.0s), 0000/5000 VUs, 378 complete and 4627 interrupted iterations | |
default ✓ [======================================] 5000 VUs 20s | |
█ GET: Home Page | |
✗ HTTP status == 200 | |
↳ 99% — ✓ 3197 / ✗ 15 | |
█ GET: Students Page | |
✓ HTTP status == 200 | |
█ GET, POST: Add Students Page | |
✓ HTTP status == 200 | |
checks.....................: 99.75% ✓ 6101 ✗ 15 | |
data_received..............: 200 MB 3.8 MB/s | |
data_sent..................: 3.8 MB 71 kB/s | |
group_duration.............: avg=15.57s min=2.21s med=13.44s max=50.46s p(90)=29.23s p(95)=35.13s | |
http_req_blocked...........: avg=4.43s min=0s med=0s max=49.38s p(90)=14.31s p(95)=23.35s | |
http_req_connecting........: avg=694.59ms min=0s med=0s max=16.57s p(90)=1.64s p(95)=3.37s | |
✗ http_req_duration..........: avg=5.17s min=0s med=818.95ms max=44.85s p(90)=17.79s p(95)=25.37s | |
http_req_receiving.........: avg=2.48s min=0s med=0s max=42.59s p(90)=9.7s p(95)=15s | |
http_req_sending...........: avg=472.64µs min=0s med=0s max=124.99ms p(90)=993.7µs p(95)=1ms | |
http_req_tls_handshaking...: avg=3.72s min=0s med=0s max=48.22s p(90)=11.05s p(95)=22.27s | |
http_req_waiting...........: avg=2.68s min=0s med=742.99ms max=43.39s p(90)=7.78s p(95)=13.14s | |
http_reqs..................: 7781 146.818418/s | |
iteration_duration.........: avg=40.58s min=16s med=41.88s max=50.98s p(90)=48.24s p(95)=48.99s | |
iterations.................: 389 7.339977/s | |
vus........................: 0 min=0 max=5000 | |
vus_max....................: 5000 min=5000 max=5000 | |
ERRO[0103] some thresholds have failed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment