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

How to run test programatically #222

Closed
parthaaptuz opened this issue Dec 22, 2014 · 8 comments · Fixed by #1266 or #1327
Closed

How to run test programatically #222

parthaaptuz opened this issue Dec 22, 2014 · 8 comments · Fixed by #1266 or #1327
Milestone

Comments

@parthaaptuz
Copy link

I would like to run these load testing through clicking a button, or something else. How to do this ? and also how to grab those result.

@vasiliyb
Copy link

I've built a Jenkins pipeline to do a multi-step process of starting locust instances in AWS, run tests, shut down. Seems like the best approach, as you can add this to your Continuous Integration :)

@hukka
Copy link

hukka commented May 11, 2015

Here's a short script. Hope this helps you. I agree it would have been nice to have this in the documentation, compared to having to read the source.

from argparse import Namespace

from locust import runners

import locustfile


options = Namespace()
options.host = "http://localhost"
options.num_clients = 10
options.hatch_rate = options.num_clients
options.num_requests = options.num_clients * 10

runners.locust_runner = runners.LocalLocustRunner([locustfile.MyUser], options)
runners.locust_runner.start_hatching(wait=True)
runners.locust_runner.greenlet.join()

for name, value in runners.locust_runner.stats.entries.items():
    print(name,
          value.min_response_time,
          value.median_response_time,
          value.max_response_time,
          value.total_rps)

@FutureSharks
Copy link

I wanted to do the same thing but also run load tests from AWS Lambda so I made a small wrapper for locust to make running it programatically easier:
https://github.com/FutureSharks/invokust

@cgoldberg
Copy link
Member

@FutureSharks , nice work! you should consider integrating something similar into the locust codebase... I think a general wrapper would be useful for many (with optional AWS Lambda support added to docs).

@FutureSharks
Copy link

Thanks @cgoldberg. OK I'll have a look and see how it could be put into the locust code base.

@joaonc
Copy link

joaonc commented Dec 11, 2018

Would love to see this feature in Locust natively (although @FutureSharks work seems great in the meantime).

@joaonc
Copy link

joaonc commented Dec 13, 2018

@hukka 's response here uses LocalLocustRunner which requires the list of Locust classes as parameter.

However, the locust file I'm trying to run is not a module that's part of the current path, it's just a file sitting somewhere..

Is it possible to add a similar runner (say LocalLocustFileRunner) that takes in a list of files, rather than a list of classes?
Then that would do the same as locust.main.load_locustfile(...), or something like that..

@cyberw
Copy link
Collaborator

cyberw commented Nov 10, 2019

PR #805 is a proposed fix for this but it is unlikely to be merged atm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment