0

I am using locust for performance testing of my application. Have to test following scenario. Want to know if its supported in locust.

  1. Locust client sends post request to Application by setting callback url and timer.
  2. On expiry of timer, Application will send back the request on callback url by acting as server.
  3. Locust tool has to handle the request and respond back to server.
  4. Do we have support of handling server initiated messages on locust?

Please let me know if anyone come accross this kind of scenario.

1 Answers1

1

Locust doesnt support that out of the box, but you may be able to set up a new endpoint on the locust web UI that responds to the callbacks (using the pre-release 1.0b1 version you can do it this way: https://docs.locust.io/en/latest/extending-locust.html#adding-web-routes)

Your flask response function would then have to log the callback by calling web_ui.environment.events.request_success.fire(request_type="callback", name="mycallbackthingy", response_time=<time measured by you>, response_length=0)

If you can specify the timestamp for the initial call as a parameter in the callback url you can calculate the response time that way.

Cyberwiz
  • 11,027
  • 3
  • 20
  • 40
  • 1
    Thanks for the suggesion, Let me try the same – bgalgali May 01 '20 at 16:11
  • Hi Cyberwiz, Based on ur suggestion, have tried loading the locust image 1.0b1/b2, but ended up with following error ImportError: cannot import name 'HttpLocust'. Are there any know issue or changes in latest build, same used to work with earlier build 0.14.6. – bgalgali May 03 '20 at 09:42
  • Yes, "Locust" classes are now "User" classes (so it is now HttpUser). See https://docs.locust.io/en/latest/changelog.html for more changes. – Cyberwiz May 03 '20 at 20:59
  • Thanks for pointing to doc. In earlier builds i was using runners.locust_runner.client_id to access the client Id. Looks like in latest build same was been removed. Is there any other way of accessing the client id? – bgalgali May 04 '20 at 11:54
  • Its a little tricker now, but you can use the approach I did in locust-plugins: https://github.com/SvenskaSpel/locust-plugins/blob/master/examples/timescale_listener_ex.py. Then you can access the runner from env.runner – Cyberwiz May 04 '20 at 12:30
  • I am able to extract info from environment variable. How do i make this server to behave as HTTP2, Do we support this in locust? – bgalgali May 05 '20 at 09:29
  • Hi Cyberwiz, Based on your information provided, i could able to register Event Handler, which runs on master node & abe to handle the requests. But in case of distributed architecture where we are running single master & multiple slaves, & each slaves will contribute to callbacks, Can this handler able to handle heavy loads efficiently?. – bgalgali May 07 '20 at 09:22
  • Instead of having this handler located at master Node, Can this be pushed to slaves? – bgalgali May 07 '20 at 09:36