Skip to content

Instantly share code, notes, and snippets.

@ppcano
Created November 15, 2019 13:20
Show Gist options
  • Save ppcano/34a13d1b9237af8502204645cff1b4f5 to your computer and use it in GitHub Desktop.
Save ppcano/34a13d1b9237af8502204645cff1b4f5 to your computer and use it in GitHub Desktop.
import { check, sleep } from 'k6';
import http from 'k6/http';
export let options = {
duration: "1m",
vus: 100
}
export default function() {
let res;
res = http.get("https://httpbin.org/get");
check(res, { "status is 200": (r) => r.status === 200 });
res = http.get("https://httpbin.org/bearer", {
headers: { "Authorization": "Bearer da39a3ee5e6b4b0d3255bfef95601890afd80709" }
});
check(res, {
"status is 200": (r) => r.status === 200,
"is authenticated": (r) => r.json()["authenticated"] === true
});
res = http.get("https://httpbin.org/base64/azYgaXMgYXdlc29tZSE=");
check(res, {
"status is 200": (r) => r.status === 200,
"k6 is awesome!": (r) => r.body === "k6 is awesome!"
});
sleep(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment