locust 2.29.2.dev34__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-2.29.2.dev34.dist-info → locust-2.29.2.dev42.dist-info}/METADATA +31 -26
- {locust-2.29.2.dev34.dist-info → locust-2.29.2.dev42.dist-info}/RECORD +16 -46
- 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.dev34.dist-info/WHEEL +0 -5
- locust-2.29.2.dev34.dist-info/entry_points.txt +0 -2
- locust-2.29.2.dev34.dist-info/top_level.txt +0 -1
- {locust-2.29.2.dev34.dist-info → locust-2.29.2.dev42.dist-info}/LICENSE +0 -0
locust/test/test_tags.py
DELETED
@@ -1,440 +0,0 @@
|
|
1
|
-
from locust import TaskSet, User, tag, task
|
2
|
-
from locust.env import Environment
|
3
|
-
from locust.user.task import filter_tasks_by_tags
|
4
|
-
|
5
|
-
from .testcases import LocustTestCase
|
6
|
-
|
7
|
-
|
8
|
-
class TestTags(LocustTestCase):
|
9
|
-
def test_tagging(self):
|
10
|
-
@tag("tag1")
|
11
|
-
@task
|
12
|
-
def tagged():
|
13
|
-
pass
|
14
|
-
|
15
|
-
self.assertIn("locust_tag_set", dir(tagged))
|
16
|
-
self.assertEqual({"tag1"}, tagged.locust_tag_set)
|
17
|
-
|
18
|
-
@tag("tag2", "tag3")
|
19
|
-
@task
|
20
|
-
def tagged_multiple_args():
|
21
|
-
pass
|
22
|
-
|
23
|
-
self.assertIn("locust_tag_set", dir(tagged_multiple_args))
|
24
|
-
self.assertEqual({"tag2", "tag3"}, tagged_multiple_args.locust_tag_set)
|
25
|
-
|
26
|
-
@tag("tag4")
|
27
|
-
@tag("tag5")
|
28
|
-
@task
|
29
|
-
def tagged_multiple_times():
|
30
|
-
pass
|
31
|
-
|
32
|
-
self.assertIn("locust_tag_set", dir(tagged_multiple_times))
|
33
|
-
self.assertEqual({"tag4", "tag5"}, tagged_multiple_times.locust_tag_set)
|
34
|
-
|
35
|
-
def test_tagging_taskset(self):
|
36
|
-
@tag("taskset")
|
37
|
-
@task
|
38
|
-
class MyTaskSet(TaskSet):
|
39
|
-
@task
|
40
|
-
def tagged(self):
|
41
|
-
pass
|
42
|
-
|
43
|
-
@tag("task")
|
44
|
-
@task
|
45
|
-
def tagged_again(self):
|
46
|
-
pass
|
47
|
-
|
48
|
-
@tag("taskset2")
|
49
|
-
@task
|
50
|
-
class NestedTaskSet(TaskSet):
|
51
|
-
@task
|
52
|
-
def nested_task(self):
|
53
|
-
pass
|
54
|
-
|
55
|
-
# when tagging taskset, its tasks receive the tag
|
56
|
-
self.assertIn("locust_tag_set", dir(MyTaskSet.tagged))
|
57
|
-
self.assertEqual({"taskset"}, MyTaskSet.tagged.locust_tag_set)
|
58
|
-
|
59
|
-
# tagging inner task receives both
|
60
|
-
self.assertIn("locust_tag_set", dir(MyTaskSet.tagged_again))
|
61
|
-
self.assertEqual({"taskset", "task"}, MyTaskSet.tagged_again.locust_tag_set)
|
62
|
-
|
63
|
-
# when tagging nested taskset, its tasks receives both
|
64
|
-
self.assertIn("locust_tag_set", dir(MyTaskSet.NestedTaskSet.nested_task))
|
65
|
-
self.assertEqual({"taskset", "taskset2"}, MyTaskSet.NestedTaskSet.nested_task.locust_tag_set)
|
66
|
-
|
67
|
-
def test_tagging_without_args_fails(self):
|
68
|
-
@task
|
69
|
-
def dummy_task(self):
|
70
|
-
pass
|
71
|
-
|
72
|
-
# task is tagged without parens
|
73
|
-
self.assertRaises(ValueError, lambda: tag(dummy_task))
|
74
|
-
|
75
|
-
# task is tagged with empty parens
|
76
|
-
self.assertRaises(ValueError, lambda: tag()(dummy_task))
|
77
|
-
|
78
|
-
def test_including_tags(self):
|
79
|
-
class MyTaskSet(TaskSet):
|
80
|
-
@tag("include this", "other tag")
|
81
|
-
@task
|
82
|
-
def included(self):
|
83
|
-
pass
|
84
|
-
|
85
|
-
@tag("dont include this", "other tag")
|
86
|
-
@task
|
87
|
-
def not_included(self):
|
88
|
-
pass
|
89
|
-
|
90
|
-
@task
|
91
|
-
def dont_include_this_either(self):
|
92
|
-
pass
|
93
|
-
|
94
|
-
self.assertListEqual(
|
95
|
-
MyTaskSet.tasks, [MyTaskSet.included, MyTaskSet.not_included, MyTaskSet.dont_include_this_either]
|
96
|
-
)
|
97
|
-
|
98
|
-
filter_tasks_by_tags(MyTaskSet, tags={"include this"})
|
99
|
-
self.assertListEqual(MyTaskSet.tasks, [MyTaskSet.included])
|
100
|
-
|
101
|
-
def test_excluding_tags(self):
|
102
|
-
class MyTaskSet(TaskSet):
|
103
|
-
@tag("exclude this", "other tag")
|
104
|
-
@task
|
105
|
-
def excluded(self):
|
106
|
-
pass
|
107
|
-
|
108
|
-
@tag("dont exclude this", "other tag")
|
109
|
-
@task
|
110
|
-
def not_excluded(self):
|
111
|
-
pass
|
112
|
-
|
113
|
-
@task
|
114
|
-
def dont_exclude_this_either(self):
|
115
|
-
pass
|
116
|
-
|
117
|
-
self.assertListEqual(
|
118
|
-
MyTaskSet.tasks, [MyTaskSet.excluded, MyTaskSet.not_excluded, MyTaskSet.dont_exclude_this_either]
|
119
|
-
)
|
120
|
-
|
121
|
-
filter_tasks_by_tags(MyTaskSet, exclude_tags={"exclude this"})
|
122
|
-
self.assertListEqual(MyTaskSet.tasks, [MyTaskSet.not_excluded, MyTaskSet.dont_exclude_this_either])
|
123
|
-
|
124
|
-
def test_including_and_excluding(self):
|
125
|
-
class MyTaskSet(TaskSet):
|
126
|
-
@task
|
127
|
-
def not_included_or_excluded(self):
|
128
|
-
pass
|
129
|
-
|
130
|
-
@tag("included")
|
131
|
-
@task
|
132
|
-
def included(self):
|
133
|
-
pass
|
134
|
-
|
135
|
-
@tag("excluded")
|
136
|
-
@task
|
137
|
-
def excluded(self):
|
138
|
-
pass
|
139
|
-
|
140
|
-
@tag("included", "excluded")
|
141
|
-
@task
|
142
|
-
def included_and_excluded(self):
|
143
|
-
pass
|
144
|
-
|
145
|
-
filter_tasks_by_tags(MyTaskSet, tags={"included"}, exclude_tags={"excluded"})
|
146
|
-
self.assertListEqual(MyTaskSet.tasks, [MyTaskSet.included])
|
147
|
-
|
148
|
-
def test_including_tasksets(self):
|
149
|
-
class MyTaskSet(TaskSet):
|
150
|
-
@task
|
151
|
-
class MixedNestedTaskSet(TaskSet):
|
152
|
-
@tag("included")
|
153
|
-
@task
|
154
|
-
def included(self):
|
155
|
-
pass
|
156
|
-
|
157
|
-
@task
|
158
|
-
def not_included(self):
|
159
|
-
pass
|
160
|
-
|
161
|
-
@tag("included")
|
162
|
-
@task
|
163
|
-
class TaggedNestedTaskSet(TaskSet):
|
164
|
-
@task
|
165
|
-
def included(self):
|
166
|
-
pass
|
167
|
-
|
168
|
-
@task
|
169
|
-
class NormalNestedTaskSet(TaskSet):
|
170
|
-
@task
|
171
|
-
def not_included(self):
|
172
|
-
pass
|
173
|
-
|
174
|
-
filter_tasks_by_tags(MyTaskSet, tags={"included"})
|
175
|
-
self.assertListEqual(MyTaskSet.tasks, [MyTaskSet.MixedNestedTaskSet, MyTaskSet.TaggedNestedTaskSet])
|
176
|
-
self.assertListEqual(MyTaskSet.MixedNestedTaskSet.tasks, [MyTaskSet.MixedNestedTaskSet.included])
|
177
|
-
|
178
|
-
def test_excluding_tasksets(self):
|
179
|
-
class MyTaskSet(TaskSet):
|
180
|
-
@task
|
181
|
-
class MixedNestedTaskSet(TaskSet):
|
182
|
-
@tag("excluded")
|
183
|
-
@task
|
184
|
-
def excluded(self):
|
185
|
-
pass
|
186
|
-
|
187
|
-
@task
|
188
|
-
def not_excluded(self):
|
189
|
-
pass
|
190
|
-
|
191
|
-
@task
|
192
|
-
class ExcludedNestedTaskSet(TaskSet):
|
193
|
-
@tag("excluded")
|
194
|
-
@task
|
195
|
-
def excluded(self):
|
196
|
-
pass
|
197
|
-
|
198
|
-
@tag("excluded")
|
199
|
-
@task
|
200
|
-
class TaggedNestedTaskSet(TaskSet):
|
201
|
-
@task
|
202
|
-
def excluded(self):
|
203
|
-
pass
|
204
|
-
|
205
|
-
@task
|
206
|
-
class NormalNestedTaskSet(TaskSet):
|
207
|
-
@task
|
208
|
-
def not_excluded(self):
|
209
|
-
pass
|
210
|
-
|
211
|
-
filter_tasks_by_tags(MyTaskSet, exclude_tags={"excluded"})
|
212
|
-
self.assertListEqual(MyTaskSet.tasks, [MyTaskSet.MixedNestedTaskSet, MyTaskSet.NormalNestedTaskSet])
|
213
|
-
self.assertListEqual(MyTaskSet.MixedNestedTaskSet.tasks, [MyTaskSet.MixedNestedTaskSet.not_excluded])
|
214
|
-
|
215
|
-
def test_including_tags_with_weights(self):
|
216
|
-
class MyTaskSet(TaskSet):
|
217
|
-
@tag("included")
|
218
|
-
@task(2)
|
219
|
-
def include_twice(self):
|
220
|
-
pass
|
221
|
-
|
222
|
-
@tag("included")
|
223
|
-
@task(3)
|
224
|
-
def include_3_times(self):
|
225
|
-
pass
|
226
|
-
|
227
|
-
@tag("dont include this")
|
228
|
-
@task(4)
|
229
|
-
def dont_include_4_times(self):
|
230
|
-
pass
|
231
|
-
|
232
|
-
@task(5)
|
233
|
-
def dont_include_5_times(self):
|
234
|
-
pass
|
235
|
-
|
236
|
-
self.assertListEqual(
|
237
|
-
MyTaskSet.tasks,
|
238
|
-
[
|
239
|
-
MyTaskSet.include_twice,
|
240
|
-
MyTaskSet.include_twice,
|
241
|
-
MyTaskSet.include_3_times,
|
242
|
-
MyTaskSet.include_3_times,
|
243
|
-
MyTaskSet.include_3_times,
|
244
|
-
MyTaskSet.dont_include_4_times,
|
245
|
-
MyTaskSet.dont_include_4_times,
|
246
|
-
MyTaskSet.dont_include_4_times,
|
247
|
-
MyTaskSet.dont_include_4_times,
|
248
|
-
MyTaskSet.dont_include_5_times,
|
249
|
-
MyTaskSet.dont_include_5_times,
|
250
|
-
MyTaskSet.dont_include_5_times,
|
251
|
-
MyTaskSet.dont_include_5_times,
|
252
|
-
MyTaskSet.dont_include_5_times,
|
253
|
-
],
|
254
|
-
)
|
255
|
-
|
256
|
-
filter_tasks_by_tags(MyTaskSet, tags={"included"})
|
257
|
-
|
258
|
-
self.assertListEqual(
|
259
|
-
MyTaskSet.tasks,
|
260
|
-
[
|
261
|
-
MyTaskSet.include_twice,
|
262
|
-
MyTaskSet.include_twice,
|
263
|
-
MyTaskSet.include_3_times,
|
264
|
-
MyTaskSet.include_3_times,
|
265
|
-
MyTaskSet.include_3_times,
|
266
|
-
],
|
267
|
-
)
|
268
|
-
|
269
|
-
def test_excluding_tags_with_weights(self):
|
270
|
-
class MyTaskSet(TaskSet):
|
271
|
-
@tag("dont exclude this")
|
272
|
-
@task(2)
|
273
|
-
def dont_exclude_twice(self):
|
274
|
-
pass
|
275
|
-
|
276
|
-
@task(3)
|
277
|
-
def dont_exclude_3_times(self):
|
278
|
-
pass
|
279
|
-
|
280
|
-
@tag("excluded")
|
281
|
-
@task(4)
|
282
|
-
def exclude_4_times(self):
|
283
|
-
pass
|
284
|
-
|
285
|
-
@tag("excluded")
|
286
|
-
@task(5)
|
287
|
-
def exclude_5_times(self):
|
288
|
-
pass
|
289
|
-
|
290
|
-
self.assertListEqual(
|
291
|
-
MyTaskSet.tasks,
|
292
|
-
[
|
293
|
-
MyTaskSet.dont_exclude_twice,
|
294
|
-
MyTaskSet.dont_exclude_twice,
|
295
|
-
MyTaskSet.dont_exclude_3_times,
|
296
|
-
MyTaskSet.dont_exclude_3_times,
|
297
|
-
MyTaskSet.dont_exclude_3_times,
|
298
|
-
MyTaskSet.exclude_4_times,
|
299
|
-
MyTaskSet.exclude_4_times,
|
300
|
-
MyTaskSet.exclude_4_times,
|
301
|
-
MyTaskSet.exclude_4_times,
|
302
|
-
MyTaskSet.exclude_5_times,
|
303
|
-
MyTaskSet.exclude_5_times,
|
304
|
-
MyTaskSet.exclude_5_times,
|
305
|
-
MyTaskSet.exclude_5_times,
|
306
|
-
MyTaskSet.exclude_5_times,
|
307
|
-
],
|
308
|
-
)
|
309
|
-
|
310
|
-
filter_tasks_by_tags(MyTaskSet, exclude_tags={"excluded"})
|
311
|
-
|
312
|
-
self.assertListEqual(
|
313
|
-
MyTaskSet.tasks,
|
314
|
-
[
|
315
|
-
MyTaskSet.dont_exclude_twice,
|
316
|
-
MyTaskSet.dont_exclude_twice,
|
317
|
-
MyTaskSet.dont_exclude_3_times,
|
318
|
-
MyTaskSet.dont_exclude_3_times,
|
319
|
-
MyTaskSet.dont_exclude_3_times,
|
320
|
-
],
|
321
|
-
)
|
322
|
-
|
323
|
-
def test_tagged_tasks_shared_across_tasksets(self):
|
324
|
-
@tag("tagged")
|
325
|
-
def shared_task():
|
326
|
-
pass
|
327
|
-
|
328
|
-
def untagged_shared_task():
|
329
|
-
pass
|
330
|
-
|
331
|
-
@tag("tagged")
|
332
|
-
class SharedTaskSet(TaskSet):
|
333
|
-
@task
|
334
|
-
def inner_task(self):
|
335
|
-
pass
|
336
|
-
|
337
|
-
class IncludeTaskSet(TaskSet):
|
338
|
-
tasks = [shared_task, untagged_shared_task, SharedTaskSet]
|
339
|
-
|
340
|
-
class ExcludeTaskSet(TaskSet):
|
341
|
-
tasks = [shared_task, untagged_shared_task, SharedTaskSet]
|
342
|
-
|
343
|
-
filter_tasks_by_tags(IncludeTaskSet, tags={"tagged"})
|
344
|
-
|
345
|
-
self.assertListEqual(IncludeTaskSet.tasks, [shared_task, SharedTaskSet])
|
346
|
-
self.assertListEqual(IncludeTaskSet.tasks[1].tasks, [SharedTaskSet.inner_task])
|
347
|
-
|
348
|
-
filter_tasks_by_tags(ExcludeTaskSet, exclude_tags={"tagged"})
|
349
|
-
|
350
|
-
self.assertListEqual(ExcludeTaskSet.tasks, [untagged_shared_task])
|
351
|
-
|
352
|
-
def test_include_tags_under_user(self):
|
353
|
-
class MyUser(User):
|
354
|
-
@tag("include this")
|
355
|
-
@task
|
356
|
-
def included(self):
|
357
|
-
pass
|
358
|
-
|
359
|
-
@tag("dont include this")
|
360
|
-
@task
|
361
|
-
def not_included(self):
|
362
|
-
pass
|
363
|
-
|
364
|
-
@task
|
365
|
-
def dont_include_this_either(self):
|
366
|
-
pass
|
367
|
-
|
368
|
-
filter_tasks_by_tags(MyUser, tags={"include this"})
|
369
|
-
|
370
|
-
self.assertListEqual(MyUser.tasks, [MyUser.included])
|
371
|
-
|
372
|
-
def test_exclude_tags_under_user(self):
|
373
|
-
class MyUser(User):
|
374
|
-
@tag("exclude this")
|
375
|
-
@task
|
376
|
-
def excluded(self):
|
377
|
-
pass
|
378
|
-
|
379
|
-
@tag("dont exclude this")
|
380
|
-
@task
|
381
|
-
def not_excluded(self):
|
382
|
-
pass
|
383
|
-
|
384
|
-
@task
|
385
|
-
def dont_exclude_this_either(self):
|
386
|
-
pass
|
387
|
-
|
388
|
-
filter_tasks_by_tags(MyUser, exclude_tags={"exclude this"})
|
389
|
-
|
390
|
-
self.assertListEqual(MyUser.tasks, [MyUser.not_excluded, MyUser.dont_exclude_this_either])
|
391
|
-
|
392
|
-
def test_env_include_tags(self):
|
393
|
-
class MyTaskSet(TaskSet):
|
394
|
-
@tag("include this")
|
395
|
-
@task
|
396
|
-
def included(self):
|
397
|
-
pass
|
398
|
-
|
399
|
-
@tag("dont include this")
|
400
|
-
@task
|
401
|
-
def not_included(self):
|
402
|
-
pass
|
403
|
-
|
404
|
-
@task
|
405
|
-
def dont_include_this_either(self):
|
406
|
-
pass
|
407
|
-
|
408
|
-
class MyUser(User):
|
409
|
-
tasks = [MyTaskSet]
|
410
|
-
|
411
|
-
env = Environment(user_classes=[MyUser], tags=["include this"])
|
412
|
-
env._filter_tasks_by_tags()
|
413
|
-
|
414
|
-
self.assertListEqual(MyUser.tasks, [MyTaskSet])
|
415
|
-
self.assertListEqual(MyUser.tasks[0].tasks, [MyTaskSet.included])
|
416
|
-
|
417
|
-
def test_env_exclude_tags(self):
|
418
|
-
class MyTaskSet(User):
|
419
|
-
@tag("exclude this")
|
420
|
-
@task
|
421
|
-
def excluded(self):
|
422
|
-
pass
|
423
|
-
|
424
|
-
@tag("dont exclude this")
|
425
|
-
@task
|
426
|
-
def not_excluded(self):
|
427
|
-
pass
|
428
|
-
|
429
|
-
@task
|
430
|
-
def dont_exclude_this_either(self):
|
431
|
-
pass
|
432
|
-
|
433
|
-
class MyUser(User):
|
434
|
-
tasks = [MyTaskSet]
|
435
|
-
|
436
|
-
env = Environment(user_classes=[MyUser], exclude_tags=["exclude this"])
|
437
|
-
env._filter_tasks_by_tags()
|
438
|
-
|
439
|
-
self.assertListEqual(MyUser.tasks, [MyTaskSet])
|
440
|
-
self.assertListEqual(MyUser.tasks[0].tasks, [MyTaskSet.not_excluded, MyTaskSet.dont_exclude_this_either])
|
locust/test/test_taskratio.py
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
from locust.user import TaskSet, User, task
|
2
|
-
from locust.user.inspectuser import _get_task_ratio, get_ratio
|
3
|
-
|
4
|
-
import unittest
|
5
|
-
|
6
|
-
|
7
|
-
class TestTaskRatio(unittest.TestCase):
|
8
|
-
def test_task_ratio_command(self):
|
9
|
-
class Tasks(TaskSet):
|
10
|
-
@task
|
11
|
-
def root_task1(self):
|
12
|
-
pass
|
13
|
-
|
14
|
-
@task
|
15
|
-
class SubTasks(TaskSet):
|
16
|
-
@task
|
17
|
-
def task1(self):
|
18
|
-
pass
|
19
|
-
|
20
|
-
@task
|
21
|
-
def task2(self):
|
22
|
-
pass
|
23
|
-
|
24
|
-
class MyUser(User):
|
25
|
-
tasks = [Tasks]
|
26
|
-
|
27
|
-
ratio_dict = _get_task_ratio(Tasks.tasks, True, 1.0)
|
28
|
-
|
29
|
-
self.assertEqual(
|
30
|
-
{
|
31
|
-
"SubTasks": {"tasks": {"task1": {"ratio": 0.25}, "task2": {"ratio": 0.25}}, "ratio": 0.5},
|
32
|
-
"root_task1": {"ratio": 0.5},
|
33
|
-
},
|
34
|
-
ratio_dict,
|
35
|
-
)
|
36
|
-
|
37
|
-
def test_task_ratio_command_with_locust_weight(self):
|
38
|
-
class Tasks(TaskSet):
|
39
|
-
@task(1)
|
40
|
-
def task1(self):
|
41
|
-
pass
|
42
|
-
|
43
|
-
@task(3)
|
44
|
-
def task3(self):
|
45
|
-
pass
|
46
|
-
|
47
|
-
class UnlikelyUser(User):
|
48
|
-
weight = 1
|
49
|
-
tasks = [Tasks]
|
50
|
-
|
51
|
-
class MoreLikelyUser(User):
|
52
|
-
weight = 3
|
53
|
-
tasks = [Tasks]
|
54
|
-
|
55
|
-
ratio_dict = get_ratio([UnlikelyUser, MoreLikelyUser], {"UnlikelyUser": 1, "MoreLikelyUser": 3}, True)
|
56
|
-
|
57
|
-
self.assertDictEqual(
|
58
|
-
{
|
59
|
-
"UnlikelyUser": {
|
60
|
-
"ratio": 0.25,
|
61
|
-
"tasks": {
|
62
|
-
"Tasks": {
|
63
|
-
"tasks": {
|
64
|
-
"task1": {"ratio": 0.25 * 0.25},
|
65
|
-
"task3": {"ratio": 0.25 * 0.75},
|
66
|
-
},
|
67
|
-
"ratio": 0.25,
|
68
|
-
}
|
69
|
-
},
|
70
|
-
},
|
71
|
-
"MoreLikelyUser": {
|
72
|
-
"ratio": 0.75,
|
73
|
-
"tasks": {
|
74
|
-
"Tasks": {
|
75
|
-
"tasks": {
|
76
|
-
"task1": {"ratio": 0.75 * 0.25},
|
77
|
-
"task3": {"ratio": 0.75 * 0.75},
|
78
|
-
},
|
79
|
-
"ratio": 0.75,
|
80
|
-
},
|
81
|
-
},
|
82
|
-
},
|
83
|
-
},
|
84
|
-
ratio_dict,
|
85
|
-
)
|
86
|
-
unlikely = ratio_dict["UnlikelyUser"]["tasks"]["Tasks"]["tasks"]
|
87
|
-
likely = ratio_dict["MoreLikelyUser"]["tasks"]["Tasks"]["tasks"]
|
88
|
-
assert (
|
89
|
-
unlikely["task1"]["ratio"]
|
90
|
-
+ unlikely["task3"]["ratio"]
|
91
|
-
+ likely["task1"]["ratio"]
|
92
|
-
+ likely["task3"]["ratio"]
|
93
|
-
== 1
|
94
|
-
)
|
locust/test/test_users.py
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
from locust import HttpUser, User
|
2
|
-
from locust.test.testcases import WebserverTestCase
|
3
|
-
|
4
|
-
import unittest
|
5
|
-
|
6
|
-
from urllib3 import PoolManager
|
7
|
-
|
8
|
-
|
9
|
-
class TestUserClass(unittest.TestCase):
|
10
|
-
class MyClassScopedUser(User):
|
11
|
-
pass
|
12
|
-
|
13
|
-
def test_fullname_module_scoped(self):
|
14
|
-
self.assertEqual(MyModuleScopedUser.fullname(), "locust.test.test_users.MyModuleScopedUser")
|
15
|
-
|
16
|
-
def test_fullname_class_scoped(self):
|
17
|
-
self.assertEqual(self.MyClassScopedUser.fullname(), "locust.test.test_users.TestUserClass.MyClassScopedUser")
|
18
|
-
|
19
|
-
def test_fullname_function_scoped(self):
|
20
|
-
class MyFunctionScopedUser(User):
|
21
|
-
pass
|
22
|
-
|
23
|
-
self.assertEqual(
|
24
|
-
MyFunctionScopedUser.fullname(),
|
25
|
-
"locust.test.test_users.TestUserClass.test_fullname_function_scoped.MyFunctionScopedUser",
|
26
|
-
)
|
27
|
-
|
28
|
-
|
29
|
-
class MyModuleScopedUser(User):
|
30
|
-
pass
|
31
|
-
|
32
|
-
|
33
|
-
class TestHttpUserWithWebserver(WebserverTestCase):
|
34
|
-
def test_shared_pool_manager(self):
|
35
|
-
shared_pool_manager = PoolManager(maxsize=1, block=True)
|
36
|
-
|
37
|
-
class MyUserA(HttpUser):
|
38
|
-
host = "http://127.0.0.1:%i" % self.port
|
39
|
-
pool_manager = shared_pool_manager
|
40
|
-
|
41
|
-
class MyUserB(HttpUser):
|
42
|
-
host = "http://127.0.0.1:%i" % self.port
|
43
|
-
pool_manager = shared_pool_manager
|
44
|
-
|
45
|
-
user_a = MyUserA(self.environment)
|
46
|
-
user_b = MyUserB(self.environment)
|
47
|
-
|
48
|
-
user_a.client.get("/ultra_fast")
|
49
|
-
user_b.client.get("/ultra_fast")
|
50
|
-
user_b.client.get("/ultra_fast")
|
51
|
-
user_a.client.get("/ultra_fast")
|
52
|
-
|
53
|
-
self.assertEqual(1, self.connections_count)
|
54
|
-
self.assertEqual(4, self.requests_count)
|
55
|
-
|
56
|
-
def test_pool_manager_per_user_instance(self):
|
57
|
-
class MyUser(HttpUser):
|
58
|
-
host = "http://127.0.0.1:%i" % self.port
|
59
|
-
|
60
|
-
user_a = MyUser(self.environment)
|
61
|
-
user_b = MyUser(self.environment)
|
62
|
-
|
63
|
-
user_a.client.get("/ultra_fast")
|
64
|
-
user_b.client.get("/ultra_fast")
|
65
|
-
user_b.client.get("/ultra_fast")
|
66
|
-
user_a.client.get("/ultra_fast")
|
67
|
-
|
68
|
-
self.assertEqual(2, self.connections_count)
|
69
|
-
self.assertEqual(4, self.requests_count)
|
locust/test/test_util.py
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
from locust.util.rounding import proper_round
|
2
|
-
from locust.util.timespan import parse_timespan
|
3
|
-
|
4
|
-
import unittest
|
5
|
-
|
6
|
-
|
7
|
-
class TestParseTimespan(unittest.TestCase):
|
8
|
-
def test_parse_timespan_invalid_values(self):
|
9
|
-
self.assertRaises(ValueError, parse_timespan, None)
|
10
|
-
self.assertRaises(ValueError, parse_timespan, "")
|
11
|
-
self.assertRaises(ValueError, parse_timespan, "q")
|
12
|
-
|
13
|
-
def test_parse_timespan(self):
|
14
|
-
self.assertEqual(7, parse_timespan("7"))
|
15
|
-
self.assertEqual(7, parse_timespan("7s"))
|
16
|
-
self.assertEqual(60, parse_timespan("1m"))
|
17
|
-
self.assertEqual(7200, parse_timespan("2h"))
|
18
|
-
self.assertEqual(3787, parse_timespan("1h3m7s"))
|
19
|
-
|
20
|
-
|
21
|
-
class TestRounding(unittest.TestCase):
|
22
|
-
def test_rounding_down(self):
|
23
|
-
self.assertEqual(1, proper_round(1.499999999))
|
24
|
-
self.assertEqual(5, proper_round(5.499999999))
|
25
|
-
self.assertEqual(2, proper_round(2.05))
|
26
|
-
self.assertEqual(3, proper_round(3.05))
|
27
|
-
|
28
|
-
def test_rounding_up(self):
|
29
|
-
self.assertEqual(2, proper_round(1.5))
|
30
|
-
self.assertEqual(3, proper_round(2.5))
|
31
|
-
self.assertEqual(4, proper_round(3.5))
|
32
|
-
self.assertEqual(5, proper_round(4.5))
|
33
|
-
self.assertEqual(6, proper_round(5.5))
|