Hi, I want to do a test to my API, it’s a geoip service, what I’m trying to do is generating random numbers, from 1 to 254 (four times) and concat it to get a IP format x.x.x.x, and this should be generated in each interaction.
This is my code actually:
import http from 'k6/http';
import { sleep } from 'k6';
export let options = {
vus: 100,
duration: '420s',
};
export default function () {
http.get('https://api.domain.com/X.X.X.X');
sleep(1);
}
I would appreciate someone to enlighten me a little where to go.
Sure, you can use the JavaScript function Math.random() to generate as many random numbers as you want.
We also have a small helper function called randomIntBetween() as a part of our utils utility library on jslib.k6.io, which makes generation of random integer numbers a bit easier.