Skip to content

Add test_stopping event#2033

Merged
cyberw merged 6 commits into
locustio:masterfrom
marcinh:feature/2031_test_stopping_feature
Mar 1, 2022
Merged

Add test_stopping event#2033
cyberw merged 6 commits into
locustio:masterfrom
marcinh:feature/2031_test_stopping_feature

Conversation

@marcinh
Copy link
Copy Markdown
Contributor

@marcinh marcinh commented Feb 25, 2022

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

Comment thread locust/test/test_runners.py Outdated
master = self.get_runner(user_classes=[TestUser])

run_count = [0]
run_count = [0, 0]
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

marcinh commented Feb 28, 2022

Will do



@events.test_stop.add_listener
@events.test_stopping.add_listener
Copy link
Copy Markdown
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
Copy Markdown
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