hatoo / oha

Ohayou(おはよう), HTTP load generator, inspired by rakyll/hey with tui animation.
MIT License
5.62k stars 138 forks source link

(Question) how to pass dinamic specific values? #506

Closed fenix-hub closed 4 months ago

fenix-hub commented 4 months ago

Hi,

I would like to stress test an endpoint which consists of an HTTP DELETE request. The path parameter is structured like so:

DELETE /entity/{id}

where {id} is a UUIDv4 generated by my database. Since I'd like to execute multiple requests pointing to existing entities, I'd like to give a list of possible ids to oha in order to dinamically chose one from the sequence of given ids and execute the request, replacing the path parameter with the one from the sequence.

Even giving a file like this one:

# ids.txt

abcde
fedage
adaedae
dawaijwd

would be enough

hatoo commented 4 months ago

You can use --rand-regex-url option. Currently, it's the only feature for dynamic requests. It's not good for a large amount of list, but enough for a small one.

oha --rand-regex-url "http://localhost:3000/(abcde|fedage|adaedae|dawaijwd)" -m DELETE
fenix-hub commented 4 months ago

You can use --rand-regex-url option. Currently, it's the only feature for dynamic requests. It's not good for a large amount of list, but enough for a small one.

oha --rand-regex-url "http://localhost:3000/(abcde|fedage|adaedae|dawaijwd)" -m DELETE

Thank you @hatoo , this is more than enough! Do you know any cli utility that could help creating that regex on the fly? Like passing the list from the file to an intermediate pipeline, that replaces the list inside the regex string.

hatoo commented 4 months ago

Sorry, I don't know a cli to do such a thing. If I were you, I would like to use some shell friendly script runtime such as bun shell.

fenix-hub commented 4 months ago

Thank you very much for your help