Skip to content

Instantly share code, notes, and snippets.

@danielmackay
Created May 20, 2024 10:15
Show Gist options
  • Save danielmackay/15d8a8bb066416276cf076fc24b21d5f to your computer and use it in GitHub Desktop.
Save danielmackay/15d8a8bb066416276cf076fc24b21d5f to your computer and use it in GitHub Desktop.
K6 - Basic load test
// k6 run ./script.js
import http from 'k6/http';
import { sleep, check } from 'k6';
import { Rate } from 'k6/metrics';
export const errorRate = new Rate('errors');
export let options = {
insecureSkipTLSVerify: true,
noConnectionReuse: false,
vus: 30, // number of virtual users
duration: '2m', // duration of the test
};
export default function () {
const url = 'https://localhost:7255/heroes';
check(http.get(url), {
'status is 200': (r) => r.status == 200,
}) || errorRate.add(1);
sleep(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment