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

Error when setting multiple host values #1957

Closed
maksymivash opened this issue Dec 9, 2021 · 3 comments
Closed

Error when setting multiple host values #1957

maksymivash opened this issue Dec 9, 2021 · 3 comments
Labels

Comments

@maksymivash
Copy link

maksymivash commented Dec 9, 2021

Describe the bug

We need to send load on multiple hosts simultaneously, unfortunately locust throws an exception with versions 2.2.0, 2.4.0, 2.5.0.
Everything was working as expected with v2.1.0

Expected behavior

Locust should send requests to both hosts.

Actual behavior

Exception thrown
Trace:

master_1  | [2021-12-09 19:29:05,641] faae8a51425b/INFO/locust.runners: Ramping to 4 users at a rate of 4.00 per second
master_1  | Traceback (most recent call last):
master_1  |   File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
master_1  |   File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 490, in <lambda>
master_1  |     lambda: super(LocalRunner, self).start(user_count, spawn_rate, wait=wait)
master_1  |   File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 346, in start
master_1  |     self.spawn_users(user_classes_spawn_count, wait)
master_1  |   File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 221, in spawn_users
master_1  |     new_users += spawn(user_class, spawn_count)
master_1  |   File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 210, in spawn
master_1  |     new_user = self.user_classes_by_name[user_class](self.environment)
master_1  |   File "/usr/local/lib/python3.8/site-packages/locust/contrib/fasthttp.py", line 311, in __init__
master_1  |     raise LocustError("Invalid host (`%s`), must be a valid base URL. E.g. http://example.com" % self.host)
master_1  | locust.exception.LocustError: Invalid host (``), must be a valid base URL. E.g. http://example.com
master_1  | 2021-12-09T19:29:05Z <Greenlet at 0x7faaf9ddcd00: <lambda>> failed with LocustError
master_1  |
master_1  | [2021-12-09 19:29:05,643] faae8a51425b/CRITICAL/locust.runners: Unhandled exception in greenlet: <Greenlet at 0x7faaf9ddcd00: <lambda>>
master_1  | Traceback (most recent call last):
master_1  |   File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
master_1  |   File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 490, in <lambda>
master_1  |     lambda: super(LocalRunner, self).start(user_count, spawn_rate, wait=wait)
master_1  |   File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 346, in start
master_1  |     self.spawn_users(user_classes_spawn_count, wait)
master_1  |   File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 221, in spawn_users
master_1  |     new_users += spawn(user_class, spawn_count)
master_1  |   File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 210, in spawn
master_1  |     new_user = self.user_classes_by_name[user_class](self.environment)
master_1  |   File "/usr/local/lib/python3.8/site-packages/locust/contrib/fasthttp.py", line 311, in __init__
master_1  |     raise LocustError("Invalid host (`%s`), must be a valid base URL. E.g. http://example.com" % self.host)
master_1  | locust.exception.LocustError: Invalid host (``), must be a valid base URL. E.g. http://example.com

Steps to reproduce

Locustfile:

from locust import task

from locust.contrib.fasthttp import FastHttpUser


class HealthzOnlyAPIdev(FastHttpUser):
    host = "https://api.dev.example.com"

    @task(1)
    def healthz(self):
        path = "/healthz"
        self.client.get(
            path=path,
            name=f"{self.client.base_url}{path}",
        )


class HealthzOnlyAPIstagef(FastHttpUser):
    host = "https://api.stagef.example.com"

    @task(1)
    def healthz(self):
        path = "/healthz"
        self.client.get(
            path=path,
            name=f"{self.client.base_url}{path}",
        )

Environment

  • OS: Docker/Mac
  • Python version: 3.9
  • Locust version: 2.5.0
  • Locust command line that you ran: locust -f healthz.py -u 4 -r 4
  • Locust file contents (anonymized if necessary):
@cyberw
Copy link
Collaborator

cyberw commented Dec 9, 2021

Hi! Is this fixed by 2.5.1 / #1956 ?

@maksymivash
Copy link
Author

@cyberw Hey, thanks for so quick reply!
Thanks a lot for the update and the fix :)

@cyberw
Copy link
Collaborator

cyberw commented Dec 9, 2021

Funny how someone submitted a fix only 6 hours before you filed the bug :P

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

2 participants