Skip to content

Commit

Permalink
Add test case that exhibits the incorrect logging: All users spawned:…
Browse files Browse the repository at this point in the history
… {"UserSubclass": 2} (2 total users)

Maybe we are printing the numbers from the last step? Only happens with at least 5 workers (!?)
  • Loading branch information
cyberw committed Dec 17, 2021
1 parent 73699f1 commit 4f7b37a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions locust/test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,3 +690,48 @@ def test_expect_workers(self):
self.assertIn("Waiting for workers to be ready, 0 of 2 connected", stderr)
self.assertIn("Gave up waiting for workers to connect", stderr)
self.assertEqual(1, proc.returncode)

def test_distributed(self):
with mock_locustfile() as mocked:
proc = subprocess.Popen(
[
"locust",
"-f",
mocked.file_path,
"--headless",
"--master",
"--expect-workers",
"5",
"-t",
"3",
"-u",
"3",
"-r",
"1",
"--exit-code-on-error",
"0",
],
stdout=PIPE,
stderr=PIPE,
)
gevent.sleep(0.2)
for _ in range(5):
proc_worker = subprocess.Popen(
[
"locust",
"-f",
mocked.file_path,
"--worker",
],
stdout=PIPE,
stderr=PIPE,
)

_, stderr = proc.communicate()
_, worker_stderr = proc_worker.communicate()
stderr = stderr.decode("utf-8")
worker_stderr = worker_stderr.decode("utf-8")
self.assertIn("Waiting for workers to be ready", stderr)
self.assertIn('All users spawned: {"UserSubclass": 3} (3 total users)', stderr)
self.assertIn("Got quit message from master", worker_stderr)
self.assertEqual(0, proc.returncode)

0 comments on commit 4f7b37a

Please sign in to comment.