-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathtest_websocket_client.py
52 lines (42 loc) · 1.91 KB
/
test_websocket_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
"""Performance testing of Websocket clients."""
from __future__ import annotations
from tests.integration.integration_test_case import IntegrationTestCase
from tests.integration.it_utils import test_async_and_sync
from xrpl.models.currencies import XRP, IssuedCurrency
from xrpl.models.requests import BookOffers
from xrpl.models.response import ResponseStatus
class TestWebsocketClient(IntegrationTestCase):
"""Memory usage of websocket client"""
@test_async_and_sync(globals(), websockets_only=True)
async def test_msg_queue_growth_websocket_client(self, client):
"""Test the rate of growth of the Message queue in websocket_client under
persistent load. Admittedly, this is not a precise measure, rather its a proxy
to measure the memory footprint of the client
"""
for _ in range(5):
response = await client.request(
BookOffers(
ledger_index="current",
taker_gets=XRP(),
taker_pays=IssuedCurrency(
currency="USD", issuer="rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq"
),
limit=500,
)
)
self.assertEqual(response.status, ResponseStatus.SUCCESS)
response = await client.request(
BookOffers(
ledger_index="current",
taker_gets=IssuedCurrency(
currency="USD", issuer="rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq"
),
taker_pays=XRP(),
limit=500,
)
)
self.assertEqual(response.status, ResponseStatus.SUCCESS)
self.assertEqual(client._messages.qsize(), 0)
# the messages queue has not increased in proportion to the requests/responses
# input load
self.assertEqual(client._messages.qsize(), 0)