I want every VU to represent a specific person, with different login credentials.
In other words, I want my 5 VUs to authenticate as 5 different people, and run separate scenarios.
Is it possible to perform such task with k6?
How would I create a variable to replace the authentication token cookie so that all the calls don’t use the same token from the browser har test, this is what the code looks like(with some confidential stuff taken out)
Cookies should be mostly automatically managed by k6, though you can also manage t hem manually, if you want to: Cookies
And if you need to pass things like Authorization headers between requests, you can extract data from one HTTP response, save it in a variable, and use it in the next requests. See Response and Intro to API Load Testing: The k6 Guide
Hey @pawel - will this get distributed across k6 cloud? That is, does the __VU id remain unique when distributed or does the full set of users (in this case 1,2) get run on each node?
Now the plan is to offer a bunch of helper functions to get such execution information, instead of messing with the existing or new global constants. For example, have a getLocalVUNumber() function that returns the same value as __VU, but also have getGlobalVUNumber() that returns a globally unique sequential VU ID. This will not be ready in time for k6 v0.30.0, but I’m hopeful we’ll implement it in v0.31.0 or the next few k6 versions. You can follow Improve execution information in scripts · Issue #1320 · grafana/k6 · GitHub for updates.
The example shown pre-supposes that we’ve already fetched bearer tokens and hard coded them into the script, yes?
If my script is set up to start with 125 vus, but be able to scale up to 250 vus, would I need an entry in the setup for all 250? Or is the harness smart enough to say "I see six defined, iterate through the defined six, and then cycle back to one interpreting it as seven through twelve? Wash, rinse repeat until it gets to VU 250…
I may have more but that’s the starting point on need to know.