locust 2.41.7.dev9__py3-none-any.whl → 2.41.7.dev12__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 CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '2.41.7.dev9'
32
- __version_tuple__ = version_tuple = (2, 41, 7, 'dev9')
31
+ __version__ = version = '2.41.7.dev12'
32
+ __version_tuple__ = version_tuple = (2, 41, 7, 'dev12')
33
33
 
34
34
  __commit_id__ = commit_id = None
locust/contrib/dns.py ADDED
@@ -0,0 +1,50 @@
1
+ from locust import User
2
+ from locust.exception import LocustError
3
+
4
+ import time
5
+ from collections.abc import Callable
6
+
7
+ import dns.query
8
+ from dns.exception import DNSException
9
+ from dns.message import Message
10
+
11
+
12
+ class DNSClient:
13
+ def __init__(self, request_event):
14
+ self.request_event = request_event
15
+
16
+ def __getattr__(self, function_name) -> Callable[..., Message]:
17
+ func = getattr(dns.query, function_name)
18
+
19
+ def wrapper(message: Message, *args, name=None, **kwargs) -> Message:
20
+ response = None
21
+ request_meta = {
22
+ "request_type": "DNS",
23
+ "name": name or function_name,
24
+ "start_time": time.time(),
25
+ "response_length": 0,
26
+ "context": {},
27
+ "exception": None,
28
+ }
29
+ start_perf_counter = time.perf_counter()
30
+ try:
31
+ response = func(message, *args, **kwargs)
32
+ except DNSException as e:
33
+ request_meta["exception"] = e
34
+ else:
35
+ if not response.answer:
36
+ request_meta["exception"] = LocustError("No answer in DNS response")
37
+ request_meta["response_time"] = (time.perf_counter() - start_perf_counter) * 1000
38
+ request_meta["response"] = response
39
+ self.request_event.fire(**request_meta)
40
+ return response
41
+
42
+ return wrapper # for some reason, pyright still wont infer the return type to be Message
43
+
44
+
45
+ class DNSUser(User):
46
+ abstract = True
47
+
48
+ def __init__(self, environment):
49
+ super().__init__(environment)
50
+ self.client = DNSClient(environment.events.request)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: locust
3
- Version: 2.41.7.dev9
3
+ Version: 2.41.7.dev12
4
4
  Summary: Developer-friendly load testing framework
5
5
  Project-URL: homepage, https://locust.io/
6
6
  Project-URL: repository, https://github.com/locustio/locust
@@ -44,6 +44,8 @@ Requires-Dist: setuptools>=70.0.0
44
44
  Requires-Dist: tomli>=1.1.0; python_version < '3.11'
45
45
  Requires-Dist: typing-extensions>=4.6.0; python_version < '3.12'
46
46
  Requires-Dist: werkzeug>=2.0.0
47
+ Provides-Extra: dns
48
+ Requires-Dist: dnspython>=2.8.0; extra == 'dns'
47
49
  Provides-Extra: milvus
48
50
  Requires-Dist: pymilvus>=2.5.0; extra == 'milvus'
49
51
  Provides-Extra: mqtt
@@ -1,6 +1,6 @@
1
1
  locust/__init__.py,sha256=HadpgGidiyCDPSKwkxrk1Qw6eB7dTmftNJVftuJzAiw,1876
2
2
  locust/__main__.py,sha256=vBQ82334kX06ImDbFlPFgiBRiLIinwNk3z8Khs6hd74,31
3
- locust/_version.py,sha256=Yuozf9jPPJg_81Vo2Ajl_VdRzYaQQGCEGm5m6MKl5o0,719
3
+ locust/_version.py,sha256=d_fUCMcfYMMze2J8xvAB-buiRdWco8KVqXBpGG-SjSE,721
4
4
  locust/argument_parser.py,sha256=E0HM9jOlKCzPM9S_E_UKSwgiF_CL0aIli5eCcOG8Xac,33547
5
5
  locust/clients.py,sha256=OfMTOT3LwijczdL3u6bpDwDNM2TDcPCIwXBelizPOyw,20776
6
6
  locust/debug.py,sha256=7CCm8bIg44uGH2wqBlo1rXBzV2VzwPicLxLewz8r5CQ,5099
@@ -18,6 +18,7 @@ locust/shape.py,sha256=t-lwBS8LOjWcKXNL7j2U3zroIXJ1b0fazUwpRYQOKXw,1973
18
18
  locust/stats.py,sha256=qyoSKT0i7RunLDj5pMGqizK1Sp8bcqUsXwh2m4_DpR8,47203
19
19
  locust/web.py,sha256=pLYuocmx9gifJ4vsVDgGDYIPkQhQxI7kKjxoXcUajqM,31865
20
20
  locust/contrib/__init__.py,sha256=LtZN7MczpIAbZkN7PT2h8W2wgb9nBl6cDXbFCVsV4fo,290
21
+ locust/contrib/dns.py,sha256=dL36S4dwqQkrQOcy2_2OuGOPPzAljS9-nIswTZN7Adw,1665
21
22
  locust/contrib/fasthttp.py,sha256=vuHo6EFzSHJgr5SoYf_11Mu-ApnC0mz3hOU6TzQnioI,31145
22
23
  locust/contrib/milvus.py,sha256=ebOIVo6-rO3hnAMPKzMyof5MQd7kxOZFMkBNZYOluYk,13015
23
24
  locust/contrib/mongodb.py,sha256=1seUYgJOaNKwybYOP9PUEVhgl8hGy-G33f8lFj3R8W8,1246
@@ -57,8 +58,8 @@ locust/webui/dist/assets/terminal.gif,sha256=iw80LO2u0dnf4wpGfFJZauBeKTcSpw9iUfI
57
58
  locust/webui/dist/assets/testruns-dark.png,sha256=G4p2VZSBuuqF4neqUaPSshIp5OKQJ_Bvb69Luj6XuVs,125231
58
59
  locust/webui/dist/assets/testruns-light.png,sha256=JinGDiiBPOkhpfF-XCbmQqhRInqItrjrBTLKt5MlqVI,130301
59
60
  pytest_locust/plugin.py,sha256=3jr_5H_1SHCJTdQdgnTDJ-09r5jXzNKxJPkocfE9HF4,1669
60
- locust-2.41.7.dev9.dist-info/METADATA,sha256=yPK1LLio_glXnXBdhbLMalFcqU_4Jwq_bnIC-yKxWiA,9775
61
- locust-2.41.7.dev9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
62
- locust-2.41.7.dev9.dist-info/entry_points.txt,sha256=0uIHcQ71R1qaWhM_sd8uBUCCJgp7gJfGHUVMnJeZfcY,86
63
- locust-2.41.7.dev9.dist-info/licenses/LICENSE,sha256=5hnz-Vpj0Z3kSCQl0LzV2hT1TLc4LHcbpBp3Cy-EuyM,1110
64
- locust-2.41.7.dev9.dist-info/RECORD,,
61
+ locust-2.41.7.dev12.dist-info/METADATA,sha256=ByL_5_uUxbzcDdtDQq81uz47BXaBf8qRHDTEArzZMhE,9844
62
+ locust-2.41.7.dev12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
63
+ locust-2.41.7.dev12.dist-info/entry_points.txt,sha256=0uIHcQ71R1qaWhM_sd8uBUCCJgp7gJfGHUVMnJeZfcY,86
64
+ locust-2.41.7.dev12.dist-info/licenses/LICENSE,sha256=5hnz-Vpj0Z3kSCQl0LzV2hT1TLc4LHcbpBp3Cy-EuyM,1110
65
+ locust-2.41.7.dev12.dist-info/RECORD,,