Skip to content

Commit 4e0a800

Browse files
dvora-hvladvildanov
authored andcommitted
Add modules support to async RedisCluster (#3115)
1 parent b201bd5 commit 4e0a800

File tree

5 files changed

+5
-112
lines changed

5 files changed

+5
-112
lines changed

redis/commands/cluster.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
ScriptCommands,
4545
)
4646
from .helpers import list_or_args
47-
from .redismodules import RedisModuleCommands
47+
from .redismodules import AsyncRedisModuleCommands, RedisModuleCommands
4848

4949
if TYPE_CHECKING:
5050
from redis.asyncio.cluster import TargetNodesT
@@ -907,6 +907,7 @@ class AsyncRedisClusterCommands(
907907
AsyncFunctionCommands,
908908
AsyncGearsCommands,
909909
AsyncModuleCommands,
910+
AsyncRedisModuleCommands,
910911
):
911912
"""
912913
A class for all Redis Cluster commands

tests/test_asyncio/test_bloom.py

+1-25
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def intlist(obj):
1515
return [int(v) for v in obj]
1616

1717

18-
@pytest.mark.redismod
1918
async def test_create(decoded_r: redis.Redis):
2019
"""Test CREATE/RESERVE calls"""
2120
assert await decoded_r.bf().create("bloom", 0.01, 1000)
@@ -30,13 +29,11 @@ async def test_create(decoded_r: redis.Redis):
3029
assert await decoded_r.topk().reserve("topk", 5, 100, 5, 0.9)
3130

3231

33-
@pytest.mark.redismod
3432
@pytest.mark.experimental
3533
async def test_tdigest_create(decoded_r: redis.Redis):
3634
assert await decoded_r.tdigest().create("tDigest", 100)
3735

3836

39-
@pytest.mark.redismod
4037
async def test_bf_add(decoded_r: redis.Redis):
4138
assert await decoded_r.bf().create("bloom", 0.01, 1000)
4239
assert 1 == await decoded_r.bf().add("bloom", "foo")
@@ -49,7 +46,6 @@ async def test_bf_add(decoded_r: redis.Redis):
4946
assert [1, 0] == intlist(await decoded_r.bf().mexists("bloom", "foo", "noexist"))
5047

5148

52-
@pytest.mark.redismod
5349
async def test_bf_insert(decoded_r: redis.Redis):
5450
assert await decoded_r.bf().create("bloom", 0.01, 1000)
5551
assert [1] == intlist(await decoded_r.bf().insert("bloom", ["foo"]))
@@ -80,7 +76,6 @@ async def test_bf_insert(decoded_r: redis.Redis):
8076
)
8177

8278

83-
@pytest.mark.redismod
8479
async def test_bf_scandump_and_loadchunk(decoded_r: redis.Redis):
8580
# Store a filter
8681
await decoded_r.bf().create("myBloom", "0.0001", "1000")
@@ -132,7 +127,6 @@ async def do_verify():
132127
await decoded_r.bf().create("myBloom", "0.0001", "10000000")
133128

134129

135-
@pytest.mark.redismod
136130
async def test_bf_info(decoded_r: redis.Redis):
137131
expansion = 4
138132
# Store a filter
@@ -164,7 +158,6 @@ async def test_bf_info(decoded_r: redis.Redis):
164158
assert True
165159

166160

167-
@pytest.mark.redismod
168161
async def test_bf_card(decoded_r: redis.Redis):
169162
# return 0 if the key does not exist
170163
assert await decoded_r.bf().card("not_exist") == 0
@@ -179,7 +172,6 @@ async def test_bf_card(decoded_r: redis.Redis):
179172
await decoded_r.bf().card("setKey")
180173

181174

182-
@pytest.mark.redismod
183175
async def test_cf_add_and_insert(decoded_r: redis.Redis):
184176
assert await decoded_r.cf().create("cuckoo", 1000)
185177
assert await decoded_r.cf().add("cuckoo", "filter")
@@ -205,7 +197,6 @@ async def test_cf_add_and_insert(decoded_r: redis.Redis):
205197
)
206198

207199

208-
@pytest.mark.redismod
209200
async def test_cf_exists_and_del(decoded_r: redis.Redis):
210201
assert await decoded_r.cf().create("cuckoo", 1000)
211202
assert await decoded_r.cf().add("cuckoo", "filter")
@@ -217,7 +208,6 @@ async def test_cf_exists_and_del(decoded_r: redis.Redis):
217208
assert 0 == await decoded_r.cf().count("cuckoo", "filter")
218209

219210

220-
@pytest.mark.redismod
221211
async def test_cms(decoded_r: redis.Redis):
222212
assert await decoded_r.cms().initbydim("dim", 1000, 5)
223213
assert await decoded_r.cms().initbyprob("prob", 0.01, 0.01)
@@ -233,7 +223,6 @@ async def test_cms(decoded_r: redis.Redis):
233223
assert 25 == info["count"]
234224

235225

236-
@pytest.mark.redismod
237226
@pytest.mark.onlynoncluster
238227
async def test_cms_merge(decoded_r: redis.Redis):
239228
assert await decoded_r.cms().initbydim("A", 1000, 5)
@@ -251,7 +240,6 @@ async def test_cms_merge(decoded_r: redis.Redis):
251240
assert [16, 15, 21] == await decoded_r.cms().query("C", "foo", "bar", "baz")
252241

253242

254-
@pytest.mark.redismod
255243
async def test_topk(decoded_r: redis.Redis):
256244
# test list with empty buckets
257245
assert await decoded_r.topk().reserve("topk", 3, 50, 4, 0.9)
@@ -332,7 +320,6 @@ async def test_topk(decoded_r: redis.Redis):
332320
assert 0.9 == round(float(info["decay"]), 1)
333321

334322

335-
@pytest.mark.redismod
336323
async def test_topk_incrby(decoded_r: redis.Redis):
337324
await decoded_r.flushdb()
338325
assert await decoded_r.topk().reserve("topk", 3, 10, 3, 1)
@@ -347,7 +334,6 @@ async def test_topk_incrby(decoded_r: redis.Redis):
347334
)
348335

349336

350-
@pytest.mark.redismod
351337
@pytest.mark.experimental
352338
async def test_tdigest_reset(decoded_r: redis.Redis):
353339
assert await decoded_r.tdigest().create("tDigest", 10)
@@ -364,7 +350,6 @@ async def test_tdigest_reset(decoded_r: redis.Redis):
364350
)
365351

366352

367-
@pytest.mark.redismod
368353
@pytest.mark.onlynoncluster
369354
async def test_tdigest_merge(decoded_r: redis.Redis):
370355
assert await decoded_r.tdigest().create("to-tDigest", 10)
@@ -392,7 +377,6 @@ async def test_tdigest_merge(decoded_r: redis.Redis):
392377
assert 4.0 == await decoded_r.tdigest().max("to-tDigest")
393378

394379

395-
@pytest.mark.redismod
396380
@pytest.mark.experimental
397381
async def test_tdigest_min_and_max(decoded_r: redis.Redis):
398382
assert await decoded_r.tdigest().create("tDigest", 100)
@@ -403,7 +387,6 @@ async def test_tdigest_min_and_max(decoded_r: redis.Redis):
403387
assert 1 == await decoded_r.tdigest().min("tDigest")
404388

405389

406-
@pytest.mark.redismod
407390
@pytest.mark.experimental
408391
@skip_ifmodversion_lt("2.4.0", "bf")
409392
async def test_tdigest_quantile(decoded_r: redis.Redis):
@@ -432,7 +415,6 @@ async def test_tdigest_quantile(decoded_r: redis.Redis):
432415
assert [3.0, 5.0] == res
433416

434417

435-
@pytest.mark.redismod
436418
@pytest.mark.experimental
437419
async def test_tdigest_cdf(decoded_r: redis.Redis):
438420
assert await decoded_r.tdigest().create("tDigest", 100)
@@ -444,7 +426,6 @@ async def test_tdigest_cdf(decoded_r: redis.Redis):
444426
assert [0.1, 0.9] == [round(x, 1) for x in res]
445427

446428

447-
@pytest.mark.redismod
448429
@pytest.mark.experimental
449430
@skip_ifmodversion_lt("2.4.0", "bf")
450431
async def test_tdigest_trimmed_mean(decoded_r: redis.Redis):
@@ -455,7 +436,6 @@ async def test_tdigest_trimmed_mean(decoded_r: redis.Redis):
455436
assert 4.5 == await decoded_r.tdigest().trimmed_mean("tDigest", 0.4, 0.5)
456437

457438

458-
@pytest.mark.redismod
459439
@pytest.mark.experimental
460440
async def test_tdigest_rank(decoded_r: redis.Redis):
461441
assert await decoded_r.tdigest().create("t-digest", 500)
@@ -466,7 +446,6 @@ async def test_tdigest_rank(decoded_r: redis.Redis):
466446
assert [-1, 20, 9] == await decoded_r.tdigest().rank("t-digest", -20, 20, 9)
467447

468448

469-
@pytest.mark.redismod
470449
@pytest.mark.experimental
471450
async def test_tdigest_revrank(decoded_r: redis.Redis):
472451
assert await decoded_r.tdigest().create("t-digest", 500)
@@ -476,7 +455,6 @@ async def test_tdigest_revrank(decoded_r: redis.Redis):
476455
assert [-1, 19, 9] == await decoded_r.tdigest().revrank("t-digest", 21, 0, 10)
477456

478457

479-
@pytest.mark.redismod
480458
@pytest.mark.experimental
481459
async def test_tdigest_byrank(decoded_r: redis.Redis):
482460
assert await decoded_r.tdigest().create("t-digest", 500)
@@ -488,7 +466,6 @@ async def test_tdigest_byrank(decoded_r: redis.Redis):
488466
(await decoded_r.tdigest().byrank("t-digest", -1))[0]
489467

490468

491-
@pytest.mark.redismod
492469
@pytest.mark.experimental
493470
async def test_tdigest_byrevrank(decoded_r: redis.Redis):
494471
assert await decoded_r.tdigest().create("t-digest", 500)
@@ -500,8 +477,7 @@ async def test_tdigest_byrevrank(decoded_r: redis.Redis):
500477
(await decoded_r.tdigest().byrevrank("t-digest", -1))[0]
501478

502479

503-
# @pytest.mark.redismod
504-
# async def test_pipeline(decoded_r: redis.Redis):
480+
# # async def test_pipeline(decoded_r: redis.Redis):
505481
# pipeline = await decoded_r.bf().pipeline()
506482
# assert not await decoded_r.bf().execute_command("get pipeline")
507483
#

tests/test_asyncio/test_graph.py

-20
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
from tests.conftest import skip_if_redis_enterprise
77

88

9-
@pytest.mark.redismod
109
async def test_bulk(decoded_r):
1110
with pytest.raises(NotImplementedError):
1211
await decoded_r.graph().bulk()
1312
await decoded_r.graph().bulk(foo="bar!")
1413

1514

16-
@pytest.mark.redismod
1715
async def test_graph_creation(decoded_r: redis.Redis):
1816
graph = decoded_r.graph()
1917

@@ -58,7 +56,6 @@ async def test_graph_creation(decoded_r: redis.Redis):
5856
await graph.delete()
5957

6058

61-
@pytest.mark.redismod
6259
async def test_array_functions(decoded_r: redis.Redis):
6360
graph = decoded_r.graph()
6461

@@ -81,7 +78,6 @@ async def test_array_functions(decoded_r: redis.Redis):
8178
assert [a] == result.result_set[0][0]
8279

8380

84-
@pytest.mark.redismod
8581
async def test_path(decoded_r: redis.Redis):
8682
node0 = Node(node_id=0, label="L1")
8783
node1 = Node(node_id=1, label="L1")
@@ -101,7 +97,6 @@ async def test_path(decoded_r: redis.Redis):
10197
assert expected_results == result.result_set
10298

10399

104-
@pytest.mark.redismod
105100
async def test_param(decoded_r: redis.Redis):
106101
params = [1, 2.3, "str", True, False, None, [0, 1, 2]]
107102
query = "RETURN $param"
@@ -111,7 +106,6 @@ async def test_param(decoded_r: redis.Redis):
111106
assert expected_results == result.result_set
112107

113108

114-
@pytest.mark.redismod
115109
async def test_map(decoded_r: redis.Redis):
116110
query = "RETURN {a:1, b:'str', c:NULL, d:[1,2,3], e:True, f:{x:1, y:2}}"
117111

@@ -128,7 +122,6 @@ async def test_map(decoded_r: redis.Redis):
128122
assert actual == expected
129123

130124

131-
@pytest.mark.redismod
132125
async def test_point(decoded_r: redis.Redis):
133126
query = "RETURN point({latitude: 32.070794860, longitude: 34.820751118})"
134127
expected_lat = 32.070794860
@@ -145,7 +138,6 @@ async def test_point(decoded_r: redis.Redis):
145138
assert abs(actual["longitude"] - expected_lon) < 0.001
146139

147140

148-
@pytest.mark.redismod
149141
async def test_index_response(decoded_r: redis.Redis):
150142
result_set = await decoded_r.graph().query("CREATE INDEX ON :person(age)")
151143
assert 1 == result_set.indices_created
@@ -160,7 +152,6 @@ async def test_index_response(decoded_r: redis.Redis):
160152
await decoded_r.graph().query("DROP INDEX ON :person(age)")
161153

162154

163-
@pytest.mark.redismod
164155
async def test_stringify_query_result(decoded_r: redis.Redis):
165156
graph = decoded_r.graph()
166157

@@ -214,7 +205,6 @@ async def test_stringify_query_result(decoded_r: redis.Redis):
214205
await graph.delete()
215206

216207

217-
@pytest.mark.redismod
218208
async def test_optional_match(decoded_r: redis.Redis):
219209
# Build a graph of form (a)-[R]->(b)
220210
node0 = Node(node_id=0, label="L1", properties={"value": "a"})
@@ -239,7 +229,6 @@ async def test_optional_match(decoded_r: redis.Redis):
239229
await graph.delete()
240230

241231

242-
@pytest.mark.redismod
243232
async def test_cached_execution(decoded_r: redis.Redis):
244233
await decoded_r.graph().query("CREATE ()")
245234

@@ -259,7 +248,6 @@ async def test_cached_execution(decoded_r: redis.Redis):
259248
assert cached_result.cached_execution
260249

261250

262-
@pytest.mark.redismod
263251
async def test_slowlog(decoded_r: redis.Redis):
264252
create_query = """CREATE
265253
(:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}),
@@ -272,7 +260,6 @@ async def test_slowlog(decoded_r: redis.Redis):
272260
assert results[0][2] == create_query
273261

274262

275-
@pytest.mark.redismod
276263
@pytest.mark.xfail(strict=False)
277264
async def test_query_timeout(decoded_r: redis.Redis):
278265
# Build a sample graph with 1000 nodes.
@@ -287,7 +274,6 @@ async def test_query_timeout(decoded_r: redis.Redis):
287274
assert False is False
288275

289276

290-
@pytest.mark.redismod
291277
async def test_read_only_query(decoded_r: redis.Redis):
292278
with pytest.raises(Exception):
293279
# Issue a write query, specifying read-only true,
@@ -296,7 +282,6 @@ async def test_read_only_query(decoded_r: redis.Redis):
296282
assert False is False
297283

298284

299-
@pytest.mark.redismod
300285
async def test_profile(decoded_r: redis.Redis):
301286
q = """UNWIND range(1, 3) AS x CREATE (p:Person {v:x})"""
302287
profile = (await decoded_r.graph().profile(q)).result_set
@@ -311,7 +296,6 @@ async def test_profile(decoded_r: redis.Redis):
311296
assert "Node By Label Scan | (p:Person) | Records produced: 3" in profile
312297

313298

314-
@pytest.mark.redismod
315299
@skip_if_redis_enterprise()
316300
async def test_config(decoded_r: redis.Redis):
317301
config_name = "RESULTSET_SIZE"
@@ -343,7 +327,6 @@ async def test_config(decoded_r: redis.Redis):
343327
await decoded_r.graph().config("RESULTSET_SIZE", -100, set=True)
344328

345329

346-
@pytest.mark.redismod
347330
@pytest.mark.onlynoncluster
348331
async def test_list_keys(decoded_r: redis.Redis):
349332
result = await decoded_r.graph().list_keys()
@@ -367,7 +350,6 @@ async def test_list_keys(decoded_r: redis.Redis):
367350
assert result == []
368351

369352

370-
@pytest.mark.redismod
371353
async def test_multi_label(decoded_r: redis.Redis):
372354
redis_graph = decoded_r.graph("g")
373355

@@ -393,7 +375,6 @@ async def test_multi_label(decoded_r: redis.Redis):
393375
assert True
394376

395377

396-
@pytest.mark.redismod
397378
async def test_execution_plan(decoded_r: redis.Redis):
398379
redis_graph = decoded_r.graph("execution_plan")
399380
create_query = """CREATE
@@ -412,7 +393,6 @@ async def test_execution_plan(decoded_r: redis.Redis):
412393
await redis_graph.delete()
413394

414395

415-
@pytest.mark.redismod
416396
async def test_explain(decoded_r: redis.Redis):
417397
redis_graph = decoded_r.graph("execution_plan")
418398
# graph creation / population

0 commit comments

Comments
 (0)