locustio / locust

Write scalable load tests in plain Python 🚗💨
https://locust.cloud
MIT License
25.1k stars 3k forks source link

No Tasks executed when mirgrating to config #2987

Closed vkuehn closed 5 days ago

vkuehn commented 1 week ago

Prerequisites

Description

locust --headless --users 10 --spawn-rate 1 -H http://localhost:3000 locustfile.py looks like that

from locust import HttpUser, task

class HelloWorldUser(HttpUser): @task def hello_world(self): self.client.get("/health") but putting the same code in a local.py and this to a local.conf

locustfile = local.py headless = true master = true expect-workers = 3 host = "http://localhost:3000" users = 3 spawn-rate = 1 run-time = 1m

that command runs but does not bring back any results

locust --config local.conf

I have asked at stackeoverflow and read the documentation. No answer yet found so I guess it's a bug

Command line

locust --config local.conf

Locustfile contents

local.py

from locust import HttpUser, task

class HelloWorldUser(HttpUser):
    @task
    def hello_world(self):
        self.client.get("/health")

local.conf
locustfile = local.py
headless = true
master = true
expect-workers = 3
host = "http://localhost:3000"
users = 3
spawn-rate = 1
run-time = 1m

locust --config local.conf

Python version

3.11.10

Locust version

2.32.1

Operating system

Mac OS 15.1 Build 24B83

andrewbaldwin44 commented 5 days ago

Hey @vkuehn, in your configuration file you have two arguments stated; master = true - which sets locust to run in distributed mode, and expect-workers = 3 - which is used in headless mode to wait for workers before starting the test (see expect-workers).

So in order for you test to run, you will either need to start three workers, or you can remove these flags and run in standalone. If you are still having trouble or have any questions, feel free to reach out to us on slack!

vkuehn commented 4 days ago

@andrewbaldwin44 thanks for that. It actually did start but was than not executing any task and complain.

locust.user.task: No tasks defined on LocalUser. Use the @task decorator or set the 'tasks' attribute of the User (or mark it as abstract = True if you only intend to subclass it)

can you kindly reopen the issue and consider changing the docs for less effort when showing the local.conf ?

vkuehn commented 4 days ago

ok this minimal file did work. As I have used tags in the config file which did not exist in the local.py

locustfile = load_basics.py headless = true host = "http://localhost:50505" users = 1 spawn-rate = 1 run-time = 1m

you can leave it closed @andrewbaldwin44 thanks

andrewbaldwin44 commented 4 days ago

Awesome! PRs are welcome if you think something is unclear in the docs!