Scripting example on how to generate UUIDs in your load test.
Note that if you don't need v1 UUIDs, consider using the uuidv4 function from the k6 JS lib repository.
Generate v1 and v4 UUIDs
Universally unique identifiers are handy in many scenarios, as k6 doesn't have built-in support for UUIDs, we'll have to resort to using a Node.js library called uuid and Browserify (to make it work in k6).
For this to work, we first need to go through a few required steps:
Make sure you have the necessary prerequisites installed: Node.js and Browserify
Install the uuid library:
Run it through browserify:
Move the uuid.js file to the same folder as your script file and you'll be able to import it into your test script:
Here's an example generating a v1 and v4 UUID:
generate-uuids.js