From 5186af4db3c010b6cd2d2f2fdbfc44b23adecb9c Mon Sep 17 00:00:00 2001 From: Lars Holmberg Date: Mon, 1 Nov 2021 15:19:50 +0100 Subject: [PATCH] add test for --expect-workers and --expect-workers-max-wait (expecting this to fail) --- locust/test/test_main.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/locust/test/test_main.py b/locust/test/test_main.py index cbc6410969..3bdab6099a 100644 --- a/locust/test/test_main.py +++ b/locust/test/test_main.py @@ -667,3 +667,26 @@ def test_html_report_option(self): self.assertIn("charts-container", html_report_content) self.assertNotIn("Download the Report", html_report_content, "Download report link found in HTML content") + + def test_expect_workers(self): + with mock_locustfile() as mocked: + proc = subprocess.Popen( + [ + "locust", + "-f", + mocked.file_path, + "--headless", + "--master", + "--expect-workers", + "2", + "--expect-workers-max-wait", + "1", + ], + stdout=PIPE, + stderr=PIPE, + ) + _, stderr = proc.communicate() + stderr = stderr.decode("utf-8") + 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)