diff --git a/tests/unit/functions.tcl b/tests/unit/functions.tcl index 8851e4d79..9e8ec08f3 100644 --- a/tests/unit/functions.tcl +++ b/tests/unit/functions.tcl @@ -209,14 +209,14 @@ start_server {tags {"scripting"}} { 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')}] - catch { r fcall_ro test 0 } e + 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 set x 1 - r fcall_ro test 0 + r fcall_ro test 1 x } {1} test {FUNCTION - test keys and argv} { @@ -410,7 +410,7 @@ start_server {tags {"scripting repl external:skip"}} { 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 fcall test 0 + r fcall test 1 x assert {[r get x] eq {1}} wait_for_condition 150 100 { [r -1 get x] eq {1} @@ -421,7 +421,7 @@ start_server {tags {"scripting repl external:skip"}} { test "FUNCTION - modify key space of read only replica" { catch { - r -1 fcall test 0 + r -1 fcall test 1 x } e set _ $e } {READONLY You can't write against a read only replica.} @@ -1037,7 +1037,7 @@ start_server {tags {"scripting"}} { callback = function() return redis.call('set', 'x', 1) end } } - catch {r fcall_ro f1 0} e + catch {r fcall_ro f1 1 x} e set _ $e } {*Can not execute a script with write flag using \*_ro command*} @@ -1049,7 +1049,7 @@ start_server {tags {"scripting"}} { flags = {'no-writes'} } } - catch {r fcall f1 0} e + catch {r fcall f1 1 x} e set _ $e } {*Write commands are not allowed from read-only scripts*} @@ -1060,7 +1060,7 @@ start_server {tags {"scripting"}} { r config set maxmemory 1 - catch {[r fcall f1 1 k]} e + catch {[r fcall f1 1 x]} e assert_match {OOM *when used memory > 'maxmemory'*} $e r config set maxmemory 0 @@ -1095,7 +1095,7 @@ start_server {tags {"scripting"}} { assert_equal {hello} [r fcall f2 0] - catch {[r fcall f3 0]} e + catch {[r fcall f3 1 x]} e assert_match {ERR *Can not execute the command on a stale replica*} $e assert_match {*redis_version*} [r fcall f4 0] diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index e45c9f41c..424017832 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -68,7 +68,7 @@ start_server {tags {"scripting"}} { } {} test {EVAL - Return table with a metatable that call redis} { - run_script {local a = {}; setmetatable(a,{__index=function() redis.call('set', 'x', '1') end}) return a} 0 + run_script {local a = {}; setmetatable(a,{__index=function() redis.call('set', 'x', '1') end}) return a} 1 x # make sure x was not set r get x } {} @@ -215,37 +215,37 @@ start_server {tags {"scripting"}} { test {EVAL - Scripts can't run blpop command} { set e {} - catch {run_script {return redis.pcall('blpop','x',0)} 0} e + catch {run_script {return redis.pcall('blpop','x',0)} 1 x} e set e } {*not allowed*} test {EVAL - Scripts can't run brpop command} { set e {} - catch {run_script {return redis.pcall('brpop','empty_list',0)} 0} e + catch {run_script {return redis.pcall('brpop','empty_list',0)} 1 empty_list} e set e } {*not allowed*} test {EVAL - Scripts can't run brpoplpush command} { set e {} - catch {run_script {return redis.pcall('brpoplpush','empty_list1', 'empty_list2',0)} 0} e + catch {run_script {return redis.pcall('brpoplpush','empty_list1{t}', 'empty_list2{t}',0)} 2 empty_list1{t} empty_list2{t}} e set e } {*not allowed*} test {EVAL - Scripts can't run blmove command} { set e {} - catch {run_script {return redis.pcall('blmove','empty_list1', 'empty_list2', 'LEFT', 'LEFT', 0)} 0} e + catch {run_script {return redis.pcall('blmove','empty_list1{t}', 'empty_list2{t}', 'LEFT', 'LEFT', 0)} 2 empty_list1{t} empty_list2{t}} e set e } {*not allowed*} test {EVAL - Scripts can't run bzpopmin command} { set e {} - catch {run_script {return redis.pcall('bzpopmin','empty_zset', 0)} 0} e + catch {run_script {return redis.pcall('bzpopmin','empty_zset', 0)} 1 empty_zset} e set e } {*not allowed*} test {EVAL - Scripts can't run bzpopmax command} { set e {} - catch {run_script {return redis.pcall('bzpopmax','empty_zset', 0)} 0} e + catch {run_script {return redis.pcall('bzpopmax','empty_zset', 0)} 1 empty_zset} e set e } {*not allowed*} @@ -263,7 +263,7 @@ start_server {tags {"scripting"}} { test {EVAL - Scripts can run non-deterministic commands} { set e {} catch { - run_script "redis.pcall('randomkey'); return redis.pcall('set','x','ciao')" 0 + run_script {redis.pcall('randomkey'); return redis.pcall('set','x','ciao')} 1 x } e set e } {*OK*} @@ -702,7 +702,7 @@ start_server {tags {"scripting"}} { a[i] = 1 end return redis.call("lpush", "l", unpack(a)) - } 0 + } 1 l } {7999} test "Script read key with expiration set" { @@ -713,7 +713,7 @@ start_server {tags {"scripting"}} { else return redis.call("EXISTS", "key") end - } 0] "value" + } 1 key] "value" } test "Script del key with expiration set" { @@ -721,7 +721,7 @@ start_server {tags {"scripting"}} { assert_equal [run_script { redis.call("DEL", "key") return redis.call("EXISTS", "key") - } 0] 0 + } 1 key] 0 } test "Script ACL check" { @@ -1061,14 +1061,14 @@ start_server {tags {"scripting"}} { redis.call("incr","x") redis.call("select","11") redis.call("incr","z") - } 0 + } 3 foo1 x z run_script { redis.call("set","foo1","bar1") redis.call("select","10") redis.call("incr","x") redis.call("select","11") redis.call("incr","z") - } 0 + } 3 foo1 x z wait_for_condition 50 100 { [debug_digest -1] eq [debug_digest] } else { @@ -1126,7 +1126,7 @@ start_server {tags {"scripting repl external:skip"}} { redis.call('set','c','3'); redis.set_repl(redis.REPL_ALL); redis.call('set','d','4'); - } 0 + } 4 a b c d wait_for_condition 50 100 { [r -1 mget a b c d] eq {1 {} {} 4} @@ -1358,7 +1358,7 @@ start_server {tags {"scripting needs:debug"}} { redis.call("SET", "key", "value", "PX", "1") redis.call("DEBUG", "SLEEP", 0.01) return redis.call("EXISTS", "key") - } 0] 1 + } 1 key] 1 assert_equal 0 [r EXISTS key] } @@ -1371,7 +1371,7 @@ start_server {tags {"scripting needs:debug"}} { # use DEBUG OBJECT to make sure it doesn't error (means the key still exists) r DEBUG OBJECT key - assert_equal [run_script "return redis.call('EXISTS', 'key')" 0] 0 + assert_equal [run_script {return redis.call('EXISTS', 'key')} 1 key] 0 assert_equal 0 [r EXISTS key] r DEBUG set-active-expire 1 }