rakyll / hey

HTTP load generator, ApacheBench (ab) replacement
Apache License 2.0
17.65k stars 1.17k forks source link

Generate random values in header and body of request #200

Open soldatov-s opened 4 years ago

soldatov-s commented 4 years ago

For testing some POST/PUT-endpoints, it is necessary to use unique values in the request body. For example: POST-request {"user_email": "test@test.com", "user_password": "123456qwerty"} to http://server.com/api/user for creating the user. Now we cannot apply hey for this case, because user_email in each request must be unique. Adding templates can help us execute requests. During handling of request, the markers in the template will be replaced with random values ​​that differ for different markers. For our example, we need to use the following template: {"user_email": "{{.Email}}", "user_password": "{{.String}}"} A random email address will be generated on the Email marker, e.g. gyf4ws3e2f@og9vu.com. In request may be multiple markers, e.g. {"primary_email": "{{.Email_1}}", "secondary_email": "{{.Email_2}}"}

In other cases, you may need random integers, strings, float, date/time/datetime. In header necessary to generate the RequestID.

twpayne commented 4 years ago

149 provides a more generic API for this.