How can I use multiple VU in k6 to retrieve different IDs from a list API without errors?

36 views Asked by At

I want to stress test my website. My process is as follows:

Login Use the list API to retrieve some IDs Use the edit API to modify the content of these IDs Use the delete API to delete these IDs This process works fine with one VU.

However, when I change it to 3 VUs, the delete API will repeatedly delete IDs that have already been deleted and cause an error. This is not the expected error for my stress test. How can I ensure that each VU gets different IDs when using the list API?

I tried to create an array in the setup, and then put the ID into the array if it was deleted in the default. In this way, I could check if the ID has been deleted. However, it still selects the deleted ID again.

1

There are 1 answers

1
ZFC On

Thanks @Knittl for the answer: I add a if like: if (id % options.vus === __VU - 1)