API
User
Bases: ABC
Source code in src/aiolocust/__init__.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
cm()
async
Override this method if you need an async context manager around the run method
Source code in src/aiolocust/__init__.py
40 41 42 43 | |
datatypes
SafeCounter
A thread-safe counter.
Source code in src/aiolocust/datatypes.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
mitmproxy_addon
dict_source(data)
We want nice double quotes
Source code in src/aiolocust/mitmproxy_addon.py
32 33 34 35 36 37 38 39 40 41 | |
users
http
HttpUser
Bases: User
Base class for HTTP users.
Source code in src/aiolocust/users/http.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
session_kwargs = {'timeout': aiohttp.ClientTimeout(60.0)}
class-attribute
instance-attribute
Extra arguments to pass to aiohttp.ClientSession, e.g.
class TimeoutUser(HttpUser):
session_kwargs = {
"timeout": aiohttp.ClientTimeout(0.0001),
"skip_auto_headers": {"User-Agent"},
}
...
ssl_context = None
class-attribute
instance-attribute
Used to create a custom TCPConnector for LocustClientSession,
instead of having to pass ssl=ssl_context on each request.
For example, to use OS-managed trust you could do something like this:
import truststore
from aiolocust import HttpUser
class MyUser(HttpUser):
ssl_context = truststore.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT)
...
pw
LocustPage
A wrapper for the Playwright Page object to automatically generate OTel spans.
Source code in src/aiolocust/users/pw.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
websocket
WebsocketUser
Bases: User
Websocket test cases are different: instead of providing the normal run() interface, subclasses typically implement these methods:
on_start() to establish the connection (if you need to do auth before connecting or some initial WS communication afterwards)
receive() to read messages received by the client
send() to send messages, or do anything else you like to do concurrently with the receive loop. It stops automatically (without logging a ConnectionClosed) if the connection is closed by the server.
The run() method ties these things together. Unlike other User classes you don't typically override it.
Source code in src/aiolocust/users/websocket.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |