Skip to content

Commit 98bdb21

Browse files
author
DvirDukhan
authored
Merge pull request #804 from RedisAI/update_cluster_tests
Update cluster tests
2 parents c203786 + d74d953 commit 98bdb21

19 files changed

+334
-327
lines changed

src/redis_ai_objects/script.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ int RedisAI_ScriptRun_IsKeysPositionRequest_ReportKeys(RedisModuleCtx *ctx,
120120
if (!strcasecmp(str, "OUTPUTS")) {
121121
continue;
122122
}
123+
if (!strcasecmp(str, "$")) {
124+
continue;
125+
}
123126
RedisModule_KeyAtPos(ctx, argpos);
124127
}
125128
return REDISMODULE_OK;

src/redisai.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,8 +1420,8 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
14201420
REDISMODULE_ERR)
14211421
return REDISMODULE_ERR;
14221422

1423-
if (RedisModule_CreateCommand(ctx, "ai.config", RedisAI_Config_RedisCommand, "write", 1, 1,
1424-
1) == REDISMODULE_ERR)
1423+
if (RedisModule_CreateCommand(ctx, "ai.config", RedisAI_Config_RedisCommand, "write", 0, 0,
1424+
0) == REDISMODULE_ERR)
14251425
return REDISMODULE_ERR;
14261426

14271427
if (RedisModule_CreateCommand(ctx, "ai.dagrun", RedisAI_DagRun_RedisCommand,

tests/flow/includes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ def run_mobilenet(con, img, input_var, output_var):
193193
'INPUTS', 1, 'input{1}', 'OUTPUTS', 1, 'output{1}')
194194

195195

196-
def run_test_multiproc(env, n_procs, fn, args=tuple()):
196+
def run_test_multiproc(env, routing_hint, n_procs, fn, args=tuple()):
197197
procs = []
198198

199199
def tmpfn():
200-
con = env.getConnection()
200+
con = env.getConnectionByKey(routing_hint, None)
201201
fn(con, *args)
202202
return 1
203203

@@ -245,3 +245,7 @@ def get_info_section(con, section):
245245
section_ind = [i for i in range(len(sections)) if sections[i] == 'ai_'+section][0]
246246
return {k.split(":")[0]: k.split(":")[1]
247247
for k in con.execute_command("INFO MODULES").decode().split("#")[section_ind+2].split()[1:]}
248+
249+
250+
def get_connection(env, routing_hint):
251+
return env.getConnectionByKey(routing_hint, None)

tests/flow/test_serializations.py

Lines changed: 29 additions & 29 deletions
Large diffs are not rendered by default.

tests/flow/test_torchscript_extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self):
1818
sys._getframe().f_code.co_name), force=True)
1919
self.env.skip()
2020

21-
self.con = self.env.getConnection()
21+
self.con = get_connection(self.env, '{1}')
2222
script = load_file_content('redis_scripts.py')
2323
ret = self.con.execute_command(
2424
'AI.SCRIPTSTORE', 'redis_scripts{1}', DEVICE, 'ENTRY_POINTS', 13,

tests/flow/tests_commands.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_modelstore_errors(env):
1616
env.debugPrint("skipping {} since TEST_PT=0".format(sys._getframe().f_code.co_name), force=True)
1717
return
1818

19-
con = env.getConnection()
19+
con = get_connection(env, '{1}')
2020
model_pb = load_file_content('pt-minimal.pt')
2121

2222
# Check that the basic arguments are valid (model's key, device, backend, blob)
@@ -59,7 +59,7 @@ def test_modelget_errors(env):
5959
env.debugPrint("Skipping test since TF is not available", force=True)
6060
return
6161

62-
con = env.getConnection()
62+
con = get_connection(env, '{1}')
6363
# ERR WRONGTYPE
6464
con.execute_command('SET', 'NOT_MODEL{1}', 'BAR')
6565
check_error_message(env, con, "WRONGTYPE Operation against a key holding the wrong kind of value",
@@ -77,7 +77,7 @@ def test_modelexecute_errors(env):
7777
if not TEST_TF:
7878
env.debugPrint("Skipping test since TF is not available", force=True)
7979
return
80-
con = env.getConnection()
80+
con = get_connection(env, '{1}')
8181

8282
model_pb = load_file_content('graph.pb')
8383
ret = con.execute_command('AI.MODELSTORE', 'm{1}', 'TF', DEVICE,
@@ -125,7 +125,7 @@ def test_modelexecute_errors(env):
125125
'AI.MODELEXECUTE', 'm{1}', 'INPUTS', 2, 'a{1}', 'b{1}', 'OUTPUTS', 1, 'c{1}', 'TIMEOUT', 1000, 'bad_arg')
126126

127127
con.execute_command('AI.TENSORSET', 'a{1}', 'FLOAT', 2, 2, 'VALUES', 2, 3, 2, 3)
128-
con.execute_command('AI.TENSORSET', 'b', 'FLOAT', 2, 2, 'VALUES', 2, 3, 2, 3)
128+
con.execute_command('AI.TENSORSET', 'b{1}', 'FLOAT', 2, 2, 'VALUES', 2, 3, 2, 3)
129129

130130
# The following 2 commands should raise an error on cluster mode (keys are not on the same shard)
131131
if env.isCluster():
@@ -141,7 +141,7 @@ def test_keys_syntax(env):
141141
return
142142
# the KEYS keyword must appears in every AI.SCRIPTEXECUTE command, an may appear in AI.DAGEXECUTE(_RO) command.
143143

144-
con = env.getConnection()
144+
con = get_connection(env, '{1}')
145145
script = load_file_content('script.txt')
146146
ret = con.execute_command('AI.SCRIPTSTORE', 'script{1}', DEVICE, 'ENTRY_POINTS', 2, 'bar', 'bar_variadic', 'SOURCE', script)
147147
env.assertEqual(ret, b'OK')
@@ -171,7 +171,7 @@ def test_scriptstore(env):
171171
env.debugPrint("skipping {} since TEST_PT=0".format(sys._getframe().f_code.co_name), force=True)
172172
return
173173

174-
con = env.getConnection()
174+
con = get_connection(env, '{1}')
175175
script = load_file_content('script.txt')
176176

177177
ret = con.execute_command('AI.SCRIPTSTORE', 'ket{1}', DEVICE, 'ENTRY_POINTS', 2, 'bar', 'bar_variadic', 'SOURCE', script)
@@ -189,18 +189,18 @@ def test_scriptstore_errors(env):
189189
env.debugPrint("skipping {} since TEST_PT=0".format(sys._getframe().f_code.co_name), force=True)
190190
return
191191

192-
con = env.getConnection()
192+
con = get_connection(env, '{1}')
193193
script = load_file_content('script.txt')
194194
old_script = load_file_content('old_script.txt')
195195
bad_script = load_file_content('script_bad.txt')
196196

197197
check_error_message(env, con, "wrong number of arguments for 'AI.SCRIPTSTORE' command", 'AI.SCRIPTSTORE', 'ket{1}', DEVICE, 'SOURCE', 'return 1')
198198

199-
check_error_message(env, con, "wrong number of arguments for 'AI.SCRIPTSTORE' command", 'AI.SCRIPTSTORE', 'nope')
199+
check_error_message(env, con, "wrong number of arguments for 'AI.SCRIPTSTORE' command", 'AI.SCRIPTSTORE', 'nope{1}')
200200

201-
check_error_message(env, con, "wrong number of arguments for 'AI.SCRIPTSTORE' command", 'AI.SCRIPTSTORE', 'nope', 'SOURCE')
201+
check_error_message(env, con, "wrong number of arguments for 'AI.SCRIPTSTORE' command", 'AI.SCRIPTSTORE', 'nope{1}', 'SOURCE')
202202

203-
check_error_message(env, con, "wrong number of arguments for 'AI.SCRIPTSTORE' command", 'AI.SCRIPTSTORE', 'more', DEVICE)
203+
check_error_message(env, con, "wrong number of arguments for 'AI.SCRIPTSTORE' command", 'AI.SCRIPTSTORE', 'more{1}', DEVICE)
204204

205205
check_error_message(env, con, "Insufficient arguments, missing script entry points", 'AI.SCRIPTSTORE', 'ket{1}', DEVICE, 'NO_ENTRY_POINTS', 2, 'bar', 'bar_variadic', 'SOURCE', script)
206206

@@ -222,7 +222,7 @@ def test_pytrorch_scriptget_errors(env):
222222
env.debugPrint("skipping {} since TEST_PT=0".format(sys._getframe().f_code.co_name), force=True)
223223
return
224224

225-
con = env.getConnection()
225+
con = get_connection(env, '{1}')
226226

227227
script = load_file_content('script.txt')
228228

@@ -249,7 +249,7 @@ def test_pytorch_scriptexecute_errors(env):
249249
env.debugPrint("skipping {} since TEST_PT=0".format(sys._getframe().f_code.co_name), force=True)
250250
return
251251

252-
con = env.getConnection()
252+
con = get_connection(env, '{1}')
253253

254254
script = load_file_content('script.txt')
255255

@@ -307,7 +307,7 @@ def test_pytorch_scriptexecute_variadic_errors(env):
307307
env.debugPrint("skipping {} since TEST_PT=0".format(sys._getframe().f_code.co_name), force=True)
308308
return
309309

310-
con = env.getConnection()
310+
con = get_connection(env, '{1}')
311311

312312
script = load_file_content('script.txt')
313313

0 commit comments

Comments
 (0)