I want to run a function before k6 script. I thought that using node command in setup function (E.g. node test.js) This is possible? If it is not possible how can I run a function before k6 script ? And how I use that outside function ‘s returning value in setup? I m searching this because my function takes 5 minute to giving response for server. It is not meaningful using in k6 script so calling from response data outside is more effective
If there is any alternative idea could u give me a sample code or etc?
Hi @PaulM thanks for reply , I know this method but the main case is like below;
I should run a function outside of k6 script . And I have to call returning value in k6. Because I must run that function one time . If I call in export default function it will work more than one time . It should work one time . When running in setup it passes the default 60 sn so giving timeout error. Because of this I should find a solution like this;
1.Running function outside
2. Pushing the json value to an array (I will set the returning value in outside function)
3. I will call the array in setup function
When I use this methods , function run one time outside of k6 script. I will only take returning array in k6 script. I m searching a code like this
@Yusuf One of the options is to output data to a file with one script. Another script unloads the required values from the file.
Example:
To write to the file, you will need to display the required values in log cosole.log(response) and run the script with parameters k6 run test.js 2>resp.txt and then use the resp.txt file. And example this and this
The request timeout looks correct, but consider that setup() itself might also time out. That behavior is determined by the setupTimeout global option, see Options reference