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

[MB-10361] Use custom parameters to configure User Class Weights #83

Closed
wants to merge 6 commits into from

Conversation

ahobson
Copy link
Contributor

@ahobson ahobson commented Nov 9, 2021

Description

This is an example of how we could use custom weights to allow us to control which tests are run. Setting a user weight to 0 would remove them.

I tested this locally with locust 2.5.0 and it worked for me. I could run a test and then stop it and run with another set of user weights and it worked.

class_options = request.form.getlist("user_classes_option")
new_classes = [original_user_classes[n] for n in class_options]
setattr(environment, "user_classes", new_classes)
environment._remove_user_classes_with_weight_zero()
Copy link
Contributor

@duncan-truss duncan-truss Nov 10, 2021

Choose a reason for hiding this comment

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

This errors out for me, because it's an internal method I'm guessing? Since you're setting the user_classes above to what was selected, we wouldn't need to set the unselected classes to a weight of zero I'm assuming.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this might be in a different version of locust. It doesn't error out for me, so hopefully the pipenv changes will make it work for you, too

@duncan-truss
Copy link
Contributor

duncan-truss commented Nov 10, 2021

One thing I noticed is the stop test button has vanished for me after changing the user classes and status shows stopped after selecting new user classes and them starting up properly.

Screen Shot 2021-11-10 at 3 08 20 PM

@duncan-truss
Copy link
Contributor

I think there is a way to add custom arguments to appear on the initial screen but I have a feeling that is in version 2 and we are still on Locust version 1. Have there been any discussions on upgrading by chance? On first glance I don't see major breaking changes (famous last words).

locustio/locust#1881
https://github.com/locustio/locust/blob/master/examples/add_command_line_argument.py
https://github.com/locustio/locust/releases/tag/2.0.0

@duncan-truss duncan-truss changed the title Add example of custom route to set users [MB-10361] Add example of custom route to set users Nov 16, 2021
@ahobson ahobson changed the title [MB-10361] Add example of custom route to set users [MB-10361] Use custom parameters to configure User Class Weights Nov 17, 2021
@ahobson
Copy link
Contributor Author

ahobson commented Nov 17, 2021

I think there is a way to add custom arguments to appear on the initial screen but I have a feeling that is in version 2 and we are still on Locust version 1. Have there been any discussions on upgrading by chance? On first glance I don't see major breaking changes (famous last words).

locustio/locust#1881 https://github.com/locustio/locust/blob/master/examples/add_command_line_argument.py https://github.com/locustio/locust/releases/tag/2.0.0

THAT IS IT! THANK YOU

@ahobson
Copy link
Contributor Author

ahobson commented Nov 17, 2021

One thing I noticed is the stop test button has vanished for me after changing the user classes and status shows stopped after selecting new user classes and them starting up properly.

Screen Shot 2021-11-10 at 3 08 20 PM

I think this new version fixes that problem. At least, it does for me

@felipe-lee
Copy link
Contributor

@ahobson, we've pulled this story into our current sprint, but I've just done a diff with master and I think at this point all the relevant changes might have been merged in other branches. Am I correct in that? Or am I missing something?

@ahobson
Copy link
Contributor Author

ahobson commented Dec 2, 2021

@ahobson, we've pulled this story into our current sprint, but I've just done a diff with master and I think at this point all the relevant changes might have been merged in other branches. Am I correct in that? Or am I missing something?

@felipe-lee You are right! I forgot we had this as a separate story and I accidentally sneaked it into another PR. Sorry about that

@felipe-lee
Copy link
Contributor

Awesome, no problem. I'll close this and the ticket out then!

@felipe-lee felipe-lee closed this Dec 2, 2021
@felipe-lee felipe-lee deleted the adh-pages branch December 2, 2021 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants