locust 2.29.2.dev32__py3-none-any.whl → 2.29.2.dev42__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- locust/_version.py +6 -2
- locust/contrib/fasthttp.py +1 -1
- locust/dispatch.py +7 -6
- locust/stats.py +4 -17
- {locust-2.29.2.dev32.dist-info → locust-2.29.2.dev42.dist-info}/METADATA +31 -26
- locust-2.29.2.dev42.dist-info/RECORD +49 -0
- locust-2.29.2.dev42.dist-info/WHEEL +4 -0
- locust-2.29.2.dev42.dist-info/entry_points.txt +3 -0
- locust/test/__init__.py +0 -15
- locust/test/fake_module1_for_env_test.py +0 -7
- locust/test/fake_module2_for_env_test.py +0 -7
- locust/test/mock_locustfile.py +0 -56
- locust/test/mock_logging.py +0 -28
- locust/test/test_debugging.py +0 -39
- locust/test/test_dispatch.py +0 -4170
- locust/test/test_env.py +0 -283
- locust/test/test_fasthttp.py +0 -785
- locust/test/test_http.py +0 -325
- locust/test/test_interruptable_task.py +0 -48
- locust/test/test_load_locustfile.py +0 -228
- locust/test/test_locust_class.py +0 -831
- locust/test/test_log.py +0 -237
- locust/test/test_main.py +0 -2264
- locust/test/test_old_wait_api.py +0 -0
- locust/test/test_parser.py +0 -450
- locust/test/test_runners.py +0 -4476
- locust/test/test_sequential_taskset.py +0 -157
- locust/test/test_stats.py +0 -866
- locust/test/test_tags.py +0 -440
- locust/test/test_taskratio.py +0 -94
- locust/test/test_users.py +0 -69
- locust/test/test_util.py +0 -33
- locust/test/test_wait_time.py +0 -79
- locust/test/test_web.py +0 -1257
- locust/test/test_zmqrpc.py +0 -58
- locust/test/testcases.py +0 -248
- locust/test/util.py +0 -88
- locust-2.29.2.dev32.dist-info/RECORD +0 -79
- locust-2.29.2.dev32.dist-info/WHEEL +0 -5
- locust-2.29.2.dev32.dist-info/entry_points.txt +0 -2
- locust-2.29.2.dev32.dist-info/top_level.txt +0 -1
- {locust-2.29.2.dev32.dist-info → locust-2.29.2.dev42.dist-info}/LICENSE +0 -0
locust/test/test_log.py
DELETED
@@ -1,237 +0,0 @@
|
|
1
|
-
from locust import log
|
2
|
-
from locust.log import greenlet_exception_logger
|
3
|
-
|
4
|
-
import socket
|
5
|
-
import subprocess
|
6
|
-
import textwrap
|
7
|
-
from logging import getLogger
|
8
|
-
from unittest import mock
|
9
|
-
|
10
|
-
import gevent
|
11
|
-
|
12
|
-
from . import changed_rlimit
|
13
|
-
from .testcases import LocustTestCase
|
14
|
-
from .util import temporary_file
|
15
|
-
|
16
|
-
|
17
|
-
class TestGreenletExceptionLogger(LocustTestCase):
|
18
|
-
# Gevent outputs all unhandled exceptions to stderr, so we'll suppress that in this test
|
19
|
-
@mock.patch("sys.stderr.write")
|
20
|
-
def test_greenlet_exception_logger(self, mocked_stderr):
|
21
|
-
self.assertFalse(log.unhandled_greenlet_exception)
|
22
|
-
|
23
|
-
def thread():
|
24
|
-
raise ValueError("Boom!?")
|
25
|
-
|
26
|
-
logger = getLogger("greenlet_test_logger")
|
27
|
-
g = gevent.spawn(thread)
|
28
|
-
g.link_exception(greenlet_exception_logger(logger))
|
29
|
-
g.join()
|
30
|
-
self.assertEqual(1, len(self.mocked_log.critical))
|
31
|
-
msg = self.mocked_log.critical[0]
|
32
|
-
self.assertIn("Unhandled exception in greenlet: ", msg["message"])
|
33
|
-
self.assertTrue(isinstance(msg["exc_info"][1], ValueError))
|
34
|
-
self.assertIn("Boom!?", str(msg["exc_info"][1]))
|
35
|
-
self.assertTrue(log.unhandled_greenlet_exception)
|
36
|
-
|
37
|
-
|
38
|
-
class TestLoggingOptions(LocustTestCase):
|
39
|
-
def test_logging_output(self):
|
40
|
-
with temporary_file(
|
41
|
-
textwrap.dedent(
|
42
|
-
"""
|
43
|
-
import logging
|
44
|
-
from locust import User, task, constant
|
45
|
-
|
46
|
-
custom_logger = logging.getLogger("custom_logger")
|
47
|
-
|
48
|
-
class MyUser(User):
|
49
|
-
wait_time = constant(2)
|
50
|
-
@task
|
51
|
-
def my_task(self):
|
52
|
-
print("running my_task")
|
53
|
-
logging.info("custom log message")
|
54
|
-
custom_logger.info("test")
|
55
|
-
"""
|
56
|
-
)
|
57
|
-
) as file_path:
|
58
|
-
output = subprocess.check_output(
|
59
|
-
[
|
60
|
-
"locust",
|
61
|
-
"-f",
|
62
|
-
file_path,
|
63
|
-
"-u",
|
64
|
-
"1",
|
65
|
-
"-r",
|
66
|
-
"1",
|
67
|
-
"-t",
|
68
|
-
"1",
|
69
|
-
"--headless",
|
70
|
-
],
|
71
|
-
stderr=subprocess.STDOUT,
|
72
|
-
timeout=10,
|
73
|
-
text=True,
|
74
|
-
)
|
75
|
-
|
76
|
-
self.assertIn(
|
77
|
-
f"{socket.gethostname()}/INFO/locust.main: Run time limit set to 1 seconds",
|
78
|
-
output,
|
79
|
-
)
|
80
|
-
self.assertIn(
|
81
|
-
f"{socket.gethostname()}/INFO/locust.main: --run-time limit reached, shutting down",
|
82
|
-
output,
|
83
|
-
)
|
84
|
-
self.assertIn(
|
85
|
-
f"{socket.gethostname()}/INFO/locust.main: Shutting down (exit code 0)",
|
86
|
-
output,
|
87
|
-
)
|
88
|
-
self.assertIn(
|
89
|
-
"\nrunning my_task\n",
|
90
|
-
output,
|
91
|
-
)
|
92
|
-
# check that custom message of root logger is also printed
|
93
|
-
self.assertIn(
|
94
|
-
f"{socket.gethostname()}/INFO/root: custom log message",
|
95
|
-
output,
|
96
|
-
)
|
97
|
-
# check that custom message of custom_logger is also printed
|
98
|
-
self.assertIn(
|
99
|
-
f"{socket.gethostname()}/INFO/custom_logger: test",
|
100
|
-
output,
|
101
|
-
)
|
102
|
-
|
103
|
-
def test_skip_logging(self):
|
104
|
-
with temporary_file(
|
105
|
-
textwrap.dedent(
|
106
|
-
"""
|
107
|
-
from locust import User, task, constant
|
108
|
-
|
109
|
-
class MyUser(User):
|
110
|
-
wait_time = constant(2)
|
111
|
-
@task
|
112
|
-
def my_task(self):
|
113
|
-
print("running my_task")
|
114
|
-
"""
|
115
|
-
)
|
116
|
-
) as file_path:
|
117
|
-
output = subprocess.check_output(
|
118
|
-
[
|
119
|
-
"locust",
|
120
|
-
"-f",
|
121
|
-
file_path,
|
122
|
-
"-u",
|
123
|
-
"1",
|
124
|
-
"-r",
|
125
|
-
"1",
|
126
|
-
"-t",
|
127
|
-
"1",
|
128
|
-
"--headless",
|
129
|
-
"--skip-log-setup",
|
130
|
-
],
|
131
|
-
stderr=subprocess.STDOUT,
|
132
|
-
timeout=10,
|
133
|
-
text=True,
|
134
|
-
)
|
135
|
-
if not changed_rlimit:
|
136
|
-
self.assertTrue(output.strip().endswith("running my_task"))
|
137
|
-
else:
|
138
|
-
self.assertEqual("running my_task", output.strip())
|
139
|
-
|
140
|
-
def test_log_to_file(self):
|
141
|
-
with temporary_file(
|
142
|
-
textwrap.dedent(
|
143
|
-
"""
|
144
|
-
import logging
|
145
|
-
from locust import User, task, constant
|
146
|
-
|
147
|
-
class MyUser(User):
|
148
|
-
wait_time = constant(2)
|
149
|
-
@task
|
150
|
-
def my_task(self):
|
151
|
-
print("running my_task")
|
152
|
-
logging.info("custom log message")
|
153
|
-
"""
|
154
|
-
)
|
155
|
-
) as file_path:
|
156
|
-
with temporary_file("", suffix=".log") as log_file_path:
|
157
|
-
try:
|
158
|
-
output = subprocess.check_output(
|
159
|
-
[
|
160
|
-
"locust",
|
161
|
-
"-f",
|
162
|
-
file_path,
|
163
|
-
"-u",
|
164
|
-
"1",
|
165
|
-
"-r",
|
166
|
-
"1",
|
167
|
-
"-t",
|
168
|
-
"1",
|
169
|
-
"--headless",
|
170
|
-
"--logfile",
|
171
|
-
log_file_path,
|
172
|
-
],
|
173
|
-
stderr=subprocess.STDOUT,
|
174
|
-
timeout=10,
|
175
|
-
text=True,
|
176
|
-
)
|
177
|
-
except subprocess.CalledProcessError as e:
|
178
|
-
raise AssertionError(f"Running locust command failed. Output was:\n\n{e.stdout}") from e
|
179
|
-
|
180
|
-
with open(log_file_path, encoding="utf-8") as f:
|
181
|
-
log_content = f.read()
|
182
|
-
|
183
|
-
# make sure print still appears in output
|
184
|
-
self.assertIn("running my_task", output)
|
185
|
-
|
186
|
-
# check that log messages don't go into output
|
187
|
-
self.assertNotIn("Starting Locust", output)
|
188
|
-
self.assertNotIn("Run time limit set to 1 seconds", output)
|
189
|
-
|
190
|
-
# check that log messages goes into file
|
191
|
-
self.assertIn(
|
192
|
-
f"{socket.gethostname()}/INFO/locust.main: Run time limit set to 1 seconds",
|
193
|
-
log_content,
|
194
|
-
)
|
195
|
-
self.assertIn(
|
196
|
-
f"{socket.gethostname()}/INFO/locust.main: --run-time limit reached, shutting down",
|
197
|
-
log_content,
|
198
|
-
)
|
199
|
-
self.assertIn(
|
200
|
-
f"{socket.gethostname()}/INFO/locust.main: Shutting down (exit code 0)",
|
201
|
-
log_content,
|
202
|
-
)
|
203
|
-
# check that message of custom logger also went into log file
|
204
|
-
self.assertIn(
|
205
|
-
f"{socket.gethostname()}/INFO/root: custom log message",
|
206
|
-
log_content,
|
207
|
-
)
|
208
|
-
|
209
|
-
def test_user_broken_on_start(self):
|
210
|
-
with temporary_file(
|
211
|
-
textwrap.dedent(
|
212
|
-
"""
|
213
|
-
from locust import HttpUser, task
|
214
|
-
|
215
|
-
class TestUser(HttpUser):
|
216
|
-
host = "invalidhost"
|
217
|
-
|
218
|
-
def on_start(self):
|
219
|
-
self.client.get("/")
|
220
|
-
"""
|
221
|
-
)
|
222
|
-
) as file_path:
|
223
|
-
output = subprocess.check_output(
|
224
|
-
[
|
225
|
-
"locust",
|
226
|
-
"-f",
|
227
|
-
file_path,
|
228
|
-
"-t",
|
229
|
-
"1",
|
230
|
-
"--headless",
|
231
|
-
],
|
232
|
-
stderr=subprocess.STDOUT,
|
233
|
-
timeout=10,
|
234
|
-
text=True,
|
235
|
-
)
|
236
|
-
|
237
|
-
self.assertIn("ERROR/locust.user.users: Invalid URL", output)
|