Skip to content

Instantly share code, notes, and snippets.

@averylizette
Created November 10, 2019 01:29
Show Gist options
  • Save averylizette/bfb549bd75ee0e4d228a4a99e5634b44 to your computer and use it in GitHub Desktop.
Save averylizette/bfb549bd75ee0e4d228a4a99e5634b44 to your computer and use it in GitHub Desktop.
CONFIG:
import http from "k6/http";
import { check } from "k6";
import { Rate } from "k6/metrics";
export let errorRate = new Rate("errors");
export let options = {
thresholds: {
"errors": ["rate<0.1"], // <10% errors
}
};
export default function() {
const result = check(http.get("http://localhost:3001/9999996/"), {
"status is 200": (r) => r.status == 200
})
errorRate.add(!result);
};
EXAMPLE RESULTS:
Averys-MacBook-Air:proxy-avery averylizette$ k6 run --vus 10 --duration 50s checks_thresholds.js
/\ |‾‾| /‾‾/ /‾/
/\ / \ | |_/ / / /
/ \/ \ | | / ‾‾\
/ \ | |‾\ \ | (_) |
/ __________ \ |__| \__\ \___/ .io
execution: local
output: -
script: checks_thresholds.js
duration: 50s, iterations: -
vus: 10, max: 10
done [==========================================================] 50s / 50s
✓ status is 200
checks.....................: 100.00% ✓ 25932 ✗ 0
data_received..............: 29 MB 587 kB/s
data_sent..................: 2.3 MB 46 kB/s
✓ errors.....................: 0.00% ✓ 0 ✗ 25932
http_req_blocked...........: avg=8.99µs min=1µs med=4µs max=15.53ms p(90)=6µs p(95)=8µs
http_req_connecting........: avg=1.07µs min=0s med=0s max=5.59ms p(90)=0s p(95)=0s
http_req_duration..........: avg=19ms min=1.57ms med=12.13ms max=318.88ms p(90)=37.09ms p(95)=56.21ms
http_req_receiving.........: avg=127.22µs min=35µs med=100µs max=10.46ms p(90)=197µs p(95)=264µs
http_req_sending...........: avg=26.29µs min=8µs med=21µs max=7.57ms p(90)=38µs p(95)=52µs
http_req_tls_handshaking...: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_waiting...........: avg=18.84ms min=1.4ms med=11.98ms max=318.75ms p(90)=36.88ms p(95)=55.97ms
http_reqs..................: 25932 518.638475/s
iteration_duration.........: avg=19.23ms min=1.97ms med=12.37ms max=319.05ms p(90)=37.36ms p(95)=56.41ms
iterations.................: 25932 518.638475/s
vus........................: 10 min=10 max=10
vus_max....................: 10 min=10 max=10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment