3
3
from .utility import *
4
4
import logging
5
5
from . import dfly_args
6
+ from .instance import DflyInstance , DflyInstanceFactory
6
7
7
8
8
9
@pytest .mark .opt_only
17
18
("STRING" , 3_500_000 , 1000 , 1 ),
18
19
],
19
20
)
20
- async def test_rss_used_mem_gap (df_factory , type , keys , val_size , elements ):
21
+ # We limit to 5gb just in case to sanity check the gh runner. Otherwise, if we ask for too much
22
+ # memory it might force the gh runner to run out of memory (since OOM killer might not even
23
+ # get a chance to run).
24
+ @dfly_args ({"proactor_threads" : 4 , "maxmemory" : "5gb" })
25
+ async def test_rss_used_mem_gap (df_server : DflyInstance , type , keys , val_size , elements ):
21
26
# Create a Dragonfly and fill it up with `type` until it reaches `min_rss`, then make sure that
22
27
# the gap between used_memory and rss is no more than `max_unaccounted_ratio`.
23
28
min_rss = 3 * 1024 * 1024 * 1024 # 3gb
24
29
max_unaccounted = 200 * 1024 * 1024 # 200mb
25
30
26
- # We limit to 5gb just in case to sanity check the gh runner. Otherwise, if we ask for too much
27
- # memory it might force the gh runner to run out of memory (since OOM killer might not even
28
- # get a chance to run).
29
- df_server = df_factory .create (maxmemory = "5gb" )
30
- df_factory .start_all ([df_server ])
31
31
client = df_server .client ()
32
32
await asyncio .sleep (1 ) # Wait for another RSS heartbeat update in Dragonfly
33
33
@@ -60,21 +60,20 @@ async def test_rss_used_mem_gap(df_factory, type, keys, val_size, elements):
60
60
}
61
61
)
62
62
@pytest .mark .parametrize ("admin_port" , [0 , 1112 ])
63
- async def test_rss_oom_ratio (df_factory , admin_port ):
63
+ async def test_rss_oom_ratio (df_factory : DflyInstanceFactory , admin_port ):
64
64
"""
65
65
Test dragonfly rejects denyoom commands and new connections when rss memory is above maxmemory*rss_oom_deny_ratio
66
66
Test dragonfly does not rejects when rss memory goes below threshold
67
67
"""
68
68
df_server = df_factory .create (admin_port = admin_port )
69
69
df_server .start ()
70
70
71
- client = aioredis . Redis ( port = df_server .port )
71
+ client = df_server .client ( )
72
72
await client .execute_command ("DEBUG POPULATE 10000 key 40000 RAND" )
73
73
74
74
await asyncio .sleep (1 ) # Wait for another RSS heartbeat update in Dragonfly
75
75
76
- port = df_server .admin_port if admin_port else df_server .port
77
- new_client = aioredis .Redis (port = port )
76
+ new_client = df_server .admin_client () if admin_port else df_server .client ()
78
77
await new_client .ping ()
79
78
80
79
info = await new_client .info ("memory" )
@@ -92,7 +91,7 @@ async def test_rss_oom_ratio(df_factory, admin_port):
92
91
93
92
if admin_port :
94
93
# new client create should also fail if admin port was set
95
- client = aioredis . Redis ( port = df_server .port )
94
+ client = df_server .client ( )
96
95
with pytest .raises (redis .exceptions .ConnectionError ):
97
96
await client .ping ()
98
97
@@ -106,5 +105,5 @@ async def test_rss_oom_ratio(df_factory, admin_port):
106
105
assert info ["used_memory_rss" ] < reject_limit
107
106
108
107
# new client create shoud not fail after memory usage decrease
109
- client = aioredis . Redis ( port = df_server .port )
108
+ client = df_server .client ( )
110
109
await client .execute_command ("set x y" )
0 commit comments