I have written a REST API and now my requirement is to load test it for 1k calls or something. Problem is the request json has an unique attribute - Cnumber which needs to be changed for every request.
json request:
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "C7" }
how can I make this request for 1K users concurrently with Cnumber changes in every request?
CodePudding user response:
Depending on what you're trying to achieve:
Incrementing number can be generated using __counter() function like:
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__counter(FALSE,)}" }
Random number can be generated using __Random() function
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__Random(1,2147483647,)}" }
Random alphanumeric string can be generated using __RandomString() function like:
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__RandomString(2,abcdefjhijklmnopqrstuvwxyz0123456789,)}" }
Current thread number: __threadNum() function
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__threadNum}" }
GUID-like structure: __UUID() function
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__UUID}" }
More information on JMeter Functions concept: Apache JMeter Functions - An Introduction
CodePudding user response:
You could use a timestamp...
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "C${__time}" }