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

Add test_stopping event #2033

Merged
merged 6 commits into from
Mar 1, 2022

Conversation

marcinh
Copy link
Contributor

@marcinh marcinh commented Feb 25, 2022

Adding test_stopping event - fired before stopping users.
It resolves #2031

@@ -2224,11 +2230,15 @@ def my_task(self):
with mock.patch("locust.rpc.rpc.Server", mocked_rpc()) as server:
master = self.get_runner(user_classes=[TestUser])

run_count = [0]
run_count = [0, 0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Using a list here is more or less a hack for modifying values outside the function. I think this can be done in a more obvious way. even using a (properly named) global is preferable.

@cyberw
Copy link
Collaborator

cyberw commented Feb 25, 2022

Looks good apart from my comment about the test. Can you add this event to this example? https://github.com/locustio/locust/blob/master/examples/test_data_management.py

@marcinh
Copy link
Contributor Author

marcinh commented Feb 28, 2022

Will do

@@ -60,11 +60,16 @@ def _(environment, **_kwargs):
).json()["data"]


@events.test_stop.add_listener
@events.test_stopping.add_listener
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you update the comment at the start of the file too!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

like this?

# 6. Test run stopping
# 7. User stop
# 8. Test run stop
# 9. (not shown in this example) Locust quit

@cyberw cyberw merged commit 90c46ee into locustio:master Mar 1, 2022
@marcinh marcinh deleted the feature/2031_test_stopping_feature branch March 2, 2022 07:41
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.

Introduce test_stopping event
2 participants