Skip to content

Instantly share code, notes, and snippets.

@paulgrav
Last active Jul 30, 2018
Embed
What would you like to do?
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