How to use multiple unique users

Hi all,

I’m a newby dev, and even newer to testing, and I’ve recently started looking in to k6 as a load testing tool.

I understand that one of the main selling points is the fact that we can use VUs to ramp up load, but what I’d like to try and do is to use multiple users as opposed to having a single user login in and use multiple VUs.

The reason being is that I have, for example, 100 test users in my DB. I’d like to be able to login with each of them, and have them make requests to my API to ensure they can access the things they should be able to.

So:

  • user_id 1 logs in, requests all items available to that user (so items 101, 102, 103 … 199),
  • user_id 2 logs in, requests all items available to that user (so items 201, 202, 203 … 299),
  • etc

Each user will have a batch of requests like login, request list, request details of specific items on list, etc. With groups I can see that I can batch up requests and then check results, but it would be amazing if I could login multiple real users in parallel.

Can i iterate over a list of logins, and then run multiple batches within default()? Can I map real login creds to each specific VU?

Thanks in advance k6 community, and apologies if my question seems under developed or confused. Any help or advice will be much appreciated.

Dave

Hi @Thundersmurf,
You can take a look at this question and this one - this should be sufficient for what you ask and more :smiley: . Good luck and you can always ask additional questions if you need to :slight_smile: .

Amazing, thank you. I spent ages searching various terms, and those two answers look like exactly what I need.

1 Like