Skip to content

Instantly share code, notes, and snippets.

@darrenferguson
Created December 6, 2022 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenferguson/ca189a021f6b7dc42a28fd22269f19a7 to your computer and use it in GitHub Desktop.
Save darrenferguson/ca189a021f6b7dc42a28fd22269f19a7 to your computer and use it in GitHub Desktop.
Hello World K6
import http from 'k6/http';
import { check, sleep } from 'k6';
import { randomItem } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
export const options = {
stages: [
{ duration: '30s', target: 20 },
{ duration: '1m30s', target: 10 },
{ duration: '20s', target: 0 },
],
};
const names = ['John', 'Jane', 'Bert', 'Ed'];
export default function () {
const params = {
// cookies: { my_cookie: 'value' },
headers: { 'X-MyHeader': 'k6test' },
// redirects: 5,
// tags: { k6test: 'yes' },
};
var url = 'https://httpbin.test.k6.io?name=' + randomItem(names);
console.log(url);
const res = http.get(url , params);
// check(res, { 'status was 200': (r) => r.status == 200 });
sleep(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment