Last active
March 28, 2019 16:54
-
-
Save boynoiz/2f1fed3ccc13ddb6d7e5c4e6b84e355a to your computer and use it in GitHub Desktop.
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 http from "k6/http"; | |
import { check } from "k6"; | |
import { Trend, Rate, Counter, Gauge } from "k6/metrics"; | |
export let TrendRTT = new Trend("RTT"); | |
export let RateContentOK = new Rate("ContentOK"); | |
export let TrackRate = new Rate("TrackRate"); | |
export let GaugeContentSize = new Gauge("ContentSize"); | |
export let GaugeResponseTime = new Gauge("ResponseTime"); | |
export let CounterErrors = new Counter("Errors"); | |
export let CounterRequests = new Counter("Requests"); | |
export let maxResponseTime = 0.0; | |
export let options = { | |
// Add VU ramping option, total test length is 3m | |
stages: [ | |
// Ramp up from 1 VU to 25 VUs for 1 minute | |
{ target: 25, duration: "30s" }, | |
// Stay constant at 25 VUs for 1 minute | |
{ target: 25, duration: "10s" }, | |
// Ramp down from 25 VUs to 0 VUs for 1 minute | |
{ target: 0, duration: "30s" } | |
], | |
thresholds: { | |
RTT: ["p(99)<300", "p(70)<250", "avg<200", "med<150", "min<100"], | |
ContentOK: ["rate>0.95"], | |
ContentSize: ["value<4000"], | |
Errors: ["count<100"] | |
}, | |
maxRedirects: 0 | |
}; | |
export default function() { | |
let res = http.get("https://www.myapp.test/"); | |
TrendRTT.add(res.timings.looking_up + res.timings.connecting); | |
RateContentOK.add(res.status == 200); | |
GaugeContentSize.add(res.body.length); | |
CounterErrors.add(!res.status == 200); | |
CounterRequests.add(1); | |
maxResponseTime = Math.max(maxResponseTime, res.timings.duration); | |
GaugeResponseTime.add(maxResponseTime); | |
let passed = check(res, { "status is 200": r => r.status === 200 }); | |
TrackRate.add(passed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment