Query is related to below config options in k6 tool:
I have tried to set the config as below in config.json for both the queries.
For tlsAuth, cannot put 'open' in the json file as below. So what is the work around?
Trying to understand minIterationDuration config option. Does k6 wait if default function completes execution earlier than this defined duration? In the other scenario, does it wait for no time when default function completes execution in more time than this defined duration?
below is snippet from config.json file -> (actual file has more options too)
{
"tlsAuth": [{
"domains": ["example.com"],
"cert": open(".\certs\mycert.pem"),
"key": open(".\certs\mycert-key.pem")
}],
"minIterationDuration":20
}
Expecting to define all my k6 options via config file including tlsAuth option and use defined certs from another folder. Do not want to define k6 options in the main js file.
Kindly advise. Thanks in advance and my apologies if this is a simple coding level issue.
To start with the easier questions:
Trying to understand minIterationDuration config option. Does k6 wait if default function completes execution earlier than this defined duration?
Yes
In the other scenario, does it wait for no time when default function completes execution in more time than this defined duration?
Yes. And it would be more readable if you define the minIterationDuration
with its tune unit, so something like "2s"
or "400ms"
.
For tlsAuth, cannot put 'open' in the json file as below. So what is the work around?
That JSON file is a simple data file, it cannot have any functions like open()
in it. open()
would only work in the JS script that k6 executes - it just reads the file contents and returns them as a string by default. So, if you want the tlsAuth
option in the JSON config, you have to specify it as a string, albeit a very big one.
Do not want to define k6 options in the main js file.
You can have a hybrid approach. You can have most of your config in a simple JSON or JS file, open()
or import
that in the main JS file and export it again as the script options
:
export let options = JSON.parse(open("my-custom-config.json"))
options.tlsAuth = open("/some/other/file")