Skip to content

Commit 7885b41

Browse files
committed
Optimize run time of some unit tests.
1 parent bfe4de5 commit 7885b41

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

locust/test/test_main.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -613,14 +613,14 @@ def test_autostart_wo_run_time(self):
613613
response = requests.get(f"http://localhost:{port}/")
614614
except Exception:
615615
pass
616-
self.assertEqual(200, response.status_code)
617616
proc.send_signal(signal.SIGTERM)
618617
stdout, stderr = proc.communicate()
619618
self.assertIn("Starting Locust", stderr)
620619
self.assertIn("No run time limit set, use CTRL+C to interrupt", stderr)
621620
self.assertIn("Shutting down ", stderr)
622621
self.assertNotIn("Traceback", stderr)
623622
# check response afterwards, because it really isn't as informative as stderr
623+
self.assertEqual(200, response.status_code)
624624
d = pq(response.content.decode("utf-8"))
625625

626626
self.assertEqual(200, response.status_code)
@@ -885,7 +885,7 @@ def t(self):
885885
mocked.file_path,
886886
"--headless",
887887
"--run-time",
888-
"7s",
888+
"6s",
889889
"-u",
890890
"0",
891891
"--loglevel",
@@ -999,7 +999,7 @@ def test_spawing_with_fixed_multiple_locustfiles(self):
999999
f"{mocked1.file_path},{mocked2.file_path}",
10001000
"--headless",
10011001
"--run-time",
1002-
"5s",
1002+
"2s",
10031003
"-u",
10041004
"10",
10051005
"-r",
@@ -1053,7 +1053,7 @@ def t(self):
10531053
mocked.file_path,
10541054
"--headless",
10551055
"--run-time",
1056-
"1s",
1056+
"0.5",
10571057
"-u",
10581058
"3",
10591059
],
@@ -1674,8 +1674,10 @@ def t(self):
16741674
"1",
16751675
"-u",
16761676
"3",
1677+
"-r",
1678+
"99",
16771679
"-t",
1678-
"5s",
1680+
"1s",
16791681
],
16801682
stderr=STDOUT,
16811683
stdout=PIPE,
@@ -1737,8 +1739,10 @@ def t(self):
17371739
"1",
17381740
"-u",
17391741
"3",
1742+
"-r",
1743+
"99",
17401744
"-t",
1741-
"5s",
1745+
"1s",
17421746
],
17431747
stderr=STDOUT,
17441748
stdout=PIPE,
@@ -1759,7 +1763,7 @@ def t(self):
17591763
proc_worker.communicate()
17601764

17611765
self.assertIn(
1762-
'Spawning is complete and report waittime is expired, but not all reports received from workers: {"User1": 2} (2 total users)',
1766+
"Spawning is complete and report waittime is expired, but not all reports received from workers:",
17631767
stdout,
17641768
)
17651769
self.assertIn("Shutting down (exit code 0)", stdout)
@@ -1808,7 +1812,7 @@ def t(self):
18081812
stdout=PIPE,
18091813
text=True,
18101814
)
1811-
gevent.sleep(2)
1815+
gevent.sleep(1)
18121816
proc_worker2 = subprocess.Popen(
18131817
[
18141818
"locust",
@@ -1858,7 +1862,7 @@ def t(self):
18581862
stdout=PIPE,
18591863
text=True,
18601864
)
1861-
gevent.sleep(2)
1865+
gevent.sleep(1)
18621866
proc = subprocess.Popen(
18631867
[
18641868
"locust",
@@ -1916,7 +1920,6 @@ def t(self):
19161920
stdout=PIPE,
19171921
text=True,
19181922
)
1919-
gevent.sleep(2)
19201923
proc_worker = subprocess.Popen(
19211924
[
19221925
"locust",
@@ -1998,6 +2001,7 @@ def hello_world(self):
19982001
self.assertEqual(dict, type(result["num_reqs_per_sec"]))
19992002
self.assertEqual(dict, type(result["num_fail_per_sec"]))
20002003

2004+
@unittest.skipIf(True, reason="This test is too slow for the value it provides")
20012005
def test_worker_indexes(self):
20022006
content = """
20032007
from locust import HttpUser, task, between

0 commit comments

Comments
 (0)