Skip to content

Commit e04e99d

Browse files
committed
chore: run tests with list_experimental_v2 enabled
Also fix issues with memory_test.py running locally. Signed-off-by: Roman Gershman <[email protected]>
1 parent 79aa5d4 commit e04e99d

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

tests/dragonfly/instance.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def cluster_client(self, *args, **kwargs) -> RedisCluster:
153153

154154
async def close_clients(self):
155155
for client in self.clients:
156-
await client.close()
156+
await client.aclose() if hasattr(client, "aclose") else client.close()
157157

158158
def __enter__(self):
159159
self.start()
@@ -411,6 +411,10 @@ def create(self, existing_port=None, path=None, version=100, **kwargs) -> DflyIn
411411
vmod = "dragonfly_connection=1,accept_server=1,listener_interface=1,main_service=1,rdb_save=1,replica=1,cluster_family=1,proactor_pool=1,dflycmd=1"
412412
args.setdefault("vmodule", vmod)
413413
args.setdefault("jsonpathv2")
414+
415+
# If path is not set, we assume that we are running the latest dragonfly.
416+
if not path:
417+
args.setdefault("list_experimental_v2")
414418
args.setdefault("log_dir", self.params.log_dir)
415419

416420
if version >= 1.21:

tests/dragonfly/memory_test.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .utility import *
44
import logging
55
from . import dfly_args
6+
from .instance import DflyInstance, DflyInstanceFactory
67

78

89
@pytest.mark.opt_only
@@ -17,17 +18,16 @@
1718
("STRING", 3_500_000, 1000, 1),
1819
],
1920
)
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):
2126
# Create a Dragonfly and fill it up with `type` until it reaches `min_rss`, then make sure that
2227
# the gap between used_memory and rss is no more than `max_unaccounted_ratio`.
2328
min_rss = 3 * 1024 * 1024 * 1024 # 3gb
2429
max_unaccounted = 200 * 1024 * 1024 # 200mb
2530

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])
3131
client = df_server.client()
3232
await asyncio.sleep(1) # Wait for another RSS heartbeat update in Dragonfly
3333

@@ -60,21 +60,20 @@ async def test_rss_used_mem_gap(df_factory, type, keys, val_size, elements):
6060
}
6161
)
6262
@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):
6464
"""
6565
Test dragonfly rejects denyoom commands and new connections when rss memory is above maxmemory*rss_oom_deny_ratio
6666
Test dragonfly does not rejects when rss memory goes below threshold
6767
"""
6868
df_server = df_factory.create(admin_port=admin_port)
6969
df_server.start()
7070

71-
client = aioredis.Redis(port=df_server.port)
71+
client = df_server.client()
7272
await client.execute_command("DEBUG POPULATE 10000 key 40000 RAND")
7373

7474
await asyncio.sleep(1) # Wait for another RSS heartbeat update in Dragonfly
7575

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()
7877
await new_client.ping()
7978

8079
info = await new_client.info("memory")
@@ -92,7 +91,7 @@ async def test_rss_oom_ratio(df_factory, admin_port):
9291

9392
if admin_port:
9493
# new client create should also fail if admin port was set
95-
client = aioredis.Redis(port=df_server.port)
94+
client = df_server.client()
9695
with pytest.raises(redis.exceptions.ConnectionError):
9796
await client.ping()
9897

@@ -106,5 +105,5 @@ async def test_rss_oom_ratio(df_factory, admin_port):
106105
assert info["used_memory_rss"] < reject_limit
107106

108107
# new client create shoud not fail after memory usage decrease
109-
client = aioredis.Redis(port=df_server.port)
108+
client = df_server.client()
110109
await client.execute_command("set x y")

0 commit comments

Comments
 (0)