Created
March 26, 2018 21:23
-
-
Save ejhari/ca5fa05fa8c47b60cb5e808a3d3be170 to your computer and use it in GitHub Desktop.
Load Testing using K6 + InfluxDB + Grafana
This file contains hidden or 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
// REF: https://medium.com/codeinsights/how-to-load-test-your-node-js-app-using-k6-74d7339bc787 | |
// | |
// brew tap loadimpact/k6 | |
// brew install k6 grafana influxdb | |
// k6 run load_test.js | |
// k6 run --out influxdb=http://localhost:8086/resultsdb load_test.js | |
// | |
// To have launchd start grafana now and restart at login: | |
// brew services start grafana | |
// Or, if you don't want/need a background service you can just run: | |
// grafana-server --config=/usr/local/etc/grafana/grafana.ini --homepath /usr/local/share/grafana cfg:default.paths.logs=/usr/local/var/log/grafana cfg:default.paths.data=/usr/local/var/lib/grafana cfg:default.paths.plugins=/usr/local/var/lib/grafana/plugins | |
// | |
// To have launchd start influxdb now and restart at login: | |
// brew services start influxdb | |
// Or, if you don't want/need a background service you can just run: | |
// influxd -config /usr/local/etc/influxdb.conf | |
// | |
import http from "k6/http"; | |
import { check, sleep } from "k6"; | |
export let options = { | |
vus: 1000, | |
duration: "60s" | |
}; | |
export default function() { | |
//let res = http.get("url"); | |
var url = "https://localhost:2020/path/to/hit"; | |
var payload = JSON.stringify({ email: "", password: "" }); | |
var params = { headers: { | |
"Content-Type": "application/x-www-form-urlencoded", | |
} }; | |
let res = http.post(url, payload, params); | |
check(res, { | |
"success": (r) => r.status == 200 | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment