-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Support for tests that use multiple hosts #150
Comments
You can actually make requests to different hosts, simply by specifying a full URL, however the hostname will not appear in the statistics entry, so requests to different hosts, but with the same path, will appear as a single stats entry: self.client.get("/some/path")
self.client.get("http://other.host/some/path") If you want them to be separate stats entries, you could override the entry name using the name parameter: self.client.get("http://other.host/some/path", name="http://other.host/some/path") If you could live with that, you could then specify a second host using an environment variable. Perhaps something like this: import os
from locust import HttpLocust
from locust.clients import HttpSession
class MultipleHostsLocust(HttpLocust):
abstract = True
def __init__(self, *args, **kwargs):
super(MultipleHostsLocust, self).__init__(*args, **kwargs)
self.api_client = HttpSession(base_url=os.environ["API_HOST"]) |
Hi Jonatan, Thanks! I was able to get this working this way, and it makes sense. Locust looks like a really great tool for running these sorts of tests, and looking forward to getting it used as part of our production system! best, |
Glad to hear that :)! You could also expand on my suggestion above, to make the api_client automatically set the |
This also solved my problem. It would however be quite nice if I could leave "host" as blank totally. For cases where I write tests that always pass a full URL. |
thank you guys, super useful |
it's working on me, thanks |
Our system runs two different hostnames (one for web, one for api requests), and it's not clear to me how to write a locust that would handle this. The --host option being passed to locust only allows passing one hostname (and assumes that the host resolves to the IP in question -- in a testing setup, the Host: header in the request to the web server might not resolve, as in testing during a build).
Suggestions?
Thanks,
Jeff
The text was updated successfully, but these errors were encountered: