Load test types
Smoke testing
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 3, // Key for Smoke test. Keep it at 2, 3, max 5 VUs
duration: '1m', // This can be shorter or just a few iterations
};
export default () => {
const urlRes = http.get('https://quickpizza.grafana.com');
sleep(1);
// MORE STEPS
// Add only the processes that will be on high demand
// Step1
// Step2
// etc.
};

Average-load testing
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
// Key configurations for avg load test in this section
stages: [
{ duration: '5m', target: 100 }, // traffic ramp-up from 1 to 100 users over 5 minutes.
{ duration: '30m', target: 100 }, // stay at 100 users for 30 minutes
{ duration: '5m', target: 0 }, // ramp-down to 0 users
],
};
export default () => {
const urlRes = http.get('https://quickpizza.grafana.com');
sleep(1);
};

Stress testing
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
// Key configurations for Stress in this section
stages: [
{ duration: '10m', target: 200 }, // traffic ramp-up from 1 to a higher 200 users over 10 minutes.
{ duration: '30m', target: 200 }, // stay at higher 200 users for 30 minutes
{ duration: '5m', target: 0 }, // ramp-down to 0 users
],
};
export default () => {
const urlRes = http.get('https://quickpizza.grafana.com');
sleep(1);
};

Soak testing
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
// Key configurations for Soak test in this section
stages: [
{ duration: '5m', target: 100 }, // traffic ramp-up from 1 to 100 users over 5 minutes.
{ duration: '8h', target: 100 }, // stay at 100 users for 8 hours!!!
{ duration: '5m', target: 0 }, // ramp-down to 0 users
],
};
export default () => {
const urlRes = http.get('https://quickpizza.grafana.com');
sleep(1);
};

Spike testing
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
// Key configurations for spike in this section
stages: [
{ duration: '2m', target: 2000 }, // fast ramp-up to a high point
// No plateau
{ duration: '1m', target: 0 }, // quick ramp-down to 0 users
],
};
export default () => {
const urlRes = http.get('https://quickpizza.grafana.com');
sleep(1);
};

Breakpoint testing
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
// Key configurations for breakpoint in this section
executor: 'ramping-arrival-rate', //Assure load increase if the system slows
stages: [
{ duration: '2h', target: 20000 }, // just slowly ramp-up to a HUGE load
],
};
export default () => {
const urlRes = http.get('https://quickpizza.grafana.com');
sleep(1);
};
