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

No Tasks executed when mirgrating to config #2987

Closed
2 tasks done
vkuehn opened this issue Nov 15, 2024 · 4 comments
Closed
2 tasks done

No Tasks executed when mirgrating to config #2987

vkuehn opened this issue Nov 15, 2024 · 4 comments

Comments

@vkuehn
Copy link
Contributor

vkuehn commented Nov 15, 2024

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

@vkuehn vkuehn added the bug label Nov 15, 2024
@vkuehn vkuehn changed the title No Tasks executed when mirgration to config No Tasks executed when mirgrating to config Nov 15, 2024
@andrewbaldwin44
Copy link
Collaborator

andrewbaldwin44 commented Nov 16, 2024

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
Copy link
Contributor Author

vkuehn commented Nov 18, 2024

@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
Copy link
Contributor Author

vkuehn commented Nov 18, 2024

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
Copy link
Collaborator

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

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

No branches or pull requests

3 participants