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

Locustfile distribution from master to worker #2583

Merged
merged 19 commits into from
Feb 8, 2024

Conversation

cyberw
Copy link
Collaborator

@cyberw cyberw commented Feb 5, 2024

Make workers get locustfile directly from master when locustfile argument is set to -

@cyberw cyberw changed the title Locustfile distribution Locustfile distribution from master to worker Feb 6, 2024
@cyberw cyberw marked this pull request as draft February 6, 2024 07:38
Copy link
Collaborator

@DennisKrone DennisKrone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm kinda surprised that it works!


options, _ = parser.parse_known_args(args=args)

if options.locustfile == "-":
# having this in argument_parser module is a bit weird, but it needs to happen early on
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe i would have put this in a separate function just to prevent some bloat/make it more "digestible"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better now?

elif msg.type == "locustfile":
logging.debug("Worker requested locust file")
assert self.environment.parsed_options
filename = (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this just in case the user didn't put .py at the end? Feels like this maybe should be done in the argument parser if possible

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value for locust file is "locustfile" (but gets expanded to "locustfile.py" implictly) which is why I support this. I could change it to just "add .py if there is no .py at the end" which would support if someone says "locust -f module_name_without_py_at_the_end". Specifying a bare module name and then having the file transfered anyway, might be nice, but it is kinda weird, and exception logged later on (line 1048) might become confusing if locust just adds .py automatically. What do you think?

locust/test/test_main.py Outdated Show resolved Hide resolved
@cyberw cyberw marked this pull request as ready for review February 6, 2024 11:39
@DennisKrone DennisKrone merged commit bf02feb into master Feb 8, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants