Skip to content

Instantly share code, notes, and snippets.

@paulgrav
Last active July 30, 2018 15:47
Show Gist options
  • Save paulgrav/a8b6d77639b0d54774b499c5dfd660c6 to your computer and use it in GitHub Desktop.
Save paulgrav/a8b6d77639b0d54774b499c5dfd660c6 to your computer and use it in GitHub Desktop.
import http from "k6/http";
import { check, group } from "k6";
import { Rate } from "k6/metrics";
import { sleep } from "k6";
export let errorRate = new Rate("errors");
export let options = {
stages: [
{ duration: "5m", target: 1 },
],
noConnectionReuse: true,
noVUConnectionReuse: true,
userAgent: "MyK6UserAgentString/1.0"
};
const baseUrl = "http://host.name/";
export default function() {
visitHomepage();
sleep(1);
};
function visitHomepage() {
let res = http.get(baseUrl + "/");
check(res, {
"status is 200": checkStatus(200)
}) || errorRate.add(1);
};
function checkStatus(statusCode) {
return (res) => res.status == statusCode;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment