Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support dynamic request body similar to --rand-regex-url #586

Open
fedulovivan opened this issue Oct 4, 2024 · 1 comment

Comments

@fedulovivan
Copy link

I'm trying to create load for the enpoint which has a unique name constraint for the created entity.
So the imaginary ⚠️ syntax could be like:

oha --method PUT -H 'Content-Type: application/json' -d '{"name":"name-{{uuid}}"}' http://localhost/entity
# or
oha --method PUT -H 'Content-Type: application/json' -d '{"name":"name-[a-z][a-z][0-9]"}' http://localhost/entity

Following snippet obviously do not work, as well:

oha --method PUT -H 'Content-Type: application/json' -d "{\"name\":\"name-`uuidgen`\"}" http://localhost/entity
@fedulovivan
Copy link
Author

I have found a workaround thought. Which utilises --rand-regex-url feature.

First step is adding special handling in PUT request handler for the load-tested application, which is able to receive entity name via the url, in addition to the request body handling (normal behavior). See
details here my case here.

Second step, is using url with random entity name for the put request:
oha --method PUT -H 'Content-Type: application/json' -n 10000 -c 10 -D ./assets/load/create-rule.json --rand-regex-url http://localhost/rules/name-[a-z0-9]{16}
Complete example is here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant