nicholas
nicholas

Reputation: 2772

Locust Not Running

I had coded some simple locust load testing code in python. Previously, it running without any errors but after some time i run the code, the http request is not get executed.

class WebsiteUser(HttpUser):
wait_time = between(1, 5)

#HTTPConnection.debuglevel = 1
#logging.basicConfig()
#logging.getLogger().setLevel(logging.DEBUG)
#requests_log = logging.getLogger("requests.packages.urllib3")
#requests_log.setLevel(logging.DEBUG)
#requests_log.propagate = True

# All instances of this class will be limited to 10 concurrent connections at most.
#pool_manager = PoolManager(maxsize=900000, block=True)

####################################################################################################################
@events.test_start.add_listener
def on_test_start(environment, **kwargs):
    if not isinstance(environment.runner, MasterRunner):
        print("Beginning test setup")
    else:
        print("Started test from Master node")

@events.test_stop.add_listener
def on_test_stop(environment, **kwargs):
    print(environment.runner.stats.total.fail_ratio)
    # Send test report

def on_start(self):
    response = self.client.post(
        "https://stg-accounts.mediaprimaplus.com.my/authorize?client_id=632354224783531&redirect_uri=https%3A%2F%2Fstaging-ticket.revid.my%2Fcallback&response_type=code&state=%2F",
        {"username": "", "password": ""})
    print("Response status code:", response.status_code)
    print("Response text:", response.text)
    print(self.client.cookies)

@task
def homepage(self):
    self.client.get("/")

@task
def getEvent(self):
    self.client.get("event/tik-tok-award-2024-realisasikan-impianmu")

@task
def checkout(self):
    self.client.get("event/checkout")

@task
def checkAccount(self):
    self.client.get("account?tab=account")

@task
def orderHistory(self):
    self.client.get("account?tab=order")

I running on Macbook. There is no error in the Web UI dashboard, it just doesn't get executed the USERS.

Is it relate to firewall? Please help. Thanks in advance.

I get this in the Web UI log.

[2025-02-04 15:28:02,602] RMG-NICHOLAS/CRITICAL/locust.runners: Unhandled exception in greenlet: <Greenlet at 0x1039ea2a0: > Traceback (most recent call last): File "src/gevent/greenlet.py", line 908, in gevent._gevent_cgreenlet.Greenlet.run File "/Users/nicholas/PycharmProjects/RevIDETicketing/.venv/lib/python3.12/site-packages/locust/runners.py", line 555, in lambda: self._start(user_count, spawn_rate, wait=wait, user_classes=user_classes) ^^^^^^^^^^^^^^^^^ File "/Users/nicholas/PycharmProjects/RevIDETicketing/.venv/lib/python3.12/site-packages/locust/runners.py", line 526, in _start self.spawn_users(user_classes_spawn_count, wait) ^^^^^^^^^^^^^^^^^ File "/Users/nicholas/PycharmProjects/RevIDETicketing/.venv/lib/python3.12/site-packages/locust/runners.py", line 240, in spawn_users new_users += spawn(user_class, spawn_count) ^^^^^^^^^^^^^^^^^ File "/Users/nicholas/PycharmProjects/RevIDETicketing/.venv/lib/python3.12/site-packages/locust/runners.py", line 226, in spawn new_user = self.user_classes_by_nameuser_class ^^^^^^^^^^^^^^^^^ File "/Users/nicholas/PycharmProjects/RevIDETicketing/.venv/lib/python3.12/site-packages/locust/user/users.py", line 261, in init raise LocustError( ^^^^^^^^^^^^^^^^^ locust.exception.LocustError: You must specify the base host. Either in the host attribute in the User class, or on the command line using the --host option.

Upvotes: 0

Views: 36

Answers (1)

nicholas
nicholas

Reputation: 2772

Supply --host="" parameter at cli.

Upvotes: 1

Related Questions