问题
Is there any way to invoke GRPC python client in locust.
The output is generated when I run the code locust -f 1.py
. But the stats are not working. They are idle.
users are swarming, but the stats are idle for everything
回答1:
When you build your own client you need to report samples to locust yourself (because how would it otherwise know what you had done?)
In current stable locust version you'd do something like:
from locust import events,
events.request_success.fire(request_type="grpc", name=name, response_time=total_time_calculated_by_you, response_length=your_response_length)
https://docs.locust.io/en/stable/testing-other-systems.html
In latest master / 1.0, it would be something like this (if you're calling this from your TaskSet, if you are already in the Locust class, skip the .locust part):
self.locust.environment.events.request_success.fire(request_type="grpc", name=name, response_time=total_time_calculated_by_you, response_length=your_response_length)
https://docs.locust.io/en/latest/testing-other-systems.html
来源:https://stackoverflow.com/questions/61120975/how-to-invoke-a-grpc-python-client-in-locust