Can I do an increment on K6?

Hello, I want to test my API, in my API there is an ID to place an order, which ID must be different every time an order comes in. because if there is the same ID, it will fail if a stress test is carried out

can I do an Increment in K6?

for example, the ID is the following ID/09/09/01

how to make it able to have a different ID on each VUs?

Thanks

Hi @rifkiaz

Welcome to the forum :tada:

While k6 doesn’t have this feature in its core, we have an xk6 extension that does what it sounds like you’re trying to achieve: xk6-counter.

If you’re not familiar with xk6, nor extensions, it is a tool that allows you to compile k6 binaries with specific third-party extensions (such as the one linked before).

Please let me know if that’s helpful and if you need any more support with this :bowing_man:

I’ve found I’ve need the same functionality but across multiple load generators, so have used the K6 Redis extension and using the redis incr funciton.

Also has the benefit of maintaining that value between test runs. But if you need it to reset you can do so in the setup script.

Helps that I use redis for lots of other things as well so already have a server stood up.

1 Like

I maked some extension to use counter for increment, maybe some of counters will good for you.
But i didn’t use it in prod, it’s my pet project)))

1 Like