diff --git a/tests/cluster/tests/04-resharding.tcl b/tests/cluster/tests/04-resharding.tcl index ff11119ccd..4cf59d82c7 100644 --- a/tests/cluster/tests/04-resharding.tcl +++ b/tests/cluster/tests/04-resharding.tcl @@ -110,7 +110,7 @@ test "Cluster consistency during live resharding" { } elseif {$listid % 3 == 1} { $cluster_plaintext rpush $key $ele } else { - $cluster eval {redis.call("rpush",KEYS[1],ARGV[1])} 1 $key $ele + $cluster eval {server.call("rpush",KEYS[1],ARGV[1])} 1 $key $ele } lappend content($key) $ele diff --git a/tests/integration/aof.tcl b/tests/integration/aof.tcl index 72fae9915b..302827f589 100644 --- a/tests/integration/aof.tcl +++ b/tests/integration/aof.tcl @@ -436,7 +436,7 @@ tags {"aof external:skip"} { # make sure that the script times out during loading create_aof $aof_dirpath $aof_file { append_to_aof [formatCommand select 9] - append_to_aof [formatCommand eval {redis.call('set',KEYS[1],'y'); for i=1,1500000 do redis.call('ping') end return 'ok'} 1 x] + append_to_aof [formatCommand eval {server.call('set',KEYS[1],'y'); for i=1,1500000 do server.call('ping') end return 'ok'} 1 x] } set rd [valkey_deferring_client] $rd debug loadaof @@ -460,9 +460,9 @@ tags {"aof external:skip"} { } create_aof $aof_dirpath $aof_file { append_to_aof [formatCommand select 9] - append_to_aof [formatCommand eval {redis.call("set",KEYS[1],"100")} 1 foo] - append_to_aof [formatCommand eval {redis.call("incr",KEYS[1])} 1 foo] - append_to_aof [formatCommand eval {redis.call("incr",KEYS[1])} 1 foo] + append_to_aof [formatCommand eval {server.call("set",KEYS[1],"100")} 1 foo] + append_to_aof [formatCommand eval {server.call("incr",KEYS[1])} 1 foo] + append_to_aof [formatCommand eval {server.call("incr",KEYS[1])} 1 foo] } start_server [list overrides [list dir $server_path appendonly yes replica-read-only yes replicaof "127.0.0.1 0"]] { assert_equal [r get foo] 102 diff --git a/tests/integration/rdb.tcl b/tests/integration/rdb.tcl index e3f92bf521..f517e253a9 100644 --- a/tests/integration/rdb.tcl +++ b/tests/integration/rdb.tcl @@ -361,7 +361,7 @@ start_server {overrides {save ""}} { exec cp -f tests/assets/scriptbackup.rdb $server_path start_server [list overrides [list "dir" $server_path "dbfilename" "scriptbackup.rdb" "appendonly" "no"]] { - # the script is: "return redis.call('set', 'foo', 'bar')"" + # the script is: "return server.call('set', 'foo', 'bar')"" # its sha1 is: a0c38691e9fffe4563723c32ba77a34398e090e6 test {script won't load anymore if it's in rdb} { assert_equal [r script exists a0c38691e9fffe4563723c32ba77a34398e090e6] 0 @@ -389,21 +389,21 @@ start_server {} { # repeat with script assert_error {MISCONF *} {r eval { - return redis.call('set','x',1) + return server.call('set','x',1) } 1 x } assert_equal {x} [r eval { - return redis.call('get','x') + return server.call('get','x') } 1 x ] # again with script using shebang assert_error {MISCONF *} {r eval {#!lua - return redis.call('set','x',1) + return server.call('set','x',1) } 1 x } assert_equal {x} [r eval {#!lua flags=no-writes - return redis.call('get','x') + return server.call('get','x') } 1 x ] diff --git a/tests/integration/replication-4.tcl b/tests/integration/replication-4.tcl index d5b55b3b57..8a7790b0c4 100644 --- a/tests/integration/replication-4.tcl +++ b/tests/integration/replication-4.tcl @@ -61,8 +61,8 @@ start_server {tags {"repl external:skip"}} { # Load some functions to be used later $master FUNCTION load replace {#!lua name=test - server.register_function{function_name='f_default_flags', callback=function(keys, args) return redis.call('get',keys[1]) end, flags={}} - server.register_function{function_name='f_no_writes', callback=function(keys, args) return redis.call('get',keys[1]) end, flags={'no-writes'}} + server.register_function{function_name='f_default_flags', callback=function(keys, args) return server.call('get',keys[1]) end, flags={}} + server.register_function{function_name='f_no_writes', callback=function(keys, args) return server.call('get',keys[1]) end, flags={'no-writes'}} } test {First server should have role slave after SLAVEOF} { @@ -74,14 +74,14 @@ start_server {tags {"repl external:skip"}} { $master config set min-slaves-max-lag 3 $master config set min-slaves-to-write 1 assert_equal OK [$master set foo 123] - assert_equal OK [$master eval "return redis.call('set','foo',12345)" 0] + assert_equal OK [$master eval "return server.call('set','foo',12345)" 0] } test {With min-slaves-to-write (2,3): master should not be writable} { $master config set min-slaves-max-lag 3 $master config set min-slaves-to-write 2 assert_error "*NOREPLICAS*" {$master set foo bar} - assert_error "*NOREPLICAS*" {$master eval "redis.call('set','foo','bar')" 0} + assert_error "*NOREPLICAS*" {$master eval "server.call('set','foo','bar')" 0} } test {With min-slaves-to-write function without no-write flag} { @@ -92,17 +92,17 @@ start_server {tags {"repl external:skip"}} { test {With not enough good slaves, read in Lua script is still accepted} { $master config set min-slaves-max-lag 3 $master config set min-slaves-to-write 1 - $master eval "redis.call('set','foo','bar')" 0 + $master eval "server.call('set','foo','bar')" 0 $master config set min-slaves-to-write 2 - $master eval "return redis.call('get','foo')" 0 + $master eval "return server.call('get','foo')" 0 } {bar} test {With min-slaves-to-write: master not writable with lagged slave} { $master config set min-slaves-max-lag 2 $master config set min-slaves-to-write 1 assert_equal OK [$master set foo 123] - assert_equal OK [$master eval "return redis.call('set','foo',12345)" 0] + assert_equal OK [$master eval "return server.call('set','foo',12345)" 0] # Killing a slave to make it become a lagged slave. pause_process [srv 0 pid] # Waiting for slave kill. @@ -112,7 +112,7 @@ start_server {tags {"repl external:skip"}} { fail "Master didn't become readonly" } assert_error "*NOREPLICAS*" {$master set foo 123} - assert_error "*NOREPLICAS*" {$master eval "return redis.call('set','foo',12345)" 0} + assert_error "*NOREPLICAS*" {$master eval "return server.call('set','foo',12345)" 0} resume_process [srv 0 pid] } } diff --git a/tests/integration/replication.tcl b/tests/integration/replication.tcl index b175f4ff34..4b031f7878 100644 --- a/tests/integration/replication.tcl +++ b/tests/integration/replication.tcl @@ -254,12 +254,12 @@ start_server {tags {"repl external:skip"}} { # DB is empty. r -1 flushdb r -1 flushdb - r -1 eval {redis.call("flushdb")} 0 + r -1 eval {server.call("flushdb")} 0 # DBs are empty. r -1 flushall r -1 flushall - r -1 eval {redis.call("flushall")} 0 + r -1 eval {server.call("flushall")} 0 # add another command to check nothing else was propagated after the above r -1 incr x diff --git a/tests/modules/propagate.c b/tests/modules/propagate.c index b3cd279e5a..99078904d8 100644 --- a/tests/modules/propagate.c +++ b/tests/modules/propagate.c @@ -159,7 +159,7 @@ void timerHandlerEval(ValkeyModuleCtx *ctx, void *data) { ValkeyModuleCallReply *reply = ValkeyModule_Call(ctx,"INCRBY","cc!","timer-eval-start","1"); ValkeyModule_FreeCallReply(reply); - reply = ValkeyModule_Call(ctx, "EVAL", "cccc!", "redis.call('set',KEYS[1],ARGV[1])", "1", "foo", "bar"); + reply = ValkeyModule_Call(ctx, "EVAL", "cccc!", "server.call('set',KEYS[1],ARGV[1])", "1", "foo", "bar"); ValkeyModule_FreeCallReply(reply); ValkeyModule_Replicate(ctx, "INCR", "c", "timer-eval-middle"); diff --git a/tests/unit/acl.tcl b/tests/unit/acl.tcl index a05359d7c9..0cf13e8b46 100644 --- a/tests/unit/acl.tcl +++ b/tests/unit/acl.tcl @@ -774,7 +774,7 @@ start_server {tags {"acl external:skip"}} { test {ACL can log errors in the context of Lua scripting} { r AUTH antirez foo - catch {r EVAL {redis.call('incr','foo')} 0} + catch {r EVAL {server.call('incr','foo')} 0} r AUTH default "" set entry [lindex [r ACL LOG] 0] assert {[dict get $entry context] eq {lua}} diff --git a/tests/unit/client-eviction.tcl b/tests/unit/client-eviction.tcl index ceeb20f7b6..abbcb4b01d 100644 --- a/tests/unit/client-eviction.tcl +++ b/tests/unit/client-eviction.tcl @@ -223,7 +223,7 @@ start_server {} { set key_length [expr 1024*200] set long_key [string repeat k $key_length] # Use a script so we won't need to pass the long key name when dirtying it in the loop - set script_sha [$rr script load "redis.call('incr', '$long_key')"] + set script_sha [$rr script load "server.call('incr', '$long_key')"] # Pause serverCron so it won't update memory usage since we're testing the update logic when # writing tracking redirection output diff --git a/tests/unit/cluster/scripting.tcl b/tests/unit/cluster/scripting.tcl index 1cf1421079..bef6eff2e7 100644 --- a/tests/unit/cluster/scripting.tcl +++ b/tests/unit/cluster/scripting.tcl @@ -4,16 +4,16 @@ start_cluster 1 0 {tags {external:skip cluster}} { # Test that scripts with shebang block cross slot operations assert_error "ERR Script attempted to access keys that do not hash to the same slot*" { r 0 eval {#!lua - redis.call('set', 'foo', 'bar') - redis.call('set', 'bar', 'foo') + server.call('set', 'foo', 'bar') + server.call('set', 'bar', 'foo') return 'OK' } 0} # Test the functions by default block cross slot operations r 0 function load REPLACE {#!lua name=crossslot local function test_cross_slot(keys, args) - redis.call('set', 'foo', 'bar') - redis.call('set', 'bar', 'foo') + server.call('set', 'foo', 'bar') + server.call('set', 'bar', 'foo') return 'OK' end @@ -23,11 +23,11 @@ start_cluster 1 0 {tags {external:skip cluster}} { test {Cross slot commands are allowed by default for eval scripts and with allow-cross-slot-keys flag} { # Old style lua scripts are allowed to access cross slot operations - r 0 eval "redis.call('set', 'foo', 'bar'); redis.call('set', 'bar', 'foo')" 0 + r 0 eval "server.call('set', 'foo', 'bar'); server.call('set', 'bar', 'foo')" 0 # scripts with allow-cross-slot-keys flag are allowed r 0 eval {#!lua flags=allow-cross-slot-keys - redis.call('set', 'foo', 'bar'); redis.call('set', 'bar', 'foo') + server.call('set', 'foo', 'bar'); server.call('set', 'bar', 'foo') } 0 # Retrieve data from different slot to verify data has been stored in the correct dictionary in cluster-enabled setup @@ -40,8 +40,8 @@ start_cluster 1 0 {tags {external:skip cluster}} { # Functions with allow-cross-slot-keys flag are allowed r 0 function load REPLACE {#!lua name=crossslot local function test_cross_slot(keys, args) - redis.call('set', 'foo', 'bar') - redis.call('set', 'bar', 'foo') + server.call('set', 'foo', 'bar') + server.call('set', 'bar', 'foo') return 'OK' end @@ -57,14 +57,14 @@ start_cluster 1 0 {tags {external:skip cluster}} { test {Cross slot commands are also blocked if they disagree with pre-declared keys} { assert_error "ERR Script attempted to access keys that do not hash to the same slot*" { r 0 eval {#!lua - redis.call('set', 'foo', 'bar') + server.call('set', 'foo', 'bar') return 'OK' } 1 bar} } test {Cross slot commands are allowed by default if they disagree with pre-declared keys} { r 0 flushall - r 0 eval "redis.call('set', 'foo', 'bar')" 1 bar + r 0 eval "server.call('set', 'foo', 'bar')" 1 bar # Make sure the script writes to the right slot assert_equal 1 [r 0 cluster COUNTKEYSINSLOT 12182] ;# foo slot diff --git a/tests/unit/functions.tcl b/tests/unit/functions.tcl index 6a720419d3..f8d962f214 100644 --- a/tests/unit/functions.tcl +++ b/tests/unit/functions.tcl @@ -145,7 +145,7 @@ start_server {tags {"scripting"}} { test {FUNCTION - test flushall and flushdb do not clean functions} { r function flush - r function load REPLACE [get_function_code lua test test {return redis.call('set', 'x', '1')}] + r function load REPLACE [get_function_code lua test test {return server.call('set', 'x', '1')}] r flushall r flushdb r function list @@ -209,19 +209,19 @@ start_server {tags {"scripting"}} { } {*unknown subcommand or wrong number of arguments for 'restore'. Try FUNCTION HELP.} test {FUNCTION - test fcall_ro with write command} { - r function load REPLACE [get_no_writes_function_code lua test test {return redis.call('set', 'x', '1')}] + r function load REPLACE [get_no_writes_function_code lua test test {return server.call('set', 'x', '1')}] catch { r fcall_ro test 1 x } e set _ $e } {*Write commands are not allowed from read-only scripts*} test {FUNCTION - test fcall_ro with read only commands} { - r function load REPLACE [get_no_writes_function_code lua test test {return redis.call('get', 'x')}] + r function load REPLACE [get_no_writes_function_code lua test test {return server.call('get', 'x')}] r set x 1 r fcall_ro test 1 x } {1} test {FUNCTION - test keys and argv} { - r function load REPLACE [get_function_code lua test test {return redis.call('set', KEYS[1], ARGV[1])}] + r function load REPLACE [get_function_code lua test test {return server.call('set', KEYS[1], ARGV[1])}] r fcall test 1 x foo r get x } {foo} @@ -410,7 +410,7 @@ start_server {tags {"scripting repl external:skip"}} { } {*can't write against a read only replica*} test "FUNCTION - function effect is replicated to replica" { - r function load REPLACE [get_function_code LUA test test {return redis.call('set', 'x', '1')}] + r function load REPLACE [get_function_code LUA test test {return server.call('set', 'x', '1')}] r fcall test 1 x assert {[r get x] eq {1}} wait_for_condition 150 100 { @@ -461,7 +461,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - test shared function can access default globals} { r function load {#!lua name=lib1 local function ping() - return redis.call('ping') + return server.call('ping') end server.register_function( 'f1', @@ -618,10 +618,10 @@ start_server {tags {"scripting"}} { set _ $e } {*attempted to access nonexistent global variable 'math'*} - test {LIBRARIES - redis.call from function load} { + test {LIBRARIES - server.call from function load} { catch { r function load replace {#!lua name=lib2 - return redis.call('ping') + return server.call('ping') } } e set _ $e @@ -688,9 +688,9 @@ start_server {tags {"scripting"}} { assert_match {*Script attempted to access nonexistent global variable 'math'*} $e catch {[r function load {#!lua name=lib2 - redis.redis.call('ping') + redis.server.call('ping') }]} e - assert_match {*Script attempted to access nonexistent global variable 'redis'*} $e + assert_match {*Script attempted to access nonexistent global variable 'server'*} $e catch {[r fcall f2 0]} e assert_match {*can only be called on FUNCTION LOAD command*} $e @@ -983,7 +983,7 @@ start_server {tags {"scripting"}} { r FUNCTION load replace {#!lua name=f1 server.register_function{ function_name='f1', - callback=function() return redis.call('set', 'x', '1') end, + callback=function() return server.call('set', 'x', '1') end, flags={'allow-oom'} } } @@ -1035,7 +1035,7 @@ start_server {tags {"scripting"}} { r function load replace {#!lua name=test server.register_function{ function_name = 'f1', - callback = function() return redis.call('set', 'x', 1) end + callback = function() return server.call('set', 'x', 1) end } } catch {r fcall_ro f1 1 x} e @@ -1046,7 +1046,7 @@ start_server {tags {"scripting"}} { r function load replace {#!lua name=test server.register_function{ function_name = 'f1', - callback = function() return redis.call('set', 'x', 1) end, + callback = function() return server.call('set', 'x', 1) end, flags = {'no-writes'} } } @@ -1056,7 +1056,7 @@ start_server {tags {"scripting"}} { test {FUNCTION - deny oom} { r FUNCTION load replace {#!lua name=test - server.register_function('f1', function() return redis.call('set', 'x', '1') end) + server.register_function('f1', function() return server.call('set', 'x', '1') end) } r config set maxmemory 1 @@ -1084,8 +1084,8 @@ start_server {tags {"scripting"}} { r FUNCTION load replace {#!lua name=test server.register_function{function_name='f1', callback=function() return 'hello' end, flags={'no-writes'}} server.register_function{function_name='f2', callback=function() return 'hello' end, flags={'allow-stale', 'no-writes'}} - server.register_function{function_name='f3', callback=function() return redis.call('get', 'x') end, flags={'allow-stale', 'no-writes'}} - server.register_function{function_name='f4', callback=function() return redis.call('info', 'server') end, flags={'allow-stale', 'no-writes'}} + server.register_function{function_name='f3', callback=function() return server.call('get', 'x') end, flags={'allow-stale', 'no-writes'}} + server.register_function{function_name='f4', callback=function() return server.call('info', 'server') end, flags={'allow-stale', 'no-writes'}} } r config set replica-serve-stale-data no diff --git a/tests/unit/introspection-2.tcl b/tests/unit/introspection-2.tcl index b8f4e0aed4..9d1c213ad2 100644 --- a/tests/unit/introspection-2.tcl +++ b/tests/unit/introspection-2.tcl @@ -108,9 +108,9 @@ start_server {tags {"introspection"}} { r config resetstat r set mykey myval r eval { - redis.call('set', KEYS[1], 0) - redis.call('expire', KEYS[1], 0) - redis.call('geoadd', KEYS[1], 0, 0, "bar") + server.call('set', KEYS[1], 0) + server.call('expire', KEYS[1], 0) + server.call('geoadd', KEYS[1], 0, 0, "bar") } 1 mykey assert_match {*calls=1,*} [cmdstat eval] assert_match {*calls=2,*} [cmdstat set] diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl index 6d0e48e39c..3e871c3df6 100644 --- a/tests/unit/introspection.tcl +++ b/tests/unit/introspection.tcl @@ -303,7 +303,7 @@ start_server {tags {"introspection"}} { set rd [valkey_deferring_client] $rd monitor $rd read ;# Discard the OK - r eval {redis.call('set',KEYS[1],ARGV[1])} 1 foo bar + r eval {server.call('set',KEYS[1],ARGV[1])} 1 foo bar assert_match {*eval*} [$rd read] assert_match {*lua*"set"*"foo"*"bar"*} [$rd read] $rd close @@ -311,7 +311,7 @@ start_server {tags {"introspection"}} { test {MONITOR can log commands issued by functions} { r function load replace {#!lua name=test - server.register_function('test', function() return redis.call('set', 'foo', 'bar') end) + server.register_function('test', function() return server.call('set', 'foo', 'bar') end) } set rd [valkey_deferring_client] $rd monitor diff --git a/tests/unit/latency-monitor.tcl b/tests/unit/latency-monitor.tcl index 9048192a44..0e897e9eb3 100644 --- a/tests/unit/latency-monitor.tcl +++ b/tests/unit/latency-monitor.tcl @@ -150,7 +150,7 @@ tags {"needs:debug"} { r eval { local i = 0 while (i < tonumber(ARGV[1])) do - redis.call('sadd',KEYS[1],i) + server.call('sadd',KEYS[1],i) i = i+1 end } 1 mybigkey $count diff --git a/tests/unit/moduleapi/commandfilter.tcl b/tests/unit/moduleapi/commandfilter.tcl index bad68189a0..e6275c297a 100644 --- a/tests/unit/moduleapi/commandfilter.tcl +++ b/tests/unit/moduleapi/commandfilter.tcl @@ -38,15 +38,15 @@ start_server {tags {"modules"}} { r lrange log-key 0 -1 } "{ping @log}" - test {Command Filter applies on Lua redis.call()} { + test {Command Filter applies on Lua server.call()} { r del log-key - r eval "redis.call('ping', '@log')" 0 + r eval "server.call('ping', '@log')" 0 r lrange log-key 0 -1 } "{ping @log}" - test {Command Filter applies on Lua redis.call() that calls a module} { + test {Command Filter applies on Lua server.call() that calls a module} { r del log-key - r eval "redis.call('commandfilter.ping')" 0 + r eval "server.call('commandfilter.ping')" 0 r lrange log-key 0 -1 } "{ping @log}" @@ -88,7 +88,7 @@ start_server {tags {"modules"}} { r commandfilter.ping assert_equal {} [r lrange log-key 0 -1] - r eval "redis.call('commandfilter.ping')" 0 + r eval "server.call('commandfilter.ping')" 0 assert_equal {} [r lrange log-key 0 -1] } @@ -107,11 +107,11 @@ test {RM_CommandFilterArgInsert and script argv caching} { r module load $testmodule log-key 0 r del mylist # command with 6 args - r eval {redis.call('rpush', KEYS[1], 'elem1', 'elem2', 'elem3', 'elem4')} 1 mylist + r eval {server.call('rpush', KEYS[1], 'elem1', 'elem2', 'elem3', 'elem4')} 1 mylist # command with 3 args that is changed to 4 - r eval {redis.call('rpush', KEYS[1], '@insertafter')} 1 mylist + r eval {server.call('rpush', KEYS[1], '@insertafter')} 1 mylist # command with 6 args again - r eval {redis.call('rpush', KEYS[1], 'elem1', 'elem2', 'elem3', 'elem4')} 1 mylist + r eval {server.call('rpush', KEYS[1], 'elem1', 'elem2', 'elem3', 'elem4')} 1 mylist assert_equal [r lrange mylist 0 -1] {elem1 elem2 elem3 elem4 @insertafter --inserted-after-- elem1 elem2 elem3 elem4} } } diff --git a/tests/unit/moduleapi/misc.tcl b/tests/unit/moduleapi/misc.tcl index 9e0ea72456..60405908e1 100644 --- a/tests/unit/moduleapi/misc.tcl +++ b/tests/unit/moduleapi/misc.tcl @@ -140,7 +140,7 @@ start_server {overrides {save {900 1}} tags {"modules"}} { r MSET key1{t} 1 key2{t} 1 # GET triggers tracking, SET does not - $rd_trk test.rm_call EVAL "redis.call('get', 'key1{t}')" 2 key1{t} key2{t} + $rd_trk test.rm_call EVAL "server.call('get', 'key1{t}')" 2 key1{t} key2{t} r MSET key1{t} 2 key2{t} 2 assert_equal {invalidate key1{t}} [$rd_trk read] assert_equal "PONG" [$rd_trk ping] @@ -247,7 +247,7 @@ start_server {overrides {save {900 1}} tags {"modules"}} { # use the M flag without allow-oom shebang flag assert_error {OOM *} { r test.rm_call_flags M eval {#!lua - redis.call('set','x',1) + server.call('set','x',1) return 1 } 1 x } @@ -255,7 +255,7 @@ start_server {overrides {save {900 1}} tags {"modules"}} { # add the M flag with allow-oom shebang flag assert_equal {1} [ r test.rm_call_flags M eval {#!lua flags=allow-oom - redis.call('set','x',1) + server.call('set','x',1) return 1 } 1 x ] @@ -275,13 +275,13 @@ start_server {overrides {save {900 1}} tags {"modules"}} { test {rm_call EVAL} { r test.rm_call eval { - redis.call('set','x',1) + server.call('set','x',1) return 1 } 1 x assert_error {ERR Write commands are not allowed from read-only scripts.*} { r test.rm_call eval {#!lua flags=no-writes - redis.call('set','x',1) + server.call('set','x',1) return 1 } 1 x } @@ -294,34 +294,34 @@ start_server {overrides {save {900 1}} tags {"modules"}} { # script without shebang, but uses SET, so fails assert_error {*OOM command not allowed when used memory > 'maxmemory'*} { r test.rm_call_flags M eval { - redis.call('set','x',1) + server.call('set','x',1) return 1 } 1 x } # script with an allow-oom flag, succeeds despite using SET r test.rm_call_flags M eval {#!lua flags=allow-oom - redis.call('set','x', 1) + server.call('set','x', 1) return 2 } 1 x # script with no-writes flag, implies allow-oom, succeeds r test.rm_call_flags M eval {#!lua flags=no-writes - redis.call('get','x') + server.call('get','x') return 2 } 1 x # script with shebang using default flags, so fails regardless of using only GET assert_error {*OOM command not allowed when used memory > 'maxmemory'*} { r test.rm_call_flags M eval {#!lua - redis.call('get','x') + server.call('get','x') return 3 } 1 x } # script without shebang, but uses GET, so succeeds r test.rm_call_flags M eval { - redis.call('get','x') + server.call('get','x') return 4 } 1 x @@ -334,19 +334,19 @@ start_server {overrides {save {900 1}} tags {"modules"}} { # no shebang at all r test.rm_call eval { - redis.call('set','x',1) + server.call('set','x',1) return 6 } 1 x # Shebang without flags r test.rm_call eval {#!lua - redis.call('set','x', 1) + server.call('set','x', 1) return 7 } 1 x # with allow-oom flag r test.rm_call eval {#!lua flags=allow-oom - redis.call('set','x', 1) + server.call('set','x', 1) return 8 } 1 x @@ -362,25 +362,25 @@ start_server {overrides {save {900 1}} tags {"modules"}} { assert_equal [ r test.rm_call eval {#!lua flags=no-writes - return redis.call('get','x') + return server.call('get','x') } 1 x ] "some value" assert_equal [ r test.rm_call eval { - return redis.call('get','x') + return server.call('get','x') } 1 x ] "some value" assert_error {NOREPLICAS *} { r test.rm_call eval {#!lua - return redis.call('get','x') + return server.call('get','x') } 1 x } assert_error {NOREPLICAS *} { r test.rm_call eval { - return redis.call('set','x', 1) + return server.call('set','x', 1) } 1 x } @@ -395,25 +395,25 @@ start_server {overrides {save {900 1}} tags {"modules"}} { assert_error {READONLY You can't write against a read only replica. script*} { r test.rm_call eval { - redis.call('set','x',1) + server.call('set','x',1) return 1 } 1 x } r test.rm_call eval {#!lua flags=no-writes - redis.call('get','x') + server.call('get','x') return 2 } 1 x assert_error {READONLY Can not run script with write flag on readonly replica*} { r test.rm_call eval {#!lua - redis.call('get','x') + server.call('get','x') return 3 } 1 x } r test.rm_call eval { - redis.call('get','x') + server.call('get','x') return 4 } 1 x @@ -431,14 +431,14 @@ start_server {overrides {save {900 1}} tags {"modules"}} { assert_error {MASTERDOWN *} { r test.rm_call eval {#!lua flags=no-writes - redis.call('get','x') + server.call('get','x') return 2 } 1 x } assert_error {MASTERDOWN *} { r test.rm_call eval { - redis.call('get','x') + server.call('get','x') return 4 } 1 x } @@ -467,21 +467,21 @@ start_server {overrides {save {900 1}} tags {"modules"}} { # repeat with script assert_error {MISCONF *} {r test.rm_call eval { - return redis.call('set','x',1) + return server.call('set','x',1) } 1 x } assert_equal {x} [r test.rm_call eval { - return redis.call('get','x') + return server.call('get','x') } 1 x ] # again with script using shebang assert_error {MISCONF *} {r test.rm_call eval {#!lua - return redis.call('set','x',1) + return server.call('set','x',1) } 1 x } assert_equal {x} [r test.rm_call eval {#!lua flags=no-writes - return redis.call('get','x') + return server.call('get','x') } 1 x ] diff --git a/tests/unit/moduleapi/propagate.tcl b/tests/unit/moduleapi/propagate.tcl index 89f79998f0..9eaa5c53a6 100644 --- a/tests/unit/moduleapi/propagate.tcl +++ b/tests/unit/moduleapi/propagate.tcl @@ -446,9 +446,9 @@ tags "modules" { set repl [attach_to_replication_stream] assert_equal [ $master eval { \ - redis.call("propagate-test.simple"); \ - redis.call("set", "x", "y"); \ - redis.call("propagate-test.mixed"); return "OK" } 0 ] {OK} + server.call("propagate-test.simple"); \ + server.call("set", "x", "y"); \ + server.call("propagate-test.mixed"); return "OK" } 0 ] {OK} assert_replication_stream $repl { {multi} @@ -731,15 +731,15 @@ tags "modules aof" { r config resetstat r set foo bar - r EVAL {return redis.call('SET', KEYS[1], ARGV[1])} 1 foo bar2 + r EVAL {return server.call('SET', KEYS[1], ARGV[1])} 1 foo bar2 r test.rm_call_replicate set foo bar3 - r EVAL {return redis.call('test.rm_call_replicate',ARGV[1],KEYS[1],ARGV[2])} 1 foo set bar4 + r EVAL {return server.call('test.rm_call_replicate',ARGV[1],KEYS[1],ARGV[2])} 1 foo set bar4 r multi r set foo bar5 - r EVAL {return redis.call('SET', KEYS[1], ARGV[1])} 1 foo bar6 + r EVAL {return server.call('SET', KEYS[1], ARGV[1])} 1 foo bar6 r test.rm_call_replicate set foo bar7 - r EVAL {return redis.call('test.rm_call_replicate',ARGV[1],KEYS[1],ARGV[2])} 1 foo set bar8 + r EVAL {return server.call('test.rm_call_replicate',ARGV[1],KEYS[1],ARGV[2])} 1 foo set bar8 r exec assert_match {*calls=8,*,rejected_calls=0,failed_calls=0} [cmdrstat set r] diff --git a/tests/unit/moduleapi/usercall.tcl b/tests/unit/moduleapi/usercall.tcl index d5cd533be6..9139e1e060 100644 --- a/tests/unit/moduleapi/usercall.tcl +++ b/tests/unit/moduleapi/usercall.tcl @@ -1,11 +1,11 @@ set testmodule [file normalize tests/modules/usercall.so] set test_script_set "#!lua -redis.call('set','x',1) +server.call('set','x',1) return 1" set test_script_get "#!lua -redis.call('get','x') +server.call('get','x') return 1" start_server {tags {"modules usercall"}} { diff --git a/tests/unit/multi.tcl b/tests/unit/multi.tcl index dafbc66c10..db76ffc54e 100644 --- a/tests/unit/multi.tcl +++ b/tests/unit/multi.tcl @@ -754,7 +754,7 @@ start_server {tags {"multi"}} { # make sure that SCRIPT LOAD inside MULTI isn't propagated r multi - r script load {redis.call('set', KEYS[1], 'foo')} + r script load {server.call('set', KEYS[1], 'foo')} r set foo bar set res [r exec] set sha [lindex $res 0] @@ -771,7 +771,7 @@ start_server {tags {"multi"}} { # make sure that EVAL inside MULTI is propagated in a transaction in effects r multi - r eval {redis.call('set', KEYS[1], 'bar')} 1 bar + r eval {server.call('set', KEYS[1], 'bar')} 1 bar r exec assert_replication_stream $repl { diff --git a/tests/unit/pause.tcl b/tests/unit/pause.tcl index 38c13afc46..d7c7b61534 100644 --- a/tests/unit/pause.tcl +++ b/tests/unit/pause.tcl @@ -157,7 +157,7 @@ start_server {tags {"pause network"}} { # test EVAL_RO on a unique script that's for sure not in the cache assert_equal [$rr EVAL_RO { - return redis.call('GeT', 'x')..' unique script' + return server.call('GeT', 'x')..' unique script' } 1 x ] "y unique script" @@ -227,15 +227,15 @@ start_server {tags {"pause network"}} { test "Test may-replicate commands are rejected in RO scripts" { # that's specifically important for CLIENT PAUSE WRITE assert_error {ERR Write commands are not allowed from read-only scripts. script:*} { - r EVAL_RO "return redis.call('publish','ch','msg')" 0 + r EVAL_RO "return server.call('publish','ch','msg')" 0 } assert_error {ERR Write commands are not allowed from read-only scripts. script:*} { r EVAL {#!lua flags=no-writes - return redis.call('publish','ch','msg') + return server.call('publish','ch','msg') } 0 } # make sure that publish isn't blocked from a non-RO script - assert_equal [r EVAL "return redis.call('publish','ch','msg')" 0] 0 + assert_equal [r EVAL "return server.call('publish','ch','msg')" 0] 0 } test "Test multiple clients can be queued up and unblocked" { diff --git a/tests/unit/pubsub.tcl b/tests/unit/pubsub.tcl index 68dc79a4a4..f955ed9ad8 100644 --- a/tests/unit/pubsub.tcl +++ b/tests/unit/pubsub.tcl @@ -465,10 +465,10 @@ start_server {tags {"pubsub network"}} { r hello 3 r subscribe foo set res [r eval { - redis.call("ping","abc") - redis.call("publish","foo","bar") - redis.call("publish","foo","vaz") - redis.call("ping","def") + server.call("ping","abc") + server.call("publish","foo","bar") + server.call("publish","foo","vaz") + server.call("ping","def") return "bla"} 0] assert_equal $res {bla} assert_equal [r read] {message foo bar} diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index 1a73b9d1ab..24f872b7f1 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -1,5 +1,5 @@ foreach is_eval {0 1} { -foreach script_compatibility_api {server redis} { +foreach script_compatibility_api {server valkey} { # We run the tests using both the server APIs, e.g. server.call(), and valkey APIs, e.g. redis.call(), # in order to ensure compatibility. diff --git a/tests/unit/sort.tcl b/tests/unit/sort.tcl index 397e7e12ea..03f6b03f07 100644 --- a/tests/unit/sort.tcl +++ b/tests/unit/sort.tcl @@ -179,8 +179,8 @@ foreach command {SORT SORT_RO} { r zadd zset 10 d r zadd zset 3 e r eval { - return {redis.call('sort',KEYS[1],'by','nosort','asc'), - redis.call('sort',KEYS[1],'by','nosort','desc')} + return {server.call('sort',KEYS[1],'by','nosort','asc'), + server.call('sort',KEYS[1],'by','nosort','desc')} } 1 zset } {{a c e b d} {d b e c a}} diff --git a/tests/unit/tracking.tcl b/tests/unit/tracking.tcl index 313293dcb7..04175aaaee 100644 --- a/tests/unit/tracking.tcl +++ b/tests/unit/tracking.tcl @@ -217,7 +217,7 @@ start_server {tags {"tracking network logreqres:skip"}} { assert_equal "1" [$rd_sg GET key1] # For write command in script, invalid key should not be tracked with NOLOOP flag - $rd_sg eval "return redis.call('set', 'key1', '2')" 1 key1 + $rd_sg eval "return server.call('set', 'key1', '2')" 1 key1 assert_equal "2" [$rd_sg GET key1] $rd_sg CLIENT TRACKING off } @@ -228,12 +228,12 @@ start_server {tags {"tracking network logreqres:skip"}} { $rd_sg MSET key2{t} 1 key2{t} 1 # If a script doesn't call any read command, don't track any keys - r EVAL "redis.call('set', 'key3{t}', 'bar')" 2 key1{t} key2{t} + r EVAL "server.call('set', 'key3{t}', 'bar')" 2 key1{t} key2{t} $rd_sg MSET key2{t} 2 key1{t} 2 assert_equal "PONG" [r ping] # If a script calls a read command, just the read keys - r EVAL "redis.call('get', 'key2{t}')" 2 key1{t} key2{t} + r EVAL "server.call('get', 'key2{t}')" 2 key1{t} key2{t} $rd_sg MSET key2{t} 2 key3{t} 2 assert_equal {invalidate key2{t}} [r read] assert_equal "PONG" [r ping] @@ -241,12 +241,12 @@ start_server {tags {"tracking network logreqres:skip"}} { # RO variants work like the normal variants # If a RO script doesn't call any read command, don't track any keys - r EVAL_RO "redis.call('ping')" 2 key1{t} key2{t} + r EVAL_RO "server.call('ping')" 2 key1{t} key2{t} $rd_sg MSET key2{t} 2 key1{t} 2 assert_equal "PONG" [r ping] # If a RO script calls a read command, just the read keys - r EVAL_RO "redis.call('get', 'key2{t}')" 2 key1{t} key2{t} + r EVAL_RO "server.call('get', 'key2{t}')" 2 key1{t} key2{t} $rd_sg MSET key2{t} 2 key3{t} 2 assert_equal {invalidate key2{t}} [r read] assert_equal "PONG" [r ping]