2

I tried writing simple code in Tests tab of a API request in postman tool to test rate limit of an API. Basically want to verify if n is X-Rate-Limit and if I call same API n+1 no. of times does it throw rate limit exceeded status code in response. Although I want to run these within a timeframe of ms (which X-RateLimit-Reset provides) however I'm not sure if that is achievable via postman. Also, running the below code is not working to verify the rate limit exceeded as the loop count is definitely running 20 times but not decreasing the count/value of rateRemaining in each iteration.

Any ideas or suggestions?

n = 20;
var rateRemaining = postman.getResponseHeader("X-RateLimit-Remaining");

while(n >= 0) { 
    console.log("Loop:" + n + " xRatelimitRemaining:" + rateRemaining);
    postman.setNextRequest("List API to test rate limit");
    counter--;

}
if(n === 0) {
    console.log("Stop loop");
    postman.setNextRequest(null);
    tests["Verify rate limit exceeds"] = pm.response.to.have.status(429);
}
anonymous-explorer
  • 365
  • 1
  • 12
  • 26
  • Have you looked at jmeter by any chance? I think it might be better suited for what you're trying to achieve – so cal cheesehead Aug 09 '19 at 16:20
  • oh ok @so-cal-cheesehead. I can explore. Do you think it would be possible to do via gatling tool as well? Since i started exploring gatling for load testing I was wondering if same tool can be used to test rate limit of an API for a single user to run multiple times within a timeframe to hit the rate. – anonymous-explorer Aug 22 '19 at 20:11
  • Sorry I'm not familiar with Gatling – so cal cheesehead Aug 24 '19 at 13:54

0 Answers0