How to execute task only once

#1

Hi, I would like to know, If is possible to make k6 execute some logic only one per VU, I mean for example I want to make a login when each VU starts, but after having the access token don’t do this again.

0 Likes

#3

Are you looking to just execute an action once per test in total? If so, you may want to check out the setup and teardown lifecycle stages. . During setup, actions will be completed one, by virtual user 0. You can then pass this information to the default function. Similarly, you can use the teardown function later on for post test actions. I think this is most useful if you need to terminate an environment or trigger a process to clean something up.

0 Likes

#4

I think point 1 of my proposals is what you want, although what @mark said is probably a better first option.

0 Likes