Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locust while running as library with grpc client not outputting stats #1969

Closed
saurabhsharma721 opened this issue Jan 12, 2022 · 6 comments
Closed
Labels

Comments

@saurabhsharma721
Copy link

Describe the bug

Grpc client not creating stats while running in library mode

Expected behavior

Stats should be created and available both in csv files and in api.

Actual behavior

The Csv files generated and logs created will have zero stats output

locust test have completed running

Test run completed.
requests after run : 0
Failures after run : 0

Steps to reproduce

The code is available here in github repo

https://github.com/saurabhsharma721/grpc_locust_stats_repro_prj

Environment

I see we have similar question on SO but want to check where to place request events inside the test. A code snippet will help

@cyberw
Copy link
Collaborator

cyberw commented Jan 12, 2022

Interesting. I dont have time to look at it but hopefully someone will. Or maybe dig into the code base yourself.

@saurabhsharma721
Copy link
Author

I am trying to see diff between non ui and ui code and so far nothing

@cyberw
Copy link
Collaborator

cyberw commented Jan 15, 2022

You should also update locust, just in case that matters.

@BonelessPi
Copy link
Contributor

I had an almost identical issue when running Locust as a library, although I was using SFTP clients instead of grpc. I resolved my issue by using the .events attribute of the Environment object rather than the locust.events module. I do not know if this will work for you, but it may be worth a try.

In your case, I would suggest modifying your Locustfile as so:
Line 26:
def init(self, environment, stub):
self.env = environment
...
Line 50:
self.env.events.request.fire(**request_meta)
Line 69:
self.client = GrpcClient(environment, stub)

I hope this works for you!

@saurabhsharma721
Copy link
Author

The above solution worked for me. Thanks @BonelessPi

@cyberw
Copy link
Collaborator

cyberw commented Jan 25, 2022

Huh. Seems like a bug in the example GrpcClient. Anyone up for making a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants