Skip to content

Instantly share code, notes, and snippets.

@lukecav
Last active August 19, 2021 12:49
Show Gist options
  • Save lukecav/7720716d7e31058d1456a17f580505dd to your computer and use it in GitHub Desktop.
Save lukecav/7720716d7e31058d1456a17f580505dd to your computer and use it in GitHub Desktop.
k6 - stages ramping example script
import http from "k6/http";
import { check } from "k6";
/*
* Stages (aka ramping) is how you, in code, specify the ramping of VUs.
* That is, how many VUs should be active and generating traffic against
* the target system at any specific point in time for the duration of
* the test.
*
* The following stages configuration will result in up-flat-down ramping
* profile over a 150s total test duration.
*/
export let options = {
stages: [
// Ramp-up from 1 to 60 VUs in 60s
{ duration: "60s", target: 60 },
// Stay at rest on 60 VUs for 60s
{ duration: "60s" },
// Ramp-down from 60 to 0 VUs for 30s
{ duration: "30s", target: 0 }
]
};
export default function() {
let res = http.get("https://woocommerce-test.rcfjx3-liquidwebsites.com/");
check(res, { "status is 200": (r) => r.status === 200 });
}