Skip to content

Commit

Permalink
Add stats printing validations to a couple of test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberw committed Oct 19, 2021
1 parent c0541c0 commit 9962e82
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions locust/test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ def my_task(self):
stderr = stderr.decode("utf-8")
stdout = stdout.decode("utf-8")
self.assertIn("Starting Locust", stderr)
self.assertRegex(stderr, r".*Shutting down[\S\s]*Aggregated.*", "no stats table printed after shutting down")
self.assertNotRegex(stderr, r".*Aggregated[\S\s]*Shutting down.*", "stats table printed BEFORE shutting down")
self.assertNotIn("command_line_value", stdout)
self.assertIn("web_form_value", stdout)

Expand Down Expand Up @@ -614,6 +616,8 @@ def t(self):
self.assertIn("Ramping to 0 users at a rate of 100.00 per second", output)
self.assertIn('All users spawned: {"UserSubclass": 0} (0 total users)', output)
self.assertIn("Test task is running", output)
# ensure stats printer printed at least one report before shutting down and that there was a final report printed as well
self.assertRegex(output, r".*Aggregated[\S\s]*Shutting down[\S\s]*Aggregated.*")
self.assertIn("Shutting down (exit code 0), bye.", output)
self.assertEqual(0, proc.returncode)

Expand Down

0 comments on commit 9962e82

Please sign in to comment.