You have a good summary of exactly what it takes to calculate the max duration of the test run. A couple of minor points though:
Setup() duration is variable and not included. This should mostly be negligible assuming that this doesn’t take more than a couple of minutes.
You can restrict max
teardown() times with the
teardownTimeout options, which will give you an upper bound in your calculations.
§ Non-scenario profiles:
After k6 v0.27.0, every k6 run is running one or more scenarios, each with a specific executor. The top-level
stages options are just shortcuts to running a single-scenario test run with the specific executor that corresponds to the option (see the docs for which it is). So even they have
gracefulStop, it’s just the default one of 30s.
So, yeah… calculating the total test duration is a bit complex. We plan to add some helper functions to get this type of execution information inside of the scripts, and I made a note about this use case specifically: Improve execution information in scripts · Issue #1320 · k6io/k6 · GitHub