While executing grafana k6 script on the console the time to be taken for test execution is mentioned, but do we have a way to know in advance ie before actually the test begin execution how much time any test going to take.
If you specify the duration
option (default null
) or the maxDuration
scenario option (default '10m'
), the test will generally run for the given duration – and will be forcibly stopped if the (max) duration is exceeded. This is the test duration that k6 displays, give or take. The real duration additionally includes starting the k6 process, parsing your JS files, setup/teardown/summary functions, plus the gracefulStop
period.
If you don’t specify the (max) duration, you must execute your test since k6 cannot possibly predict the future. Why not?
export default function() {
http.get('https://yourapi/one'); // usually takes 2 seconds
http.get('https://yourapi/two'); // takes between 1 and 20 seconds
http.get('https://yourapi/three'); // takes 4 or 40 seconds
http.get('https://yourapi/four'); // can take up to 1 minute
}
Given the above test function, how long will a single test run take? You can’t know and neither can k6. It could be anything between 7 seconds and 2 minutes 2 seconds or more.