diff --git a/tests/assets/test_cli_hint_suite.txt b/tests/assets/test_cli_hint_suite.txt index 18c1fe07a..7c3f3da76 100644 --- a/tests/assets/test_cli_hint_suite.txt +++ b/tests/assets/test_cli_hint_suite.txt @@ -1,4 +1,4 @@ -# Test suite for redis-cli command-line hinting mechanism. +# Test suite for redict-cli command-line hinting mechanism. # Each test case consists of two strings: a (partial) input command line, and the expected hint string. # Command with one arg: GET key diff --git a/tests/cluster/tests/04-resharding.tcl b/tests/cluster/tests/04-resharding.tcl index d8bedaaca..bc364de47 100644 --- a/tests/cluster/tests/04-resharding.tcl +++ b/tests/cluster/tests/04-resharding.tcl @@ -116,7 +116,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 {redict.call("rpush",KEYS[1],ARGV[1])} 1 $key $ele } lappend content($key) $ele diff --git a/tests/cluster/tests/10-manual-failover.tcl b/tests/cluster/tests/10-manual-failover.tcl index ccae3c9e9..31dfdae29 100644 --- a/tests/cluster/tests/10-manual-failover.tcl +++ b/tests/cluster/tests/10-manual-failover.tcl @@ -53,7 +53,7 @@ test "Send CLUSTER FAILOVER to #5, during load" { if {$listid % 2} { $cluster rpush $key $ele } else { - $cluster eval {redis.call("rpush",KEYS[1],ARGV[1])} 1 $key $ele + $cluster eval {redict.call("rpush",KEYS[1],ARGV[1])} 1 $key $ele } lappend content($key) $ele diff --git a/tests/cluster/tests/16-transactions-on-replica.tcl b/tests/cluster/tests/16-transactions-on-replica.tcl index 39e305c38..a8d759ce4 100644 --- a/tests/cluster/tests/16-transactions-on-replica.tcl +++ b/tests/cluster/tests/16-transactions-on-replica.tcl @@ -84,8 +84,8 @@ test "read-only blocking operations from replica" { test "reply MOVED when eval from replica for update" { catch {[$replica eval {#!lua - return redis.call('del','a') + return redict.call('del','a') } 1 a ]} err assert {[string range $err 0 4] eq {MOVED}} -} \ No newline at end of file +} diff --git a/tests/cluster/tmp/.gitignore b/tests/cluster/tmp/.gitignore index f581f73e2..d530666eb 100644 --- a/tests/cluster/tmp/.gitignore +++ b/tests/cluster/tmp/.gitignore @@ -1,2 +1,2 @@ -redis_* +redict_* sentinel_* diff --git a/tests/integration/aof.tcl b/tests/integration/aof.tcl index aa0e7c97d..72415bad4 100644 --- a/tests/integration/aof.tcl +++ b/tests/integration/aof.tcl @@ -442,7 +442,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 {redict.call('set',KEYS[1],'y'); for i=1,1500000 do redict.call('ping') end return 'ok'} 1 x] } set rd [redict_deferring_client] $rd debug loadaof @@ -466,9 +466,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 {redict.call("set",KEYS[1],"100")} 1 foo] + append_to_aof [formatCommand eval {redict.call("incr",KEYS[1])} 1 foo] + append_to_aof [formatCommand eval {redict.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 b195635ab..0f85a5280 100644 --- a/tests/integration/rdb.tcl +++ b/tests/integration/rdb.tcl @@ -367,10 +367,10 @@ 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')"" - # its sha1 is: a0c38691e9fffe4563723c32ba77a34398e090e6 + # the script is: "return redict.call('set', 'foo', 'bar')"" + # its sha1 is: 0ede24b0c6cf991e80a18f0ef8e7f211764125e2 test {script won't load anymore if it's in rdb} { - assert_equal [r script exists a0c38691e9fffe4563723c32ba77a34398e090e6] 0 + assert_equal [r script exists 0ede24b0c6cf991e80a18f0ef8e7f211764125e2] 0 } } @@ -395,21 +395,21 @@ start_server {} { # repeate with script assert_error {MISCONF *} {r eval { - return redis.call('set','x',1) + return redict.call('set','x',1) } 1 x } assert_equal {x} [r eval { - return redis.call('get','x') + return redict.call('get','x') } 1 x ] # again with script using shebang assert_error {MISCONF *} {r eval {#!lua - return redis.call('set','x',1) + return redict.call('set','x',1) } 1 x } assert_equal {x} [r eval {#!lua flags=no-writes - return redis.call('get','x') + return redict.call('get','x') } 1 x ] diff --git a/tests/integration/redict-cli.tcl b/tests/integration/redict-cli.tcl index 88473dba0..d3ad3e910 100644 --- a/tests/integration/redict-cli.tcl +++ b/tests/integration/redict-cli.tcl @@ -449,7 +449,7 @@ if {!$::tls} { ;# fake_redict_node doesn't support TLS assert_match "*SUCCESS*" $output r acl deluser clitest } - + proc test_redict_cli_rdb_dump {functions_only} { r flushdb r function flush @@ -457,7 +457,7 @@ if {!$::tls} { ;# fake_redict_node doesn't support TLS set dir [lindex [r config get dir] 1] assert_equal "OK" [r debug populate 100000 key 1000] - assert_equal "lib1" [r function load "#!lua name=lib1\nredis.register_function('func1', function() return 123 end)"] + assert_equal "lib1" [r function load "#!lua name=lib1\nredict.register_function('func1', function() return 123 end)"] if {$functions_only} { set args "--functions-rdb $dir/cli.rdb" } else { @@ -470,7 +470,7 @@ if {!$::tls} { ;# fake_redict_node doesn't support TLS file rename "$dir/cli.rdb" "$dir/dump.rdb" assert_equal "OK" [r set should-not-exist 1] - assert_equal "should_not_exist_func" [r function load "#!lua name=should_not_exist_func\nredis.register_function('should_not_exist_func', function() return 456 end)"] + assert_equal "should_not_exist_func" [r function load "#!lua name=should_not_exist_func\nredict.register_function('should_not_exist_func', function() return 456 end)"] assert_equal "OK" [r debug reload nosave] assert_equal {} [r get should-not-exist] assert_equal {{library_name lib1 engine LUA functions {{name func1 description {} flags {}}}}} [r function list] diff --git a/tests/integration/replication-4.tcl b/tests/integration/replication-4.tcl index 11282d0d7..73fdccf25 100644 --- a/tests/integration/replication-4.tcl +++ b/tests/integration/replication-4.tcl @@ -67,8 +67,8 @@ start_server {tags {"repl external:skip"}} { # Load some functions to be used later $master FUNCTION load replace {#!lua name=test - redis.register_function{function_name='f_default_flags', callback=function(keys, args) return redis.call('get',keys[1]) end, flags={}} - redis.register_function{function_name='f_no_writes', callback=function(keys, args) return redis.call('get',keys[1]) end, flags={'no-writes'}} + redict.register_function{function_name='f_default_flags', callback=function(keys, args) return redict.call('get',keys[1]) end, flags={}} + redict.register_function{function_name='f_no_writes', callback=function(keys, args) return redict.call('get',keys[1]) end, flags={'no-writes'}} } test {First server should have role slave after SLAVEOF} { @@ -80,14 +80,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 redict.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 "redict.call('set','foo','bar')" 0} } test {With min-slaves-to-write function without no-write flag} { @@ -98,17 +98,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 "redict.call('set','foo','bar')" 0 $master config set min-slaves-to-write 2 - $master eval "return redis.call('get','foo')" 0 + $master eval "return redict.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 redict.call('set','foo',12345)" 0] # Killing a slave to make it become a lagged slave. pause_process [srv 0 pid] # Waiting for slave kill. @@ -118,7 +118,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 redict.call('set','foo',12345)" 0} resume_process [srv 0 pid] } } @@ -272,8 +272,8 @@ start_server {tags {"repl external:skip"}} { wait_for_sync $replica } - test {Data divergence can happen under default conditions} { - $replica config set propagation-error-behavior ignore + test {Data divergence can happen under default conditions} { + $replica config set propagation-error-behavior ignore $master debug replicate fake-command-1 # Wait for replication to normalize @@ -286,7 +286,7 @@ start_server {tags {"repl external:skip"}} { assert_equal [count_log_message 0 "== CRITICAL =="] 1 } - test {Data divergence is allowed on writable replicas} { + test {Data divergence is allowed on writable replicas} { $replica config set replica-read-only no $replica set number2 foo $master incrby number2 1 diff --git a/tests/integration/replication.tcl b/tests/integration/replication.tcl index 31e1ce523..5fec4de6b 100644 --- a/tests/integration/replication.tcl +++ b/tests/integration/replication.tcl @@ -196,7 +196,7 @@ start_server {tags {"repl external:skip"}} { [$B lrange foo 0 -1] eq {a b c} } else { fail "Master and replica have different digest: [$A debug digest] VS [$B debug digest]" - } + } assert_match {*calls=1,*,rejected_calls=0,failed_calls=1*} [cmdrstat blpop $B] } } @@ -259,12 +259,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 {redict.call("flushdb")} 0 # DBs are empty. r -1 flushall r -1 flushall - r -1 eval {redis.call("flushall")} 0 + r -1 eval {redict.call("flushall")} 0 # add another command to check nothing else was propagated after the above r -1 incr x @@ -580,12 +580,12 @@ foreach testType {Successful Aborted} { # Set a function value on replica to check status during loading, on failure and after swapping db $replica function load {#!lua name=test - redis.register_function('test', function() return 'hello1' end) + redict.register_function('test', function() return 'hello1' end) } # Set a function value on master to check it reaches the replica when replication ends $master function load {#!lua name=test - redis.register_function('test', function() return 'hello2' end) + redict.register_function('test', function() return 'hello2' end) } # Remember the sync_full stat before the client kill. @@ -733,7 +733,7 @@ test {diskless loading short read} { # Set a function value to check short read handling on functions r function load {#!lua name=test - redis.register_function('test', function() return 'hello1' end) + redict.register_function('test', function() return 'hello1' end) } for {set k 0} {$k < 3} {incr k} { diff --git a/tests/support/benchmark.tcl b/tests/support/benchmark.tcl index 673636849..9876a8739 100644 --- a/tests/support/benchmark.tcl +++ b/tests/support/benchmark.tcl @@ -25,14 +25,14 @@ proc redictbenchmark {host port {opts {}}} { } proc redictbenchmarkuri {host port {opts {}}} { - set cmd [list src/redict-benchmark -u redis://$host:$port] + set cmd [list src/redict-benchmark -u redict://$host:$port] lappend cmd {*}[redictbenchmark_tls_config "tests"] lappend cmd {*}$opts return $cmd } proc redictbenchmarkuriuserpass {host port user pass {opts {}}} { - set cmd [list src/redict-benchmark -u redis://$user:$pass@$host:$port] + set cmd [list src/redict-benchmark -u redict://$user:$pass@$host:$port] lappend cmd {*}[redictbenchmark_tls_config "tests"] lappend cmd {*}$opts return $cmd diff --git a/tests/support/util.tcl b/tests/support/util.tcl index 074e0df0b..64d742e03 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -43,7 +43,7 @@ proc crashlog_from_file {filename} { set logall 0 set result {} foreach line $lines { - if {[string match {*REDIS BUG REPORT START*} $line]} { + if {[string match {*REDICT BUG REPORT START*} $line]} { set logall 1 } if {[regexp {^\[\d+\]\s+\d+\s+\w+\s+\d{2}:\d{2}:\d{2} \#} $line]} { @@ -577,7 +577,7 @@ proc wait_load_handlers_disconnected {{level 0}} { } } -proc K { x y } { set x } +proc K { x y } { set x } # Shuffle a list with Fisher-Yates algorithm. proc lshuffle {list} { @@ -1019,7 +1019,7 @@ proc get_nonloopback_client {} { } # The following functions and variables are used only when running large-memory -# tests. We avoid defining them when not running large-memory tests because the +# tests. We avoid defining them when not running large-memory tests because the # global variables takes up lots of memory. proc init_large_mem_vars {} { if {![info exists ::str500]} { diff --git a/tests/unit/acl.tcl b/tests/unit/acl.tcl index c9f115f31..750323818 100644 --- a/tests/unit/acl.tcl +++ b/tests/unit/acl.tcl @@ -252,7 +252,7 @@ start_server {tags {"acl external:skip"}} { catch {$rd read} e set e } {*NOPERM*channel*} - + test {Subscribers are killed when revoked of channel permission} { set rd [redict_deferring_client] r ACL setuser psuser resetchannels &foo:1 @@ -463,7 +463,7 @@ start_server {tags {"acl external:skip"}} { # Appending to the existing access string of bob. r ACL setuser bob +@all +client|id # Although this does nothing, we retain it anyways so we can reproduce - # the original ACL. + # the original ACL. set cmdstr [dict get [r ACL getuser bob] commands] assert_equal {+@all +client|id} $cmdstr @@ -780,7 +780,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 {redict.call('incr','foo')} 0} r AUTH default "" set entry [lindex [r ACL LOG] 0] assert {[dict get $entry context] eq {lua}} @@ -919,7 +919,7 @@ start_server {tags {"acl external:skip"}} { set current_invalid_cmd_accesses [s acl_access_denied_cmd] set current_invalid_key_accesses [s acl_access_denied_key] set current_invalid_channel_accesses [s acl_access_denied_channel] - assert_error "*WRONGPASS*" {r AUTH notrealuser 1233456} + assert_error "*WRONGPASS*" {r AUTH notrealuser 1233456} assert {[s acl_access_denied_auth] eq [expr $current_auth_failures + 1]} assert_error "*WRONGPASS*" {r HELLO 3 AUTH notrealuser 1233456} assert {[s acl_access_denied_auth] eq [expr $current_auth_failures + 2]} @@ -960,7 +960,7 @@ start_server {tags {"acl external:skip"}} { assert {[s acl_access_denied_cmd] eq $current_invalid_cmd_accesses} assert {[s acl_access_denied_key] eq [expr $current_invalid_key_accesses + 1]} assert {[s acl_access_denied_channel] eq $current_invalid_channel_accesses} - } + } # If a user try to access an unauthorized channel the metric increases test {ACL-Metrics invalid channels accesses} { @@ -1203,11 +1203,11 @@ start_server [list overrides [list "dir" $server_path "aclfile" "user.acl"] tags set corruption "\nuser alice on nopass ~* -@all" exec echo $corruption >> $server_path/user.acl catch {r ACL LOAD} err - assert_match {*Duplicate user 'alice' found*} $err + assert_match {*Duplicate user 'alice' found*} $err # Verify the previous users still exist # NOTE: A missing user evaluates to an empty - # string. + # string. assert {[r ACL GETUSER alice] != ""} assert_equal [dict get [r ACL GETUSER alice] commands] "+@all" assert {[r ACL GETUSER bob] != ""} @@ -1221,17 +1221,17 @@ start_server [list overrides [list "dir" $server_path "aclfile" "user.acl"] tags set corruption "\nuser default on nopass ~* -@all" exec echo $corruption >> $server_path/user.acl catch {r ACL LOAD} err - assert_match {*Duplicate user 'default' found*} $err + assert_match {*Duplicate user 'default' found*} $err # Verify the previous users still exist # NOTE: A missing user evaluates to an empty - # string. + # string. assert {[r ACL GETUSER alice] != ""} assert_equal [dict get [r ACL GETUSER alice] commands] "+@all" assert {[r ACL GETUSER bob] != ""} assert {[r ACL GETUSER default] != ""} } - + test {Test loading duplicate users in config on startup} { catch {exec src/redict-server --user foo --user foo} err assert_match {*Duplicate user*} $err diff --git a/tests/unit/aofrw.tcl b/tests/unit/aofrw.tcl index 8fb6652ef..36062db9d 100644 --- a/tests/unit/aofrw.tcl +++ b/tests/unit/aofrw.tcl @@ -200,7 +200,7 @@ start_server {tags {"aofrw external:skip"} overrides {aof-use-rdb-preamble no}} test "AOF rewrite functions" { r flushall r FUNCTION LOAD {#!lua name=test - redis.register_function('test', function() return 1 end) + redict.register_function('test', function() return 1 end) } r bgrewriteaof waitForBgrewriteaof r diff --git a/tests/unit/client-eviction.tcl b/tests/unit/client-eviction.tcl index 6b7b9d5ae..71d963ce7 100644 --- a/tests/unit/client-eviction.tcl +++ b/tests/unit/client-eviction.tcl @@ -215,7 +215,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 "redict.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/cli.tcl b/tests/unit/cluster/cli.tcl index 34f144764..712866a6f 100644 --- a/tests/unit/cluster/cli.tcl +++ b/tests/unit/cluster/cli.tcl @@ -88,7 +88,7 @@ start_multiple_servers 3 [list overrides $base_conf] { set node1_rd [redict_deferring_client 0] test "use previous hostip in \"cluster-preferred-endpoint-type unknown-endpoint\" mode" { - + # backup and set cluster-preferred-endpoint-type unknown-endpoint set endpoint_type_before_set [lindex [split [$node1 CONFIG GET cluster-preferred-endpoint-type] " "] 1] $node1 CONFIG SET cluster-preferred-endpoint-type unknown-endpoint @@ -187,7 +187,7 @@ start_multiple_servers 5 [list overrides $base_conf] { # upload a function to all the cluster exec src/redict-cli --cluster-yes --cluster call 127.0.0.1:[srv 0 port] \ FUNCTION LOAD {#!lua name=TEST - redis.register_function('test', function() return 'hello' end) + redict.register_function('test', function() return 'hello' end) } # adding node to the cluster @@ -211,7 +211,7 @@ start_multiple_servers 5 [list overrides $base_conf] { # add function to node 5 assert_equal {TEST} [$node5_rd FUNCTION LOAD {#!lua name=TEST - redis.register_function('test', function() return 'hello' end) + redict.register_function('test', function() return 'hello' end) }] # make sure functions was added to node 5 @@ -254,10 +254,10 @@ test {Migrate the last slot away from a node using redict-cli} { exec src/redict-cli --cluster-yes --cluster add-node \ 127.0.0.1:[srv -3 port] \ 127.0.0.1:[srv 0 port] - + # First we wait for new node to be recognized by entire cluster wait_for_cluster_size 4 - + wait_for_condition 1000 50 { [CI 0 cluster_state] eq {ok} && [CI 1 cluster_state] eq {ok} && diff --git a/tests/unit/cluster/scripting.tcl b/tests/unit/cluster/scripting.tcl index c36fc2664..5034922dd 100644 --- a/tests/unit/cluster/scripting.tcl +++ b/tests/unit/cluster/scripting.tcl @@ -10,30 +10,30 @@ 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') + redict.call('set', 'foo', 'bar') + redict.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') + redict.call('set', 'foo', 'bar') + redict.call('set', 'bar', 'foo') return 'OK' end - redis.register_function('test_cross_slot', test_cross_slot)} + redict.register_function('test_cross_slot', test_cross_slot)} assert_error "ERR Script attempted to access keys that do not hash to the same slot*" {r FCALL test_cross_slot 0} } 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 "redict.call('set', 'foo', 'bar'); redict.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') + redict.call('set', 'foo', 'bar'); redict.call('set', 'bar', 'foo') } 0 # Retrieve data from different slot to verify data has been stored in the correct dictionary in cluster-enabled setup @@ -46,12 +46,12 @@ 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') + redict.call('set', 'foo', 'bar') + redict.call('set', 'bar', 'foo') return 'OK' end - redis.register_function{function_name='test_cross_slot', callback=test_cross_slot, flags={ 'allow-cross-slot-keys' }}} + redict.register_function{function_name='test_cross_slot', callback=test_cross_slot, flags={ 'allow-cross-slot-keys' }}} r FCALL test_cross_slot 0 # Retrieve data from different slot to verify data has been stored in the correct dictionary in cluster-enabled setup @@ -59,18 +59,18 @@ start_cluster 1 0 {tags {external:skip cluster}} { assert_equal "bar" [r 0 get foo] assert_equal "foo" [r 0 get bar] } - + 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') + redict.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 "redict.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 @@ -79,7 +79,7 @@ start_cluster 1 0 {tags {external:skip cluster}} { test "Function no-cluster flag" { R 0 function load {#!lua name=test - redis.register_function{function_name='f1', callback=function() return 'hello' end, flags={'no-cluster'}} + redict.register_function{function_name='f1', callback=function() return 'hello' end, flags={'no-cluster'}} } catch {R 0 fcall f1 0} e assert_match {*Can not run script on cluster, 'no-cluster' flag is set*} $e @@ -91,7 +91,7 @@ start_cluster 1 0 {tags {external:skip cluster}} { return 1 } 0 } e - + assert_match {*Can not run script on cluster, 'no-cluster' flag is set*} $e } } diff --git a/tests/unit/functions.tcl b/tests/unit/functions.tcl index b776d1b78..ef0652dcc 100644 --- a/tests/unit/functions.tcl +++ b/tests/unit/functions.tcl @@ -5,11 +5,11 @@ # SPDX-License-Identifier: LGPL-3.0-only proc get_function_code {args} { - return [format "#!%s name=%s\nredis.register_function('%s', function(KEYS, ARGV)\n %s \nend)" [lindex $args 0] [lindex $args 1] [lindex $args 2] [lindex $args 3]] + return [format "#!%s name=%s\nredict.register_function('%s', function(KEYS, ARGV)\n %s \nend)" [lindex $args 0] [lindex $args 1] [lindex $args 2] [lindex $args 3]] } proc get_no_writes_function_code {args} { - return [format "#!%s name=%s\nredis.register_function{function_name='%s', callback=function(KEYS, ARGV)\n %s \nend, flags={'no-writes'}}" [lindex $args 0] [lindex $args 1] [lindex $args 2] [lindex $args 3]] + return [format "#!%s name=%s\nredict.register_function{function_name='%s', callback=function(KEYS, ARGV)\n %s \nend, flags={'no-writes'}}" [lindex $args 0] [lindex $args 1] [lindex $args 2] [lindex $args 3]] } start_server {tags {"scripting"}} { @@ -151,7 +151,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 redict.call('set', 'x', '1')}] r flushall r flushdb r function list @@ -215,19 +215,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 redict.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 redict.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 redict.call('set', KEYS[1], ARGV[1])}] r fcall test 1 x foo r get x } {foo} @@ -323,7 +323,7 @@ start_server {tags {"scripting repl external:skip"}} { test {FUNCTION - creation is replicated to replica} { r function load [get_no_writes_function_code LUA test test {return 'hello'}] - wait_for_condition 150 100 { + wait_for_condition 150 100 { [r -1 function list] eq {{library_name test engine LUA functions {{name test description {} flags no-writes}}}} } else { fail "Failed waiting for function to replicate to replica" @@ -416,7 +416,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 redict.call('set', 'x', '1')}] r fcall test 1 x assert {[r get x] eq {1}} wait_for_condition 150 100 { @@ -439,7 +439,7 @@ test {FUNCTION can processes create, delete and flush commands in AOF when doing start_server {} { r config set appendonly yes waitForBgrewriteaof r - r FUNCTION LOAD "#!lua name=test\nredis.register_function('test', function() return 'hello' end)" + r FUNCTION LOAD "#!lua name=test\nredict.register_function('test', function() return 'hello' end)" r config set slave-read-only yes r slaveof 127.0.0.1 0 r debug loadaof @@ -453,7 +453,7 @@ test {FUNCTION can processes create, delete and flush commands in AOF when doing r slaveof no one assert_equal [r function list] {} - r FUNCTION LOAD "#!lua name=test\nredis.register_function('test', function() return 'hello' end)" + r FUNCTION LOAD "#!lua name=test\nredict.register_function('test', function() return 'hello' end)" r FUNCTION FLUSH r slaveof 127.0.0.1 0 @@ -467,9 +467,9 @@ 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 redict.call('ping') end - redis.register_function( + redict.register_function( 'f1', function(keys, args) return ping() @@ -484,13 +484,13 @@ start_server {tags {"scripting"}} { local function add1(a) return a + 1 end - redis.register_function( + redict.register_function( 'f1', function(keys, args) return add1(1) end ) - redis.register_function( + redict.register_function( 'f2', function(keys, args) return add1(2) @@ -508,13 +508,13 @@ start_server {tags {"scripting"}} { local function add1(a) return a + 2 end - redis.register_function( + redict.register_function( 'f1', function(keys, args) return add1(1) end ) - redis.register_function( + redict.register_function( 'f2', 'not a function' ) @@ -528,7 +528,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - test registration function name collision} { catch { r function load replace {#!lua name=lib2 - redis.register_function( + redict.register_function( 'f1', function(keys, args) return 1 @@ -544,13 +544,13 @@ start_server {tags {"scripting"}} { test {LIBRARIES - test registration function name collision on same library} { catch { r function load replace {#!lua name=lib2 - redis.register_function( + redict.register_function( 'f1', function(keys, args) return 1 end ) - redis.register_function( + redict.register_function( 'f1', function(keys, args) return 1 @@ -564,7 +564,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - test registration with no argument} { catch { r function load replace {#!lua name=lib2 - redis.register_function() + redict.register_function() } } e set _ $e @@ -573,7 +573,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - test registration with only name} { catch { r function load replace {#!lua name=lib2 - redis.register_function('f1') + redict.register_function('f1') } } e set _ $e @@ -582,7 +582,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - test registration with to many arguments} { catch { r function load replace {#!lua name=lib2 - redis.register_function('f1', function() return 1 end, {}, 'description', 'extra arg') + redict.register_function('f1', function() return 1 end, {}, 'description', 'extra arg') } } e set _ $e @@ -591,7 +591,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - test registration with no string name} { catch { r function load replace {#!lua name=lib2 - redis.register_function(nil, function() return 1 end) + redict.register_function(nil, function() return 1 end) } } e set _ $e @@ -600,7 +600,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - test registration with wrong name format} { catch { r function load replace {#!lua name=lib2 - redis.register_function('test\0test', function() return 1 end) + redict.register_function('test\0test', function() return 1 end) } } e set _ $e @@ -609,7 +609,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - test registration with empty name} { catch { r function load replace {#!lua name=lib2 - redis.register_function('', function() return 1 end) + redict.register_function('', function() return 1 end) } } e set _ $e @@ -624,37 +624,37 @@ start_server {tags {"scripting"}} { set _ $e } {*attempted to access nonexistent global variable 'math'*} - test {LIBRARIES - redis.call from function load} { + test {LIBRARIES - redict.call from function load} { catch { r function load replace {#!lua name=lib2 - return redis.call('ping') + return redict.call('ping') } } e set _ $e } {*attempted to access nonexistent global variable 'call'*} - test {LIBRARIES - redis.setresp from function load} { + test {LIBRARIES - redict.setresp from function load} { catch { r function load replace {#!lua name=lib2 - return redis.setresp(3) + return redict.setresp(3) } } e set _ $e } {*attempted to access nonexistent global variable 'setresp'*} - test {LIBRARIES - redis.set_repl from function load} { + test {LIBRARIES - redict.set_repl from function load} { catch { r function load replace {#!lua name=lib2 - return redis.set_repl(redis.REPL_NONE) + return redict.set_repl(redict.REPL_NONE) } } e set _ $e } {*attempted to access nonexistent global variable 'set_repl'*} - test {LIBRARIES - redis.acl_check_cmd from function load} { + test {LIBRARIES - redict.acl_check_cmd from function load} { catch { r function load replace {#!lua name=lib2 - return redis.acl_check_cmd('set','xx',1) + return redict.acl_check_cmd('set','xx',1) } } e set _ $e @@ -662,7 +662,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - malicious access test} { # the 'library' API is not exposed inside a - # function context and the 'redis' API is not + # function context and the 'redict' API is not # expose on the library registration context. # But a malicious user might find a way to hack it # (as demonstrated in this test). This is why we @@ -670,16 +670,16 @@ start_server {tags {"scripting"}} { # code itself and we want to test it and verify # that it works properly. r function load replace {#!lua name=lib1 - local lib = redis + local lib = redict lib.register_function('f1', function () - lib.redis = redis + lib.redict = redict lib.math = math return {ok='OK'} end) lib.register_function('f2', function () lib.register_function('f1', function () - lib.redis = redis + lib.redict = redict lib.math = math return {ok='OK'} end) @@ -689,14 +689,14 @@ start_server {tags {"scripting"}} { assert_match {*Attempt to modify a readonly table*} $e catch {[r function load {#!lua name=lib2 - redis.math.random() + redict.math.random() }]} e assert_match {*Script attempted to access nonexistent global variable 'math'*} $e catch {[r function load {#!lua name=lib2 - redis.redis.call('ping') + redict.redict.call('ping') }]} e - assert_match {*Script attempted to access nonexistent global variable 'redis'*} $e + assert_match {*Script attempted to access nonexistent global variable 'redict'*} $e catch {[r fcall f2 0]} e assert_match {*can only be called on FUNCTION LOAD command*} $e @@ -709,10 +709,10 @@ start_server {tags {"scripting"}} { test {LIBRARIES - register function inside a function} { r function load {#!lua name=lib - redis.register_function( + redict.register_function( 'f1', function(keys, args) - redis.register_function( + redict.register_function( 'f2', function(key, args) return 2 @@ -757,7 +757,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - named arguments} { r function load {#!lua name=lib - redis.register_function{ + redict.register_function{ function_name='f1', callback=function() return 'hello' @@ -771,7 +771,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - named arguments, bad function name} { catch { r function load replace {#!lua name=lib - redis.register_function{ + redict.register_function{ function_name=function() return 1 end, callback=function() return 'hello' @@ -786,7 +786,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - named arguments, bad callback type} { catch { r function load replace {#!lua name=lib - redis.register_function{ + redict.register_function{ function_name='f1', callback='bad', description='some desc' @@ -799,7 +799,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - named arguments, bad description} { catch { r function load replace {#!lua name=lib - redis.register_function{ + redict.register_function{ function_name='f1', callback=function() return 'hello' @@ -814,7 +814,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - named arguments, unknown argument} { catch { r function load replace {#!lua name=lib - redis.register_function{ + redict.register_function{ function_name='f1', callback=function() return 'hello' @@ -830,7 +830,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - named arguments, missing function name} { catch { r function load replace {#!lua name=lib - redis.register_function{ + redict.register_function{ callback=function() return 'hello' end, @@ -844,7 +844,7 @@ start_server {tags {"scripting"}} { test {LIBRARIES - named arguments, missing callback} { catch { r function load replace {#!lua name=lib - redis.register_function{ + redict.register_function{ function_name='f1', description='desc' } @@ -859,19 +859,19 @@ start_server {tags {"scripting"}} { local function add1(a) return a + 1 end - redis.register_function( + redict.register_function( 'f1', function(keys, args) return add1(1) end ) - redis.register_function( + redict.register_function( 'f2', function(keys, args) return add1(2) end ) - redis.register_function( + redict.register_function( 'f3', function(keys, args) return add1(3) @@ -883,7 +883,7 @@ start_server {tags {"scripting"}} { # load a library with different name but with the same function name r function load {#!lua name=lib1 - redis.register_function( + redict.register_function( 'f6', function(keys, args) return 7 @@ -894,19 +894,19 @@ start_server {tags {"scripting"}} { local function add1(a) return a + 1 end - redis.register_function( + redict.register_function( 'f4', function(keys, args) return add1(4) end ) - redis.register_function( + redict.register_function( 'f5', function(keys, args) return add1(5) end ) - redis.register_function( + redict.register_function( 'f3', function(keys, args) return add1(3) @@ -932,14 +932,14 @@ start_server {tags {"scripting"}} { test {FUNCTION - test function list with code} { r function flush r function load {#!lua name=library1 - redis.register_function('f6', function(keys, args) return 7 end) + redict.register_function('f6', function(keys, args) return 7 end) } r function list withcode - } {{library_name library1 engine LUA functions {{name f6 description {} flags {}}} library_code {*redis.register_function('f6', function(keys, args) return 7 end)*}}} + } {{library_name library1 engine LUA functions {{name f6 description {} flags {}}} library_code {*redict.register_function('f6', function(keys, args) return 7 end)*}}} test {FUNCTION - test function list with pattern} { r function load {#!lua name=lib1 - redis.register_function('f7', function(keys, args) return 7 end) + redict.register_function('f7', function(keys, args) return 7 end) } r function list libraryname library* } {{library_name library1 engine LUA functions {{name f6 description {} flags {}}}}} @@ -967,14 +967,14 @@ start_server {tags {"scripting"}} { test {FUNCTION - verify OOM on function load and function restore} { r function flush r function load replace {#!lua name=test - redis.register_function('f1', function() return 1 end) + redict.register_function('f1', function() return 1 end) } set payload [r function dump] r config set maxmemory 1 r function flush catch {r function load replace {#!lua name=test - redis.register_function('f1', function() return 1 end) + redict.register_function('f1', function() return 1 end) }} e assert_match {*command not allowed when used memory*} $e @@ -987,9 +987,9 @@ start_server {tags {"scripting"}} { test {FUNCTION - verify allow-omm allows running any command} { r FUNCTION load replace {#!lua name=f1 - redis.register_function{ + redict.register_function{ function_name='f1', - callback=function() return redis.call('set', 'x', '1') end, + callback=function() return redict.call('set', 'x', '1') end, flags={'allow-oom'} } } @@ -1006,7 +1006,7 @@ start_server {tags {"scripting"}} { start_server {tags {"scripting"}} { test {FUNCTION - wrong flags type named arguments} { catch {r function load replace {#!lua name=test - redis.register_function{ + redict.register_function{ function_name = 'f1', callback = function() return 1 end, flags = 'bad flags type' @@ -1017,7 +1017,7 @@ start_server {tags {"scripting"}} { test {FUNCTION - wrong flag type} { catch {r function load replace {#!lua name=test - redis.register_function{ + redict.register_function{ function_name = 'f1', callback = function() return 1 end, flags = {function() return 1 end} @@ -1028,7 +1028,7 @@ start_server {tags {"scripting"}} { test {FUNCTION - unknown flag} { catch {r function load replace {#!lua name=test - redis.register_function{ + redict.register_function{ function_name = 'f1', callback = function() return 1 end, flags = {'unknown'} @@ -1039,9 +1039,9 @@ start_server {tags {"scripting"}} { test {FUNCTION - write script on fcall_ro} { r function load replace {#!lua name=test - redis.register_function{ + redict.register_function{ function_name = 'f1', - callback = function() return redis.call('set', 'x', 1) end + callback = function() return redict.call('set', 'x', 1) end } } catch {r fcall_ro f1 1 x} e @@ -1050,9 +1050,9 @@ start_server {tags {"scripting"}} { test {FUNCTION - write script with no-writes flag} { r function load replace {#!lua name=test - redis.register_function{ + redict.register_function{ function_name = 'f1', - callback = function() return redis.call('set', 'x', 1) end, + callback = function() return redict.call('set', 'x', 1) end, flags = {'no-writes'} } } @@ -1062,7 +1062,7 @@ start_server {tags {"scripting"}} { test {FUNCTION - deny oom} { r FUNCTION load replace {#!lua name=test - redis.register_function('f1', function() return redis.call('set', 'x', '1') end) + redict.register_function('f1', function() return redict.call('set', 'x', '1') end) } r config set maxmemory 1 @@ -1075,7 +1075,7 @@ start_server {tags {"scripting"}} { test {FUNCTION - deny oom on no-writes function} { r FUNCTION load replace {#!lua name=test - redis.register_function{function_name='f1', callback=function() return 'hello' end, flags={'no-writes'}} + redict.register_function{function_name='f1', callback=function() return 'hello' end, flags={'no-writes'}} } r config set maxmemory 1 @@ -1088,12 +1088,12 @@ start_server {tags {"scripting"}} { test {FUNCTION - allow stale} { r FUNCTION load replace {#!lua name=test - redis.register_function{function_name='f1', callback=function() return 'hello' end, flags={'no-writes'}} - redis.register_function{function_name='f2', callback=function() return 'hello' end, flags={'allow-stale', 'no-writes'}} - redis.register_function{function_name='f3', callback=function() return redis.call('get', 'x') end, flags={'allow-stale', 'no-writes'}} - redis.register_function{function_name='f4', callback=function() return redis.call('info', 'server') end, flags={'allow-stale', 'no-writes'}} + redict.register_function{function_name='f1', callback=function() return 'hello' end, flags={'no-writes'}} + redict.register_function{function_name='f2', callback=function() return 'hello' end, flags={'allow-stale', 'no-writes'}} + redict.register_function{function_name='f3', callback=function() return redict.call('get', 'x') end, flags={'allow-stale', 'no-writes'}} + redict.register_function{function_name='f4', callback=function() return redict.call('info', 'server') end, flags={'allow-stale', 'no-writes'}} } - + r config set replica-serve-stale-data no r replicaof 127.0.0.1 1 @@ -1114,15 +1114,15 @@ start_server {tags {"scripting"}} { test {FUNCTION - redict version api} { r FUNCTION load replace {#!lua name=test - local version = redis.REDICT_VERSION_NUM + local version = redict.REDICT_VERSION_NUM - redis.register_function{function_name='get_version_v1', callback=function() + redict.register_function{function_name='get_version_v1', callback=function() return string.format('%s.%s.%s', bit.band(bit.rshift(version, 16), 0x000000ff), bit.band(bit.rshift(version, 8), 0x000000ff), bit.band(version, 0x000000ff)) end} - redis.register_function{function_name='get_version_v2', callback=function() return redis.REDICT_VERSION end} + redict.register_function{function_name='get_version_v2', callback=function() return redict.REDICT_VERSION end} } catch {[r fcall f1 0]} e @@ -1133,12 +1133,12 @@ start_server {tags {"scripting"}} { r FUNCTION FLUSH r FUNCTION load {#!lua name=test1 - redis.register_function('f1', function() return 1 end) - redis.register_function('f2', function() return 1 end) + redict.register_function('f1', function() return 1 end) + redict.register_function('f2', function() return 1 end) } r FUNCTION load {#!lua name=test2 - redis.register_function('f3', function() return 1 end) + redict.register_function('f3', function() return 1 end) } r function stats @@ -1158,15 +1158,15 @@ start_server {tags {"scripting"}} { r FUNCTION FLUSH r FUNCTION load {#!lua name=test1 - redis.register_function('f1', function() return 1 end) - redis.register_function('f2', function() return 1 end) + redict.register_function('f1', function() return 1 end) + redict.register_function('f2', function() return 1 end) } catch {r FUNCTION load {#!lua name=test1 - redis.register_function('f3', function() return 1 end) + redict.register_function('f3', function() return 1 end) }} e assert_match "*Library 'test1' already exists*" $e - + r function stats } {running_script {} engines {LUA {libraries_count 1 functions_count 2}}} @@ -1178,35 +1178,35 @@ start_server {tags {"scripting"}} { test {FUNCTION - function test empty engine} { catch {r function load replace {#! name=test - redis.register_function('foo', function() return 1 end) + redict.register_function('foo', function() return 1 end) }} e set _ $e } {ERR Engine '' not found} test {FUNCTION - function test unknown metadata value} { catch {r function load replace {#!lua name=test foo=bar - redis.register_function('foo', function() return 1 end) + redict.register_function('foo', function() return 1 end) }} e set _ $e } {ERR Invalid metadata value given: foo=bar} test {FUNCTION - function test no name} { catch {r function load replace {#!lua - redis.register_function('foo', function() return 1 end) + redict.register_function('foo', function() return 1 end) }} e set _ $e } {ERR Library name was not given} test {FUNCTION - function test multiple names} { catch {r function load replace {#!lua name=foo name=bar - redis.register_function('foo', function() return 1 end) + redict.register_function('foo', function() return 1 end) }} e set _ $e } {ERR Invalid metadata value, name argument was given multiple times} test {FUNCTION - function test name with quotes} { r function load replace {#!lua name="foo" - redis.register_function('foo', function() return 1 end) + redict.register_function('foo', function() return 1 end) } } {foo} @@ -1214,7 +1214,7 @@ start_server {tags {"scripting"}} { r FUNCTION FLUSH r FUNCTION load {#!lua name=test1 - redis.register_function('f1', function() + redict.register_function('f1', function() mt = getmetatable(_G) original_globals = mt.__index original_globals['redict'] = function() return 1 end diff --git a/tests/unit/info.tcl b/tests/unit/info.tcl index 36102fe48..46c0a07a0 100644 --- a/tests/unit/info.tcl +++ b/tests/unit/info.tcl @@ -146,7 +146,7 @@ start_server {tags {"info" "external:skip"}} { r config resetstat assert_match {} [errorstat ERR] assert_equal [s total_error_replies] 0 - catch {r eval {redis.pcall('XGROUP', 'CREATECONSUMER', 's1', 'mygroup', 'consumer') return } 0} e + catch {r eval {redict.pcall('XGROUP', 'CREATECONSUMER', 's1', 'mygroup', 'consumer') return } 0} e assert_match {*count=1*} [errorstat ERR] assert_match {*calls=1,*,rejected_calls=0,failed_calls=1} [cmdstat xgroup\\|createconsumer] assert_match {*calls=1,*,rejected_calls=0,failed_calls=0} [cmdstat eval] @@ -284,7 +284,7 @@ start_server {tags {"info" "external:skip"}} { r config resetstat for {set j 1} {$j <= 1100} {incr j} { assert_error "$j my error message" { - r eval {return redis.error_reply(string.format('%s my error message', ARGV[1]))} 0 $j + r eval {return redict.error_reply(string.format('%s my error message', ARGV[1]))} 0 $j } } @@ -309,7 +309,7 @@ start_server {tags {"info" "external:skip"}} { assert_morethan $cycle1 0 assert_morethan $el_sum1 0 assert_morethan $cmd_sum1 0 - after 110 ;# default hz is 10, wait for a cron tick. + after 110 ;# default hz is 10, wait for a cron tick. set info2 [r info stats] set cycle2 [getInfoProperty $info2 eventloop_cycles] set el_sum2 [getInfoProperty $info2 eventloop_duration_sum] @@ -512,7 +512,7 @@ start_server {tags {"info" "external:skip"}} { assert_equal [dict get $mem_stats db.dict.rehashing.count] {0} # set 4 more keys to trigger rehashing # get the info within a transaction to make sure the rehashing is not completed - r multi + r multi r set b c r set c d r set d e diff --git a/tests/unit/introspection-2.tcl b/tests/unit/introspection-2.tcl index 7ebcb3a4d..6646f1989 100644 --- a/tests/unit/introspection-2.tcl +++ b/tests/unit/introspection-2.tcl @@ -114,9 +114,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") + redict.call('set', KEYS[1], 0) + redict.call('expire', KEYS[1], 0) + redict.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 a93594ee3..778848ff3 100644 --- a/tests/unit/introspection.tcl +++ b/tests/unit/introspection.tcl @@ -224,7 +224,7 @@ start_server {tags {"introspection"}} { set rd [redict_deferring_client] $rd monitor $rd read ;# Discard the OK - r eval {redis.call('set',KEYS[1],ARGV[1])} 1 foo bar + r eval {redict.call('set',KEYS[1],ARGV[1])} 1 foo bar assert_match {*eval*} [$rd read] assert_match {*lua*"set"*"foo"*"bar"*} [$rd read] $rd close @@ -232,7 +232,7 @@ start_server {tags {"introspection"}} { test {MONITOR can log commands issued by functions} { r function load replace {#!lua name=test - redis.register_function('test', function() return redis.call('set', 'foo', 'bar') end) + redict.register_function('test', function() return redict.call('set', 'foo', 'bar') end) } set rd [redict_deferring_client] $rd monitor @@ -253,7 +253,7 @@ start_server {tags {"introspection"}} { r migrate [srv 0 host] [srv 0 port] key 9 5000 AUTH2 user password catch {r auth not-real} _ catch {r auth not-real not-a-password} _ - + assert_match {*"key"*"9"*"5000"*} [$rd read] assert_match {*"key"*"9"*"5000"*"(redacted)"*} [$rd read] assert_match {*"key"*"9"*"5000"*"(redacted)"*"(redacted)"*} [$rd read] @@ -296,46 +296,46 @@ start_server {tags {"introspection"}} { $rd close } - + test {MONITOR log blocked command only once} { - + # need to reconnect in order to reset the clients state reconnect - + set rd [redict_deferring_client] set bc [redict_deferring_client] r del mylist - + $rd monitor $rd read ; # Discard the OK - + $bc blpop mylist 0 wait_for_blocked_clients_count 1 r lpush mylist 1 wait_for_blocked_clients_count 0 r lpush mylist 2 - + # we expect to see the blpop on the monitor first assert_match {*"blpop"*"mylist"*"0"*} [$rd read] - + # we scan out all the info commands on the monitor set monitor_output [$rd read] while { [string match {*"info"*} $monitor_output] } { set monitor_output [$rd read] } - + # we expect to locate the lpush right when the client was unblocked assert_match {*"lpush"*"mylist"*"1"*} $monitor_output - + # we scan out all the info commands set monitor_output [$rd read] while { [string match {*"info"*} $monitor_output] } { set monitor_output [$rd read] } - + # we expect to see the next lpush and not duplicate blpop command assert_match {*"lpush"*"mylist"*"2"*} $monitor_output - + $rd close $bc close } @@ -574,7 +574,7 @@ start_server {tags {"introspection"}} { assert_equal [r config get save] {save {}} } } {} {external:skip} - + test {CONFIG SET with multiple args} { set some_configs {maxmemory 10000001 repl-backlog-size 10000002 save {3000 5}} @@ -596,7 +596,7 @@ start_server {tags {"introspection"}} { test {CONFIG SET rollback on set error} { # This test passes an invalid percent value to maxmemory-clients which should cause an - # input verification failure during the "set" phase before trying to apply the + # input verification failure during the "set" phase before trying to apply the # configuration. We want to make sure the correct failure happens and everything # is rolled back. # backup maxmemory config @@ -619,7 +619,7 @@ start_server {tags {"introspection"}} { test {CONFIG SET rollback on apply error} { # This test tries to configure a used port number in redict. This is expected - # to pass the `CONFIG SET` validity checking implementation but fail on + # to pass the `CONFIG SET` validity checking implementation but fail on # actual "apply" of the setting. This will validate that after an "apply" # failure we rollback to the previous values. proc dummy_accept {chan addr port} {} @@ -651,8 +651,8 @@ start_server {tags {"introspection"}} { set used_port [find_available_port $::baseport $::portcount] dict set some_configs port $used_port - # Run a dummy server on used_port so we know we can't configure redict to - # use it. It's ok for this to fail because that means used_port is invalid + # Run a dummy server on used_port so we know we can't configure redict to + # use it. It's ok for this to fail because that means used_port is invalid # anyway catch {socket -server dummy_accept -myaddr 127.0.0.1 $used_port} e if {$::verbose} { puts "dummy_accept: $e" } @@ -698,18 +698,18 @@ start_server {tags {"introspection"}} { test {CONFIG GET multiple args} { set res [r config get maxmemory maxmemory* bind *of] - + # Verify there are no duplicates in the result assert_equal [expr [llength [dict keys $res]]*2] [llength $res] - + # Verify we got both name and alias in result - assert {[dict exists $res slaveof] && [dict exists $res replicaof]} + assert {[dict exists $res slaveof] && [dict exists $res replicaof]} # Verify pattern found multiple maxmemory* configs - assert {[dict exists $res maxmemory] && [dict exists $res maxmemory-samples] && [dict exists $res maxmemory-clients]} + assert {[dict exists $res maxmemory] && [dict exists $res maxmemory-samples] && [dict exists $res maxmemory-clients]} # Verify we also got the explicit config - assert {[dict exists $res bind]} + assert {[dict exists $res bind]} } test {redict-server command line arguments - error cases} { diff --git a/tests/unit/latency-monitor.tcl b/tests/unit/latency-monitor.tcl index 6b4d4e165..25cf7a1b3 100644 --- a/tests/unit/latency-monitor.tcl +++ b/tests/unit/latency-monitor.tcl @@ -155,7 +155,7 @@ tags {"needs:debug"} { r eval { local i = 0 while (i < tonumber(ARGV[1])) do - redis.call('sadd',KEYS[1],i) + redict.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 018ab5b80..7994b7d77 100644 --- a/tests/unit/moduleapi/commandfilter.tcl +++ b/tests/unit/moduleapi/commandfilter.tcl @@ -44,15 +44,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 redict.call()} { r del log-key - r eval "redis.call('ping', '@log')" 0 + r eval "redict.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 redict.call() that calls a module} { r del log-key - r eval "redis.call('commandfilter.ping')" 0 + r eval "redict.call('commandfilter.ping')" 0 r lrange log-key 0 -1 } "{ping @log}" @@ -86,7 +86,7 @@ start_server {tags {"modules"}} { r module unload commandfilter r module load $testmodule log-key 1 - test {Command Filter REDISMODULE_CMDFILTER_NOSELF works as expected} { + test {Command Filter REDICTMODULE_CMDFILTER_NOSELF works as expected} { r set mykey @log assert_equal "{set mykey @log}" [r lrange log-key 0 -1] @@ -94,7 +94,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 "redict.call('commandfilter.ping')" 0 assert_equal {} [r lrange log-key 0 -1] } @@ -113,11 +113,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 {redict.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 {redict.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 {redict.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/keyspace_events.tcl b/tests/unit/moduleapi/keyspace_events.tcl index f9bb89527..1aa8f11c8 100644 --- a/tests/unit/moduleapi/keyspace_events.tcl +++ b/tests/unit/moduleapi/keyspace_events.tcl @@ -39,7 +39,7 @@ tags "modules" { assert_equal {} [r get lua] r get x } {3} - + test {Nested multi due to RM_Call, with client MULTI} { r del multi r del lua @@ -56,7 +56,7 @@ tags "modules" { assert_equal {} [r get lua] r get x } {3} - + test {Nested multi due to RM_Call, with EVAL} { r del multi r del lua @@ -64,10 +64,10 @@ tags "modules" { r set x 1 r set x_copy 1 r eval { - redis.pcall('keyspace.del_key_copy', KEYS[1]) - redis.pcall('keyspace.incr_case1', KEYS[1]) - redis.pcall('keyspace.incr_case2', KEYS[1]) - redis.pcall('keyspace.incr_case3', KEYS[1]) + redict.pcall('keyspace.del_key_copy', KEYS[1]) + redict.pcall('keyspace.incr_case1', KEYS[1]) + redict.pcall('keyspace.incr_case2', KEYS[1]) + redict.pcall('keyspace.incr_case3', KEYS[1]) } 1 x assert_equal {} [r get multi] assert_equal {1} [r get lua] diff --git a/tests/unit/moduleapi/misc.tcl b/tests/unit/moduleapi/misc.tcl index e077fea25..546b2a5ad 100644 --- a/tests/unit/moduleapi/misc.tcl +++ b/tests/unit/moduleapi/misc.tcl @@ -35,7 +35,7 @@ start_server {overrides {save {900 1}} tags {"modules"}} { set ld [r test.ld_conversion] assert {[string match $ld "0.00000000000000001"]} } - + test {test unsigned long long conversions} { set ret [r test.ull_conversion] assert {[string match $ret "ok"]} @@ -52,7 +52,7 @@ start_server {overrides {save {900 1}} tags {"modules"}} { test {test RedictModule_ResetDataset do not reset functions} { r function load {#!lua name=lib - redis.register_function('test', function() return 1 end) + redict.register_function('test', function() return 1 end) } assert_equal [r function list] {{library_name lib engine LUA functions {{name test description {} flags {}}}}} r test.flushall @@ -147,7 +147,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 "redict.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] @@ -254,7 +254,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) + redict.call('set','x',1) return 1 } 1 x } @@ -262,7 +262,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) + redict.call('set','x',1) return 1 } 1 x ] @@ -282,13 +282,13 @@ start_server {overrides {save {900 1}} tags {"modules"}} { test {rm_call EVAL} { r test.rm_call eval { - redis.call('set','x',1) + redict.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) + redict.call('set','x',1) return 1 } 1 x } @@ -301,34 +301,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) + redict.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) + redict.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') + redict.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') + redict.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') + redict.call('get','x') return 4 } 1 x @@ -341,19 +341,19 @@ start_server {overrides {save {900 1}} tags {"modules"}} { # no shebang at all r test.rm_call eval { - redis.call('set','x',1) + redict.call('set','x',1) return 6 } 1 x # Shebang without flags r test.rm_call eval {#!lua - redis.call('set','x', 1) + redict.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) + redict.call('set','x', 1) return 8 } 1 x @@ -369,25 +369,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 redict.call('get','x') } 1 x ] "some value" assert_equal [ r test.rm_call eval { - return redis.call('get','x') + return redict.call('get','x') } 1 x ] "some value" assert_error {NOREPLICAS *} { r test.rm_call eval {#!lua - return redis.call('get','x') + return redict.call('get','x') } 1 x } assert_error {NOREPLICAS *} { r test.rm_call eval { - return redis.call('set','x', 1) + return redict.call('set','x', 1) } 1 x } @@ -402,25 +402,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) + redict.call('set','x',1) return 1 } 1 x } r test.rm_call eval {#!lua flags=no-writes - redis.call('get','x') + redict.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') + redict.call('get','x') return 3 } 1 x } r test.rm_call eval { - redis.call('get','x') + redict.call('get','x') return 4 } 1 x @@ -438,14 +438,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') + redict.call('get','x') return 2 } 1 x } assert_error {MASTERDOWN *} { r test.rm_call eval { - redis.call('get','x') + redict.call('get','x') return 4 } 1 x } @@ -474,21 +474,21 @@ start_server {overrides {save {900 1}} tags {"modules"}} { # repeate with script assert_error {MISCONF *} {r test.rm_call eval { - return redis.call('set','x',1) + return redict.call('set','x',1) } 1 x } assert_equal {x} [r test.rm_call eval { - return redis.call('get','x') + return redict.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 redict.call('set','x',1) } 1 x } assert_equal {x} [r test.rm_call eval {#!lua flags=no-writes - return redis.call('get','x') + return redict.call('get','x') } 1 x ] diff --git a/tests/unit/moduleapi/propagate.tcl b/tests/unit/moduleapi/propagate.tcl index 10f653473..a3de91661 100644 --- a/tests/unit/moduleapi/propagate.tcl +++ b/tests/unit/moduleapi/propagate.tcl @@ -143,7 +143,7 @@ tags "modules" { $master set asdf1 1 $master set asdf2 2 $master set asdf3 3 - + $master config set maxmemory-policy allkeys-random $master config set maxmemory 1 @@ -160,7 +160,7 @@ tags "modules" { # that performs `RedictModule_Call(ctx, "INCR", "c", "multi");` if the notification is inside multi exec. # so we will have 2 keys, "notifications" and "multi". wait_for_condition 500 10 { - [$replica dbsize] eq 2 + [$replica dbsize] eq 2 } else { fail "Not all keys have been evicted" } @@ -452,9 +452,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} + redict.call("propagate-test.simple"); \ + redict.call("set", "x", "y"); \ + redict.call("propagate-test.mixed"); return "OK" } 0 ] {OK} assert_replication_stream $repl { {multi} @@ -647,7 +647,7 @@ tags "modules" { set repl [attach_to_replication_stream] $master flushall - + $master get unexisting_key wait_for_condition 500 10 { @@ -667,7 +667,7 @@ tags "modules" { {get unexisting_key} {exec} } - + close_replication_stream $repl } @@ -734,23 +734,23 @@ tags "modules aof" { r config set appendonly yes r config set auto-aof-rewrite-percentage 0 ; # Disable auto-rewrite. waitForBgrewriteaof r - + r config resetstat r set foo bar - r EVAL {return redis.call('SET', KEYS[1], ARGV[1])} 1 foo bar2 + r EVAL {return redict.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 redict.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 redict.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 redict.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] - - + + # Load the AOF if {$aofload_type == "debug_cmd"} { r config resetstat @@ -760,9 +760,9 @@ tags "modules aof" { restart_server 0 true false wait_done_loading r } - + assert_no_match {*calls=*} [cmdrstat set r] - + } } } diff --git a/tests/unit/moduleapi/testrdb.tcl b/tests/unit/moduleapi/testrdb.tcl index 10b5dd130..7d56b71e0 100644 --- a/tests/unit/moduleapi/testrdb.tcl +++ b/tests/unit/moduleapi/testrdb.tcl @@ -212,7 +212,7 @@ tags "modules" { $master config set repl-diskless-sync-delay 0 $master config set save "" $replica config set repl-diskless-load swapdb - $replica config set save "" + $replica config set save "" # Initial sync to have matching replids between master and replica $replica replicaof $master_host $master_port @@ -252,11 +252,11 @@ tags "modules" { test {Diskless load swapdb RedictModuleEvent_ReplAsyncLoad handling: during loading, can keep module variable same as before} { # Wait for the replica to start reading the rdb and module for acknowledgement - # We wanna abort only after the temp db was populated by REDISMODULE_AUX_BEFORE_RDB + # We wanna abort only after the temp db was populated by REDICTMODULE_AUX_BEFORE_RDB wait_for_condition 100 100 { [s -1 async_loading] eq 1 && [$replica testrdb.async_loading.get.before] eq "value1_master" } else { - fail "Module didn't receive or react to REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED" + fail "Module didn't receive or react to REDICTMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED" } assert_equal [$replica dbsize] 200 @@ -274,7 +274,7 @@ tags "modules" { wait_for_condition 100 100 { [s -1 async_loading] eq 0 && [$replica testrdb.async_loading.get.before] eq "" } else { - fail "Module didn't receive or react to REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED" + fail "Module didn't receive or react to REDICTMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED" } assert_equal [$replica dbsize] 200 diff --git a/tests/unit/moduleapi/usercall.tcl b/tests/unit/moduleapi/usercall.tcl index 99efae96b..a735b45d2 100644 --- a/tests/unit/moduleapi/usercall.tcl +++ b/tests/unit/moduleapi/usercall.tcl @@ -7,11 +7,11 @@ set testmodule [file normalize tests/modules/usercall.so] set test_script_set "#!lua -redis.call('set','x',1) +redict.call('set','x',1) return 1" set test_script_get "#!lua -redis.call('get','x') +redict.call('get','x') return 1" start_server {tags {"modules usercall"}} { diff --git a/tests/unit/multi.tcl b/tests/unit/multi.tcl index e36f3936f..f4790b802 100644 --- a/tests/unit/multi.tcl +++ b/tests/unit/multi.tcl @@ -764,7 +764,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 {redict.call('set', KEYS[1], 'foo')} r set foo bar set res [r exec] set sha [lindex $res 0] @@ -781,7 +781,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 {redict.call('set', KEYS[1], 'bar')} 1 bar r exec assert_replication_stream $repl { @@ -902,7 +902,7 @@ start_server {tags {"multi"}} { r readraw 0 set _ $res } {*CONFIG SET failed*} - + test "Flushall while watching several keys by one client" { r flushall r mset a{t} a b{t} b diff --git a/tests/unit/pause.tcl b/tests/unit/pause.tcl index 0b9b7197e..91eb2ae29 100644 --- a/tests/unit/pause.tcl +++ b/tests/unit/pause.tcl @@ -82,7 +82,7 @@ start_server {tags {"pause network"}} { $rd2 publish foo bar wait_for_blocked_clients_count 2 50 100 - r client unpause + r client unpause assert_match "1" [$rd read] assert_match "0" [$rd2 read] $rd close @@ -98,7 +98,7 @@ start_server {tags {"pause network"}} { assert_equal [$rr GET FOO] "QUEUED" assert_match "PONG BAR" [$rr EXEC] assert_equal [s 0 blocked_clients] 0 - r client unpause + r client unpause $rr close } @@ -111,7 +111,7 @@ start_server {tags {"pause network"}} { r client PAUSE 60000 WRITE $rd EXEC wait_for_blocked_clients_count 1 50 100 - r client unpause + r client unpause assert_match "OK" [$rd read] $rd close } @@ -128,7 +128,7 @@ start_server {tags {"pause network"}} { } 0 wait_for_blocked_clients_count 2 50 100 - r client unpause + r client unpause assert_match "1" [$rd read] assert_match "1" [$rd2 read] $rd close @@ -139,7 +139,7 @@ start_server {tags {"pause network"}} { r set x y # create a function for later r FUNCTION load replace {#!lua name=f1 - redis.register_function{ + redict.register_function{ function_name='f1', callback=function() return "hello" end, flags={'no-writes'} @@ -163,7 +163,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 redict.call('GeT', 'x')..' unique script' } 1 x ] "y unique script" @@ -233,15 +233,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 redict.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 redict.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 redict.call('publish','ch','msg')" 0] 0 } test "Test multiple clients can be queued up and unblocked" { @@ -290,7 +290,7 @@ start_server {tags {"pause network"}} { r get bar{t} # Now that clients have been unpaused, expires should go through - assert_match [expr $expired_keys + 2] [s 0 expired_keys] + assert_match [expr $expired_keys + 2] [s 0 expired_keys] } test "Test that client pause starts at the end of a transaction" { @@ -309,7 +309,7 @@ start_server {tags {"pause network"}} { assert_match "BAR" [r GET FOO2{t}] assert_match "" [r GET FOO3{t}] - r client unpause + r client unpause assert_match "OK" [$rd read] $rd close } diff --git a/tests/unit/pubsub.tcl b/tests/unit/pubsub.tcl index 453b4b6a9..9426285a1 100644 --- a/tests/unit/pubsub.tcl +++ b/tests/unit/pubsub.tcl @@ -451,7 +451,7 @@ start_server {tags {"pubsub network"}} { assert_equal {1} [psubscribe $rd1 *] r set foo bar # second set of foo should not cause a 'new' event - r set foo baz + r set foo baz r set bar bar assert_equal "pmessage * __keyevent@${db}__:new foo" [$rd1 read] assert_equal "pmessage * __keyevent@${db}__:new bar" [$rd1 read] @@ -475,10 +475,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") + redict.call("ping","abc") + redict.call("publish","foo","bar") + redict.call("publish","foo","vaz") + redict.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 268327a88..98bf920e3 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -21,7 +21,7 @@ if {$is_eval == 1} { } } else { proc run_script {args} { - r function load replace [format "#!lua name=test\nredis.register_function('test', function(KEYS, ARGV)\n %s \nend)" [lindex $args 0]] + r function load replace [format "#!lua name=test\nredict.register_function('test', function(KEYS, ARGV)\n %s \nend)" [lindex $args 0]] if {[r readingraw] eq 1} { # read name assert_equal {test} [r read] @@ -29,7 +29,7 @@ if {$is_eval == 1} { r fcall test {*}[lrange $args 1 end] } proc run_script_ro {args} { - r function load replace [format "#!lua name=test\nredis.register_function{function_name='test', callback=function(KEYS, ARGV)\n %s \nend, flags={'no-writes'}}" [lindex $args 0]] + r function load replace [format "#!lua name=test\nredict.register_function{function_name='test', callback=function(KEYS, ARGV)\n %s \nend, flags={'no-writes'}}" [lindex $args 0]] if {[r readingraw] eq 1} { # read name assert_equal {test} [r read] @@ -38,7 +38,7 @@ if {$is_eval == 1} { } proc run_script_on_connection {args} { set rd [lindex $args 0] - $rd function load replace [format "#!lua name=test\nredis.register_function('test', function(KEYS, ARGV)\n %s \nend)" [lindex $args 1]] + $rd function load replace [format "#!lua name=test\nredict.register_function('test', function(KEYS, ARGV)\n %s \nend)" [lindex $args 1]] # read name $rd read $rd fcall test {*}[lrange $args 2 end] @@ -54,7 +54,7 @@ start_server {tags {"scripting"}} { test {Script - disallow write on OOM} { r config set maxmemory 1 - catch {[r eval "redis.call('set', 'x', 1)" 0]} e + catch {[r eval "redict.call('set', 'x', 1)" 0]} e assert_match {*command not allowed when used memory*} $e r config set maxmemory 0 @@ -74,7 +74,7 @@ start_server {tags {"scripting"}} { } {} test {EVAL - Return table with a metatable that call redict} { - run_script {local a = {}; setmetatable(a,{__index=function() redis.call('set', 'x', '1') end}) return a} 1 x + run_script {local a = {}; setmetatable(a,{__index=function() redict.call('set', 'x', '1') end}) return a} 1 x # make sure x was not set r get x } {} @@ -116,21 +116,21 @@ start_server {tags {"scripting"}} { test {EVAL - is Lua able to call Redict API?} { r set mykey myval - run_script {return redis.call('get',KEYS[1])} 1 mykey + run_script {return redict.call('get',KEYS[1])} 1 mykey } {myval} if {$is_eval eq 1} { # eval sha is only relevant for is_eval Lua test {EVALSHA - Can we call a SHA1 if already defined?} { - r evalsha fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey + r evalsha de68fd8c467c2dc803309766657fd734e1d1075c 1 mykey } {myval} test {EVALSHA_RO - Can we call a SHA1 if already defined?} { - r evalsha_ro fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey + r evalsha_ro de68fd8c467c2dc803309766657fd734e1d1075c 1 mykey } {myval} test {EVALSHA - Can we call a SHA1 in uppercase?} { - r evalsha FD758D1589D044DD850A6F05D52F2EEFD27F033F 1 mykey + r evalsha de68fd8c467c2dc803309766657fd734e1d1075c 1 mykey } {myval} test {EVALSHA - Do we get an error on invalid SHA1?} { @@ -147,7 +147,7 @@ start_server {tags {"scripting"}} { test {EVAL - Redict integer -> Lua type conversion} { r set x 0 run_script { - local foo = redis.pcall('incr',KEYS[1]) + local foo = redict.pcall('incr',KEYS[1]) return {type(foo),foo} } 1 x } {number 1} @@ -155,7 +155,7 @@ start_server {tags {"scripting"}} { test {EVAL - Lua number -> Redict integer conversion} { r del hash run_script { - local foo = redis.pcall('hincrby','hash','field',200000000) + local foo = redict.pcall('hincrby','hash','field',200000000) return {type(foo),foo} } 0 } {number 200000000} @@ -163,7 +163,7 @@ start_server {tags {"scripting"}} { test {EVAL - Redict bulk -> Lua type conversion} { r set mykey myval run_script { - local foo = redis.pcall('get',KEYS[1]) + local foo = redict.pcall('get',KEYS[1]) return {type(foo),foo} } 1 mykey } {string myval} @@ -174,14 +174,14 @@ start_server {tags {"scripting"}} { r rpush mylist b r rpush mylist c run_script { - local foo = redis.pcall('lrange',KEYS[1],0,-1) + local foo = redict.pcall('lrange',KEYS[1],0,-1) return {type(foo),foo[1],foo[2],foo[3],# foo} } 1 mylist } {table a b c 3} test {EVAL - Redict status reply -> Lua type conversion} { run_script { - local foo = redis.pcall('set',KEYS[1],'myval') + local foo = redict.pcall('set',KEYS[1],'myval') return {type(foo),foo['ok']} } 1 mykey } {table OK} @@ -189,7 +189,7 @@ start_server {tags {"scripting"}} { test {EVAL - Redict error reply -> Lua type conversion} { r set mykey myval run_script { - local foo = redis.pcall('incr',KEYS[1]) + local foo = redict.pcall('incr',KEYS[1]) return {type(foo),foo['err']} } 1 mykey } {table {ERR value is not an integer or out of range}} @@ -197,7 +197,7 @@ start_server {tags {"scripting"}} { test {EVAL - Redict nil bulk reply -> Lua type conversion} { r del mykey run_script { - local foo = redis.pcall('get',KEYS[1]) + local foo = redict.pcall('get',KEYS[1]) return {type(foo),foo == false} } 1 mykey } {boolean 1} @@ -206,13 +206,13 @@ start_server {tags {"scripting"}} { r set mykey "this is DB 9" r select 10 r set mykey "this is DB 10" - run_script {return redis.pcall('get',KEYS[1])} 1 mykey + run_script {return redict.pcall('get',KEYS[1])} 1 mykey } {this is DB 10} {singledb:skip} test {EVAL - SELECT inside Lua should not affect the caller} { # here we DB 10 is selected r set mykey "original value" - run_script {return redis.pcall('select','9')} 0 + run_script {return redict.pcall('select','9')} 0 set res [r get mykey] r select 9 set res @@ -234,74 +234,74 @@ start_server {tags {"scripting"}} { test {EVAL - Scripts do not block on blpop command} { r lpush l 1 r lpop l - run_script {return redis.pcall('blpop','l',0)} 1 l + run_script {return redict.pcall('blpop','l',0)} 1 l } {} test {EVAL - Scripts do not block on brpop command} { r lpush l 1 r lpop l - run_script {return redis.pcall('brpop','l',0)} 1 l + run_script {return redict.pcall('brpop','l',0)} 1 l } {} test {EVAL - Scripts do not block on brpoplpush command} { r lpush empty_list1{t} 1 r lpop empty_list1{t} - run_script {return redis.pcall('brpoplpush','empty_list1{t}', 'empty_list2{t}',0)} 2 empty_list1{t} empty_list2{t} + run_script {return redict.pcall('brpoplpush','empty_list1{t}', 'empty_list2{t}',0)} 2 empty_list1{t} empty_list2{t} } {} test {EVAL - Scripts do not block on blmove command} { r lpush empty_list1{t} 1 r lpop empty_list1{t} - run_script {return redis.pcall('blmove','empty_list1{t}', 'empty_list2{t}', 'LEFT', 'LEFT', 0)} 2 empty_list1{t} empty_list2{t} + run_script {return redict.pcall('blmove','empty_list1{t}', 'empty_list2{t}', 'LEFT', 'LEFT', 0)} 2 empty_list1{t} empty_list2{t} } {} test {EVAL - Scripts do not block on bzpopmin command} { r zadd empty_zset 10 foo r zmpop 1 empty_zset MIN - run_script {return redis.pcall('bzpopmin','empty_zset', 0)} 1 empty_zset + run_script {return redict.pcall('bzpopmin','empty_zset', 0)} 1 empty_zset } {} test {EVAL - Scripts do not block on bzpopmax command} { r zadd empty_zset 10 foo r zmpop 1 empty_zset MIN - run_script {return redis.pcall('bzpopmax','empty_zset', 0)} 1 empty_zset + run_script {return redict.pcall('bzpopmax','empty_zset', 0)} 1 empty_zset } {} test {EVAL - Scripts do not block on wait} { - run_script {return redis.pcall('wait','1','0')} 0 + run_script {return redict.pcall('wait','1','0')} 0 } {0} test {EVAL - Scripts do not block on waitaof} { - run_script {return redis.pcall('waitaof','0','1','0')} 0 + run_script {return redict.pcall('waitaof','0','1','0')} 0 } {0 0} test {EVAL - Scripts do not block on XREAD with BLOCK option} { r del s r xgroup create s g $ MKSTREAM - set res [run_script {return redis.pcall('xread','STREAMS','s','$')} 1 s] + set res [run_script {return redict.pcall('xread','STREAMS','s','$')} 1 s] assert {$res eq {}} - run_script {return redis.pcall('xread','BLOCK',0,'STREAMS','s','$')} 1 s + run_script {return redict.pcall('xread','BLOCK',0,'STREAMS','s','$')} 1 s } {} test {EVAL - Scripts do not block on XREADGROUP with BLOCK option} { - set res [run_script {return redis.pcall('xreadgroup','group','g','c','STREAMS','s','>')} 1 s] + set res [run_script {return redict.pcall('xreadgroup','group','g','c','STREAMS','s','>')} 1 s] assert {$res eq {}} - run_script {return redis.pcall('xreadgroup','group','g','c','BLOCK',0,'STREAMS','s','>')} 1 s + run_script {return redict.pcall('xreadgroup','group','g','c','BLOCK',0,'STREAMS','s','>')} 1 s } {} test {EVAL - Scripts do not block on XREAD with BLOCK option -- non empty stream} { r XADD s * a 1 - set res [run_script {return redis.pcall('xread','BLOCK',0,'STREAMS','s','$')} 1 s] + set res [run_script {return redict.pcall('xread','BLOCK',0,'STREAMS','s','$')} 1 s] assert {$res eq {}} - set res [run_script {return redis.pcall('xread','BLOCK',0,'STREAMS','s','0-0')} 1 s] + set res [run_script {return redict.pcall('xread','BLOCK',0,'STREAMS','s','0-0')} 1 s] assert {[lrange [lindex $res 0 1 0 1] 0 1] eq {a 1}} } test {EVAL - Scripts do not block on XREADGROUP with BLOCK option -- non empty stream} { r XADD s * b 2 set res [ - run_script {return redis.pcall('xreadgroup','group','g','c','BLOCK',0,'STREAMS','s','>')} 1 s + run_script {return redict.pcall('xreadgroup','group','g','c','BLOCK',0,'STREAMS','s','>')} 1 s ] assert {[llength [lindex $res 0 1]] == 2} lindex $res 0 1 0 1 @@ -310,38 +310,38 @@ 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')} 1 x + run_script {redict.pcall('randomkey'); return redict.pcall('set','x','ciao')} 1 x } e set e } {*OK*} - test {EVAL - No arguments to redis.call/pcall is considered an error} { + test {EVAL - No arguments to redict.call/pcall is considered an error} { set e {} - catch {run_script {return redis.call()} 0} e + catch {run_script {return redict.call()} 0} e set e } {*one argument*} - test {EVAL - redis.call variant raises a Lua error on Redict cmd error (1)} { + test {EVAL - redict.call variant raises a Lua error on Redict cmd error (1)} { set e {} catch { - run_script "redis.call('nosuchcommand')" 0 + run_script "redict.call('nosuchcommand')" 0 } e set e } {*Unknown Redict*} - test {EVAL - redis.call variant raises a Lua error on Redict cmd error (1)} { + test {EVAL - redict.call variant raises a Lua error on Redict cmd error (1)} { set e {} catch { - run_script "redis.call('get','a','b','c')" 0 + run_script "redict.call('get','a','b','c')" 0 } e set e } {*number of args*} - test {EVAL - redis.call variant raises a Lua error on Redict cmd error (1)} { + test {EVAL - redict.call variant raises a Lua error on Redict cmd error (1)} { set e {} r set foo bar catch { - run_script {redis.call('lpush',KEYS[1],'val')} 1 foo + run_script {redict.call('lpush',KEYS[1],'val')} 1 foo } e set e } {*against a key*} @@ -569,12 +569,12 @@ start_server {tags {"scripting"}} { test {EVAL_RO - Successful case} { r set foo bar - assert_equal bar [run_script_ro {return redis.call('get', KEYS[1]);} 1 foo] + assert_equal bar [run_script_ro {return redict.call('get', KEYS[1]);} 1 foo] } test {EVAL_RO - Cannot run write commands} { r set foo bar - catch {run_script_ro {redis.call('del', KEYS[1]);} 1 foo} e + catch {run_script_ro {redict.call('del', KEYS[1]);} 1 foo} e set e } {ERR Write commands are not allowed from read-only scripts*} @@ -583,17 +583,17 @@ start_server {tags {"scripting"}} { test {SCRIPTING FLUSH - is able to clear the scripts cache?} { r set mykey myval - r script load {return redis.call('get',KEYS[1])} - set v [r evalsha fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey] + r script load {return redict.call('get',KEYS[1])} + set v [r evalsha de68fd8c467c2dc803309766657fd734e1d1075c 1 mykey] assert_equal $v myval r script flush - assert_error {NOSCRIPT*} {r evalsha fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey} + assert_error {NOSCRIPT*} {r evalsha de68fd8c467c2dc803309766657fd734e1d1075c 1 mykey} - r eval {return redis.call('get',KEYS[1])} 1 mykey - set v [r evalsha fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey] + r eval {return redict.call('get',KEYS[1])} 1 mykey + set v [r evalsha de68fd8c467c2dc803309766657fd734e1d1075c 1 mykey] assert_equal $v myval r script flush - assert_error {NOSCRIPT*} {r evalsha fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey} + assert_error {NOSCRIPT*} {r evalsha de68fd8c467c2dc803309766657fd734e1d1075c 1 mykey} } test {SCRIPTING FLUSH ASYNC} { @@ -619,25 +619,25 @@ start_server {tags {"scripting"}} { test "SORT is normally not alpha re-ordered for the scripting engine" { r del myset r sadd myset 1 2 3 4 10 - r eval {return redis.call('sort',KEYS[1],'desc')} 1 myset + r eval {return redict.call('sort',KEYS[1],'desc')} 1 myset } {10 4 3 2 1} {cluster:skip} test "SORT BY output gets ordered for scripting" { r del myset r sadd myset a b c d e f g h i l m n o p q r s t u v z aa aaa azz - r eval {return redis.call('sort',KEYS[1],'by','_')} 1 myset + r eval {return redict.call('sort',KEYS[1],'by','_')} 1 myset } {a aa aaa azz b c d e f g h i l m n o p q r s t u v z} {cluster:skip} test "SORT BY with GET gets ordered for scripting" { r del myset r sadd myset a b c - r eval {return redis.call('sort',KEYS[1],'by','_','get','#','get','_:*')} 1 myset + r eval {return redict.call('sort',KEYS[1],'by','_','get','#','get','_:*')} 1 myset } {a {} b {} c {}} {cluster:skip} } ;# is_eval - test "redis.sha1hex() implementation" { - list [run_script {return redis.sha1hex('')} 0] \ - [run_script {return redis.sha1hex('Pizza & Mandolino')} 0] + test "redict.sha1hex() implementation" { + list [run_script {return redict.sha1hex('')} 0] \ + [run_script {return redict.sha1hex('Pizza & Mandolino')} 0] } {da39a3ee5e6b4b0d3255bfef95601890afd80709 74822d82031af7493c20eefa13bd07ec4fada82f} test "Measures elapsed time os.clock()" { @@ -700,12 +700,12 @@ start_server {tags {"scripting"}} { set decr_if_gt { local current - current = redis.call('get',KEYS[1]) + current = redict.call('get',KEYS[1]) if not current then return nil end if current > ARGV[1] then - return redis.call('decr',KEYS[1]) + return redict.call('decr',KEYS[1]) else - return redis.call('get',KEYS[1]) + return redict.call('get',KEYS[1]) end } r set foo 5 @@ -750,7 +750,7 @@ start_server {tags {"scripting"}} { # Use a non blocking client to speedup the loop. set rd [redict_deferring_client] for {set j 0} {$j < 10000} {incr j} { - run_script_on_connection $rd {return redis.call("incr",KEYS[1])} 1 x + run_script_on_connection $rd {return redict.call("incr",KEYS[1])} 1 x } for {set j 0} {$j < 10000} {incr j} { $rd read @@ -767,11 +767,11 @@ start_server {tags {"scripting"}} { r sadd myset ppp r del myset r sadd myset a b c - assert {[r eval {return redis.call('spop', 'myset')} 0] ne {}} - assert {[r eval {return redis.call('spop', 'myset', 1)} 0] ne {}} - assert {[r eval {return redis.call('spop', KEYS[1])} 1 myset] ne {}} + assert {[r eval {return redict.call('spop', 'myset')} 0] ne {}} + assert {[r eval {return redict.call('spop', 'myset', 1)} 0] ne {}} + assert {[r eval {return redict.call('spop', KEYS[1])} 1 myset] ne {}} # this one below should not be replicated - assert {[r eval {return redis.call('spop', KEYS[1])} 1 myset] eq {}} + assert {[r eval {return redict.call('spop', KEYS[1])} 1 myset] eq {}} r set trailingkey 1 assert_replication_stream $repl { {select *} @@ -790,7 +790,7 @@ start_server {tags {"scripting"}} { set repl [attach_to_replication_stream] r mset a{t} 1 b{t} 2 c{t} 3 d{t} 4 #read-only, won't be replicated - assert {[r eval {return redis.call('mget', 'a{t}', 'b{t}', 'c{t}', 'd{t}')} 0] eq {1 2 3 4}} + assert {[r eval {return redict.call('mget', 'a{t}', 'b{t}', 'c{t}', 'd{t}')} 0] eq {1 2 3 4}} r set trailingkey 2 assert_replication_stream $repl { {select *} @@ -804,7 +804,7 @@ start_server {tags {"scripting"}} { set repl [attach_to_replication_stream] r set expirekey 1 #should be replicated as EXPIREAT - assert {[r eval {return redis.call('expire', KEYS[1], ARGV[1])} 1 expirekey 3] eq 1} + assert {[r eval {return redict.call('expire', KEYS[1], ARGV[1])} 1 expirekey 3] eq 1} assert_replication_stream $repl { {select *} @@ -823,11 +823,11 @@ start_server {tags {"scripting"}} { start_server {tags {"scripting"}} { set repl [attach_to_replication_stream] # a command with 5 argsument - r eval {redis.call('hmget', KEYS[1], 1, 2, 3)} 1 key + r eval {redict.call('hmget', KEYS[1], 1, 2, 3)} 1 key # then a command with 3 that is replicated as one with 4 - r eval {redis.call('incrbyfloat', KEYS[1], 1)} 1 key + r eval {redict.call('incrbyfloat', KEYS[1], 1)} 1 key # then a command with 4 args - r eval {redis.call('set', KEYS[1], '1', 'KEEPTTL')} 1 key + r eval {redict.call('set', KEYS[1], '1', 'KEEPTTL')} 1 key assert_replication_stream $repl { {select *} @@ -844,27 +844,27 @@ start_server {tags {"scripting"}} { run_script { local i local x={} - redis.call('del','mylist') + redict.call('del','mylist') for i=1,100 do table.insert(x,i) end - redis.call('rpush','mylist',unpack(x)) - return redis.call('lrange','mylist',0,-1) + redict.call('rpush','mylist',unpack(x)) + return redict.call('lrange','mylist',0,-1) } 1 mylist } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100} test {Number conversion precision test (issue #1118)} { run_script { local value = 9007199254740991 - redis.call("set","foo",value) - return redis.call("get","foo") + redict.call("set","foo",value) + return redict.call("get","foo") } 1 foo } {9007199254740991} test {String containing number precision test (regression of issue #1118)} { run_script { - redis.call("set", "key", "12039611435714932082") - return redis.call("get", "key") + redict.call("set", "key", "12039611435714932082") + return redict.call("get", "key") } 1 key } {12039611435714932082} @@ -874,18 +874,18 @@ start_server {tags {"scripting"}} { } {ERR Number of keys can't be negative} test {Scripts can handle commands with incorrect arity} { - assert_error "ERR Wrong number of args calling Redict command from script*" {run_script "redis.call('set','invalid')" 0} - assert_error "ERR Wrong number of args calling Redict command from script*" {run_script "redis.call('incr')" 0} + assert_error "ERR Wrong number of args calling Redict command from script*" {run_script "redict.call('set','invalid')" 0} + assert_error "ERR Wrong number of args calling Redict command from script*" {run_script "redict.call('incr')" 0} } test {Correct handling of reused argv (issue #1939)} { run_script { for i = 0, 10 do - redis.call('SET', 'a{t}', '1') - redis.call('MGET', 'a{t}', 'b{t}', 'c{t}') - redis.call('EXPIRE', 'a{t}', 0) - redis.call('GET', 'a{t}') - redis.call('MGET', 'a{t}', 'b{t}', 'c{t}') + redict.call('SET', 'a{t}', '1') + redict.call('MGET', 'a{t}', 'b{t}', 'c{t}') + redict.call('EXPIRE', 'a{t}', 0) + redict.call('GET', 'a{t}') + redict.call('MGET', 'a{t}', 'b{t}', 'c{t}') end } 3 a{t} b{t} c{t} } @@ -893,7 +893,7 @@ start_server {tags {"scripting"}} { test {Functions in the Redict namespace are able to report errors} { catch { run_script { - redis.sha1hex() + redict.sha1hex() } 0 } e set e @@ -902,7 +902,7 @@ start_server {tags {"scripting"}} { test {CLUSTER RESET can not be invoke from within a script} { catch { run_script { - redis.call('cluster', 'reset', 'hard') + redict.call('cluster', 'reset', 'hard') } 0 } e set _ $e @@ -919,16 +919,16 @@ start_server {tags {"scripting"}} { assert_equal $res $expected_dict # Test RESP3 client with script in both RESP2 and RESP3 modes - set res [run_script {redis.setresp(3); return redis.call('hgetall', KEYS[1])} 1 hash] + set res [run_script {redict.setresp(3); return redict.call('hgetall', KEYS[1])} 1 hash] assert_equal $res $expected_dict - set res [run_script {redis.setresp(2); return redis.call('hgetall', KEYS[1])} 1 hash] + set res [run_script {redict.setresp(2); return redict.call('hgetall', KEYS[1])} 1 hash] assert_equal $res $expected_list # Test RESP2 client with script in both RESP2 and RESP3 modes r HELLO 2 - set res [run_script {redis.setresp(3); return redis.call('hgetall', KEYS[1])} 1 hash] + set res [run_script {redict.setresp(3); return redict.call('hgetall', KEYS[1])} 1 hash] assert_equal $res $expected_list - set res [run_script {redis.setresp(2); return redis.call('hgetall', KEYS[1])} 1 hash] + set res [run_script {redict.setresp(2); return redict.call('hgetall', KEYS[1])} 1 hash] assert_equal $res $expected_list } {} {resp3} @@ -956,17 +956,17 @@ start_server {tags {"scripting"}} { for i=1,7999 do a[i] = 1 end - return redis.call("lpush", "l", unpack(a)) + return redict.call("lpush", "l", unpack(a)) } 1 l } {7999} test "Script read key with expiration set" { r SET key value EX 10 assert_equal [run_script { - if redis.call("EXISTS", "key") then - return redis.call("GET", "key") + if redict.call("EXISTS", "key") then + return redict.call("GET", "key") else - return redis.call("EXISTS", "key") + return redict.call("EXISTS", "key") end } 1 key] "value" } @@ -974,34 +974,34 @@ start_server {tags {"scripting"}} { test "Script del key with expiration set" { r SET key value EX 10 assert_equal [run_script { - redis.call("DEL", "key") - return redis.call("EXISTS", "key") + redict.call("DEL", "key") + return redict.call("EXISTS", "key") } 1 key] 0 } - + test "Script ACL check" { r acl setuser bob on {>123} {+@scripting} {+set} {~x*} assert_equal [r auth bob 123] {OK} - + # Check permission granted assert_equal [run_script { - return redis.acl_check_cmd('set','xx',1) + return redict.acl_check_cmd('set','xx',1) } 1 xx] 1 # Check permission denied unauthorised command assert_equal [run_script { - return redis.acl_check_cmd('hset','xx','f',1) + return redict.acl_check_cmd('hset','xx','f',1) } 1 xx] {} - + # Check permission denied unauthorised key # Note: we don't pass the "yy" key as an argument to the script so key acl checks won't block the script assert_equal [run_script { - return redis.acl_check_cmd('set','yy',1) + return redict.acl_check_cmd('set','yy',1) } 0] {} # Check error due to invalid command assert_error {ERR *Invalid command passed to redict.acl_check_cmd()*} {run_script { - return redis.acl_check_cmd('invalid-cmd','arg') + return redict.acl_check_cmd('invalid-cmd','arg') } 0} } @@ -1051,7 +1051,7 @@ start_server {tags {"scripting"}} { test "Try trick readonly table on redict table" { catch { run_script { - redis.call = function() return 1 end + redict.call = function() return 1 end } 0 } e set _ $e @@ -1131,7 +1131,7 @@ start_server {tags {"scripting"}} { test {Timedout read-only scripts can be killed by SCRIPT KILL even when use pcall} { set rd [redict_deferring_client] r config set lua-time-limit 10 - run_script_on_connection $rd {local f = function() while 1 do redis.call('ping') end end while 1 do pcall(f) end} 0 + run_script_on_connection $rd {local f = function() while 1 do redict.call('ping') end end while 1 do pcall(f) end} 0 wait_for_condition 50 100 { [catch {r ping} e] == 1 @@ -1161,13 +1161,13 @@ start_server {tags {"scripting"}} { r config set lua-time-limit 10 # senging (in a pipeline): - # 1. eval "while 1 do redis.call('ping') end" 0 + # 1. eval "while 1 do redict.call('ping') end" 0 # 2. ping if {$is_eval == 1} { - set buf "*3\r\n\$4\r\neval\r\n\$33\r\nwhile 1 do redis.call('ping') end\r\n\$1\r\n0\r\n" + set buf "*3\r\n\$4\r\neval\r\n\$34\r\nwhile 1 do redict.call('ping') end\r\n\$1\r\n0\r\n" append buf "*1\r\n\$4\r\nping\r\n" } else { - set buf "*4\r\n\$8\r\nfunction\r\n\$4\r\nload\r\n\$7\r\nreplace\r\n\$97\r\n#!lua name=test\nredis.register_function('test', function() while 1 do redis.call('ping') end end)\r\n" + set buf "*4\r\n\$8\r\nfunction\r\n\$4\r\nload\r\n\$7\r\nreplace\r\n\$99\r\n#!lua name=test\nredict.register_function('test', function() while 1 do redict.call('ping') end end)\r\n" append buf "*3\r\n\$5\r\nfcall\r\n\$4\r\ntest\r\n\$1\r\n0\r\n" append buf "*1\r\n\$4\r\nping\r\n" } @@ -1206,7 +1206,7 @@ start_server {tags {"scripting"}} { test {Timedout script link is still usable after Lua returns} { r config set lua-time-limit 10 - run_script {for i=1,100000 do redis.call('ping') end return 'ok'} 0 + run_script {for i=1,100000 do redict.call('ping') end return 'ok'} 0 r ping } {PONG} @@ -1229,12 +1229,12 @@ start_server {tags {"scripting"}} { r config set lua-time-limit 10 run_script_on_connection $rd { local clients - redis.call('lpush',KEYS[1],'y'); + redict.call('lpush',KEYS[1],'y'); while true do - clients = redis.call('client','list') + clients = redict.call('client','list') if string.find(clients, 'abortscript') ~= nil then break end end - redis.call('lpush',KEYS[1],'z'); + redict.call('lpush',KEYS[1],'z'); return clients } 1 x @@ -1260,7 +1260,7 @@ start_server {tags {"scripting"}} { test {Timedout scripts that modified data can't be killed by SCRIPT KILL} { set rd [redict_deferring_client] r config set lua-time-limit 10 - run_script_on_connection $rd {redis.call('set',KEYS[1],'y'); while true do end} 1 x + run_script_on_connection $rd {redict.call('set',KEYS[1],'y'); while true do end} 1 x after 200 catch {r ping} e assert_match {BUSY*} $e @@ -1287,13 +1287,13 @@ start_server {tags {"scripting"}} { start_server {} { test "Before the replica connects we issue two EVAL commands" { # One with an error, but still executing a command. - # SHA is: 67164fc43fa971f76fd1aaeeaf60c1c178d25876 + # SHA is: 40451e526b59fb3baaefb18d34ed740f2e4466c9 catch { - run_script {redis.call('incr',KEYS[1]); redis.call('nonexisting')} 1 x + run_script {redict.call('incr',KEYS[1]); redict.call('nonexisting')} 1 x } # One command is correct: - # SHA is: 6f5ade10a69975e903c6d07b10ea44c6382381a5 - run_script {return redis.call('incr',KEYS[1])} 1 x + # SHA is: e4bad7bdbe1f444d8d00c799668fff27e27e7c65 + run_script {return redict.call('incr',KEYS[1])} 1 x } {2} test "Connect a replica to the master instance" { @@ -1311,9 +1311,9 @@ start_server {tags {"scripting"}} { # The server should replicate successful and unsuccessful # commands as EVAL instead of EVALSHA. catch { - r evalsha 67164fc43fa971f76fd1aaeeaf60c1c178d25876 1 x + r evalsha 40451e526b59fb3baaefb18d34ed740f2e4466c9 1 x } - r evalsha 6f5ade10a69975e903c6d07b10ea44c6382381a5 1 x + r evalsha e4bad7bdbe1f444d8d00c799668fff27e27e7c65 1 x } {4} test "'x' should be '4' for EVALSHA being replicated by effects" { @@ -1329,8 +1329,8 @@ start_server {tags {"scripting"}} { set rd [redict_deferring_client] $rd brpop a 0 run_script { - redis.call("lpush",KEYS[1],"1"); - redis.call("lpush",KEYS[1],"2"); + redict.call("lpush",KEYS[1],"1"); + redict.call("lpush",KEYS[1],"2"); } 1 a set res [$rd read] $rd close @@ -1345,9 +1345,9 @@ start_server {tags {"scripting"}} { if {$is_eval eq 1} { test "EVALSHA replication when first call is readonly" { r del x - r eval {if tonumber(ARGV[1]) > 0 then redis.call('incr', KEYS[1]) end} 1 x 0 - r evalsha 6e0e2745aa546d0b50b801a20983b70710aef3ce 1 x 0 - r evalsha 6e0e2745aa546d0b50b801a20983b70710aef3ce 1 x 1 + r eval {if tonumber(ARGV[1]) > 0 then redict.call('incr', KEYS[1]) end} 1 x 0 + r evalsha f3d81f4d2aeb2087b2349f2951e42b421fcbdd28 1 x 0 + r evalsha f3d81f4d2aeb2087b2349f2951e42b421fcbdd28 1 x 1 wait_for_condition 50 100 { [r -1 get x] eq {1} } else { @@ -1358,18 +1358,18 @@ start_server {tags {"scripting"}} { test "Lua scripts using SELECT are replicated correctly" { run_script { - redis.call("set","foo1","bar1") - redis.call("select","10") - redis.call("incr","x") - redis.call("select","11") - redis.call("incr","z") + redict.call("set","foo1","bar1") + redict.call("select","10") + redict.call("incr","x") + redict.call("select","11") + redict.call("incr","z") } 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") + redict.call("set","foo1","bar1") + redict.call("select","10") + redict.call("incr","x") + redict.call("select","11") + redict.call("incr","z") } 3 foo1 x z wait_for_condition 50 100 { [debug_digest -1] eq [debug_digest] @@ -1393,26 +1393,26 @@ start_server {tags {"scripting repl external:skip"}} { } # replicate_commands is the default on Redict Function - test "redis.replicate_commands() can be issued anywhere now" { + test "redict.replicate_commands() can be issued anywhere now" { r eval { - redis.call('set','foo','bar'); - return redis.replicate_commands(); + redict.call('set','foo','bar'); + return redict.replicate_commands(); } 0 } {1} - test "redis.set_repl() can be issued before replicate_commands() now" { + test "redict.set_repl() can be issued before replicate_commands() now" { catch { r eval { - redis.set_repl(redis.REPL_ALL); + redict.set_repl(redict.REPL_ALL); } 0 } e set e } {} - test "redis.set_repl() don't accept invalid values" { + test "redict.set_repl() don't accept invalid values" { catch { run_script { - redis.set_repl(12345); + redict.set_repl(12345); } 0 } e set e @@ -1421,13 +1421,13 @@ start_server {tags {"scripting repl external:skip"}} { test "Test selective replication of certain Redict commands from Lua" { r del a b c d run_script { - redis.call('set','a','1'); - redis.set_repl(redis.REPL_NONE); - redis.call('set','b','2'); - redis.set_repl(redis.REPL_AOF); - redis.call('set','c','3'); - redis.set_repl(redis.REPL_ALL); - redis.call('set','d','4'); + redict.call('set','a','1'); + redict.set_repl(redict.REPL_NONE); + redict.call('set','b','2'); + redict.set_repl(redict.REPL_AOF); + redict.call('set','c','3'); + redict.set_repl(redict.REPL_ALL); + redict.call('set','d','4'); } 4 a b c d wait_for_condition 50 100 { @@ -1447,16 +1447,16 @@ start_server {tags {"scripting repl external:skip"}} { test "PRNG is seeded randomly for command replication" { if {$is_eval eq 1} { - # on is_eval Lua we need to call redis.replicate_commands() to get real randomization + # on is_eval Lua we need to call redict.replicate_commands() to get real randomization set a [ run_script { - redis.replicate_commands() + redict.replicate_commands() return math.random()*100000; } 0 ] set b [ run_script { - redis.replicate_commands() + redict.replicate_commands() return math.random()*100000; } 0 ] @@ -1477,7 +1477,7 @@ start_server {tags {"scripting repl external:skip"}} { test "Using side effects is not a problem with command replication" { run_script { - redis.call('set','time',redis.call('time')[1]) + redict.call('set','time',redict.call('time')[1]) } 0 assert {[r get time] ne {}} @@ -1515,7 +1515,7 @@ start_server {tags {"scripting needs:debug external:skip"}} { test {Test scripting debug lua stack overflow} { r script debug sync r eval {return 'hello'} 0 - set cmd "*101\r\n\$5\r\nredis\r\n" + set cmd "*101\r\n\$6\r\nredict\r\n" append cmd [string repeat "\$4\r\ntest\r\n" 100] r write $cmd r flush @@ -1630,7 +1630,7 @@ start_server {tags {"scripting needs:debug"}} { r readraw 1 test "test $extra big number protocol parsing" { - set ret [run_script "redis.setresp($i);return redis.call('debug', 'protocol', 'bignum')" 0] + set ret [run_script "redict.setresp($i);return redict.call('debug', 'protocol', 'bignum')" 0] if {$client_proto == 2 || $i == 2} { # if either Lua or the client is RESP2 the reply will be RESP2 assert_equal $ret {$37} @@ -1652,7 +1652,7 @@ start_server {tags {"scripting needs:debug"}} { } test "test $extra map protocol parsing" { - set ret [run_script "redis.setresp($i);return redis.call('debug', 'protocol', 'map')" 0] + set ret [run_script "redict.setresp($i);return redict.call('debug', 'protocol', 'map')" 0] if {$client_proto == 2 || $i == 2} { # if either Lua or the client is RESP2 the reply will be RESP2 assert_equal $ret {*6} @@ -1665,7 +1665,7 @@ start_server {tags {"scripting needs:debug"}} { } test "test $extra set protocol parsing" { - set ret [run_script "redis.setresp($i);return redis.call('debug', 'protocol', 'set')" 0] + set ret [run_script "redict.setresp($i);return redict.call('debug', 'protocol', 'set')" 0] if {$client_proto == 2 || $i == 2} { # if either Lua or the client is RESP2 the reply will be RESP2 assert_equal $ret {*3} @@ -1678,7 +1678,7 @@ start_server {tags {"scripting needs:debug"}} { } test "test $extra double protocol parsing" { - set ret [run_script "redis.setresp($i);return redis.call('debug', 'protocol', 'double')" 0] + set ret [run_script "redict.setresp($i);return redict.call('debug', 'protocol', 'double')" 0] if {$client_proto == 2 || $i == 2} { # if either Lua or the client is RESP2 the reply will be RESP2 assert_equal $ret {$5} @@ -1689,7 +1689,7 @@ start_server {tags {"scripting needs:debug"}} { } test "test $extra null protocol parsing" { - set ret [run_script "redis.setresp($i);return redis.call('debug', 'protocol', 'null')" 0] + set ret [run_script "redict.setresp($i);return redict.call('debug', 'protocol', 'null')" 0] if {$client_proto == 2} { # null is a special case in which a Lua client format does not effect the reply to the client assert_equal $ret {$-1} @@ -1699,7 +1699,7 @@ start_server {tags {"scripting needs:debug"}} { } {} test "test $extra verbatim protocol parsing" { - set ret [run_script "redis.setresp($i);return redis.call('debug', 'protocol', 'verbatim')" 0] + set ret [run_script "redict.setresp($i);return redict.call('debug', 'protocol', 'verbatim')" 0] if {$client_proto == 2 || $i == 2} { # if either Lua or the client is RESP2 the reply will be RESP2 assert_equal $ret {$25} @@ -1713,7 +1713,7 @@ start_server {tags {"scripting needs:debug"}} { } test "test $extra true protocol parsing" { - set ret [run_script "redis.setresp($i);return redis.call('debug', 'protocol', 'true')" 0] + set ret [run_script "redict.setresp($i);return redict.call('debug', 'protocol', 'true')" 0] if {$client_proto == 2 || $i == 2} { # if either Lua or the client is RESP2 the reply will be RESP2 assert_equal $ret {:1} @@ -1723,7 +1723,7 @@ start_server {tags {"scripting needs:debug"}} { } test "test $extra false protocol parsing" { - set ret [run_script "redis.setresp($i);return redis.call('debug', 'protocol', 'false')" 0] + set ret [run_script "redict.setresp($i);return redict.call('debug', 'protocol', 'false')" 0] if {$client_proto == 2 || $i == 2} { # if either Lua or the client is RESP2 the reply will be RESP2 assert_equal $ret {:0} @@ -1741,14 +1741,14 @@ start_server {tags {"scripting needs:debug"}} { test {test resp3 attribute protocol parsing} { # attributes are not (yet) expose to the script # So here we just check the parser handles them and they are ignored. - run_script "redis.setresp(3);return redis.call('debug', 'protocol', 'attrib')" 0 + run_script "redict.setresp(3);return redict.call('debug', 'protocol', 'attrib')" 0 } {Some real reply following the attribute} test "Script block the time during execution" { assert_equal [run_script { - redis.call("SET", "key", "value", "PX", "1") - redis.call("DEBUG", "SLEEP", 0.01) - return redis.call("EXISTS", "key") + redict.call("SET", "key", "value", "PX", "1") + redict.call("DEBUG", "SLEEP", 0.01) + return redict.call("EXISTS", "key") } 1 key] 1 assert_equal 0 [r EXISTS key] @@ -1762,16 +1762,16 @@ 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')} 1 key] 0 + assert_equal [run_script {return redict.call('EXISTS', 'key')} 1 key] 0 assert_equal 0 [r EXISTS key] r DEBUG set-active-expire 1 } test "TIME command using cached time" { set res [run_script { - local result1 = {redis.call("TIME")} - redis.call("DEBUG", "SLEEP", 0.01) - local result2 = {redis.call("TIME")} + local result1 = {redict.call("TIME")} + redict.call("DEBUG", "SLEEP", 0.01) + local result2 = {redict.call("TIME")} return {result1, result2} } 0] assert_equal [lindex $res 0] [lindex $res 1] @@ -1782,69 +1782,69 @@ start_server {tags {"scripting needs:debug"}} { # and interspersed with "DEBUG SLEEP", to verify that time is frozen in script. # The commands involved are [P]TTL / SET EX[PX] / [P]EXPIRE / GETEX / [P]SETEX / [P]EXPIRETIME set res [run_script { - redis.call("SET", "key1{t}", "value", "EX", 1) - redis.call("DEBUG", "SLEEP", 0.01) + redict.call("SET", "key1{t}", "value", "EX", 1) + redict.call("DEBUG", "SLEEP", 0.01) - redis.call("SET", "key2{t}", "value", "PX", 1000) - redis.call("DEBUG", "SLEEP", 0.01) + redict.call("SET", "key2{t}", "value", "PX", 1000) + redict.call("DEBUG", "SLEEP", 0.01) - redis.call("SET", "key3{t}", "value") - redis.call("EXPIRE", "key3{t}", 1) - redis.call("DEBUG", "SLEEP", 0.01) + redict.call("SET", "key3{t}", "value") + redict.call("EXPIRE", "key3{t}", 1) + redict.call("DEBUG", "SLEEP", 0.01) - redis.call("SET", "key4{t}", "value") - redis.call("PEXPIRE", "key4{t}", 1000) - redis.call("DEBUG", "SLEEP", 0.01) + redict.call("SET", "key4{t}", "value") + redict.call("PEXPIRE", "key4{t}", 1000) + redict.call("DEBUG", "SLEEP", 0.01) - redis.call("SETEX", "key5{t}", 1, "value") - redis.call("DEBUG", "SLEEP", 0.01) + redict.call("SETEX", "key5{t}", 1, "value") + redict.call("DEBUG", "SLEEP", 0.01) - redis.call("PSETEX", "key6{t}", 1000, "value") - redis.call("DEBUG", "SLEEP", 0.01) + redict.call("PSETEX", "key6{t}", 1000, "value") + redict.call("DEBUG", "SLEEP", 0.01) - redis.call("SET", "key7{t}", "value") - redis.call("GETEX", "key7{t}", "EX", 1) - redis.call("DEBUG", "SLEEP", 0.01) + redict.call("SET", "key7{t}", "value") + redict.call("GETEX", "key7{t}", "EX", 1) + redict.call("DEBUG", "SLEEP", 0.01) - redis.call("SET", "key8{t}", "value") - redis.call("GETEX", "key8{t}", "PX", 1000) - redis.call("DEBUG", "SLEEP", 0.01) + redict.call("SET", "key8{t}", "value") + redict.call("GETEX", "key8{t}", "PX", 1000) + redict.call("DEBUG", "SLEEP", 0.01) - local ttl_results = {redis.call("TTL", "key1{t}"), - redis.call("TTL", "key2{t}"), - redis.call("TTL", "key3{t}"), - redis.call("TTL", "key4{t}"), - redis.call("TTL", "key5{t}"), - redis.call("TTL", "key6{t}"), - redis.call("TTL", "key7{t}"), - redis.call("TTL", "key8{t}")} + local ttl_results = {redict.call("TTL", "key1{t}"), + redict.call("TTL", "key2{t}"), + redict.call("TTL", "key3{t}"), + redict.call("TTL", "key4{t}"), + redict.call("TTL", "key5{t}"), + redict.call("TTL", "key6{t}"), + redict.call("TTL", "key7{t}"), + redict.call("TTL", "key8{t}")} - local pttl_results = {redis.call("PTTL", "key1{t}"), - redis.call("PTTL", "key2{t}"), - redis.call("PTTL", "key3{t}"), - redis.call("PTTL", "key4{t}"), - redis.call("PTTL", "key5{t}"), - redis.call("PTTL", "key6{t}"), - redis.call("PTTL", "key7{t}"), - redis.call("PTTL", "key8{t}")} + local pttl_results = {redict.call("PTTL", "key1{t}"), + redict.call("PTTL", "key2{t}"), + redict.call("PTTL", "key3{t}"), + redict.call("PTTL", "key4{t}"), + redict.call("PTTL", "key5{t}"), + redict.call("PTTL", "key6{t}"), + redict.call("PTTL", "key7{t}"), + redict.call("PTTL", "key8{t}")} - local expiretime_results = {redis.call("EXPIRETIME", "key1{t}"), - redis.call("EXPIRETIME", "key2{t}"), - redis.call("EXPIRETIME", "key3{t}"), - redis.call("EXPIRETIME", "key4{t}"), - redis.call("EXPIRETIME", "key5{t}"), - redis.call("EXPIRETIME", "key6{t}"), - redis.call("EXPIRETIME", "key7{t}"), - redis.call("EXPIRETIME", "key8{t}")} + local expiretime_results = {redict.call("EXPIRETIME", "key1{t}"), + redict.call("EXPIRETIME", "key2{t}"), + redict.call("EXPIRETIME", "key3{t}"), + redict.call("EXPIRETIME", "key4{t}"), + redict.call("EXPIRETIME", "key5{t}"), + redict.call("EXPIRETIME", "key6{t}"), + redict.call("EXPIRETIME", "key7{t}"), + redict.call("EXPIRETIME", "key8{t}")} - local pexpiretime_results = {redis.call("PEXPIRETIME", "key1{t}"), - redis.call("PEXPIRETIME", "key2{t}"), - redis.call("PEXPIRETIME", "key3{t}"), - redis.call("PEXPIRETIME", "key4{t}"), - redis.call("PEXPIRETIME", "key5{t}"), - redis.call("PEXPIRETIME", "key6{t}"), - redis.call("PEXPIRETIME", "key7{t}"), - redis.call("PEXPIRETIME", "key8{t}")} + local pexpiretime_results = {redict.call("PEXPIRETIME", "key1{t}"), + redict.call("PEXPIRETIME", "key2{t}"), + redict.call("PEXPIRETIME", "key3{t}"), + redict.call("PEXPIRETIME", "key4{t}"), + redict.call("PEXPIRETIME", "key5{t}"), + redict.call("PEXPIRETIME", "key6{t}"), + redict.call("PEXPIRETIME", "key7{t}"), + redict.call("PEXPIRETIME", "key8{t}")} return {ttl_results, pttl_results, expiretime_results, pexpiretime_results} } 8 key1{t} key2{t} key3{t} key4{t} key5{t} key6{t} key7{t} key8{t}] @@ -1864,14 +1864,14 @@ start_server {tags {"scripting needs:debug"}} { test "RESTORE expired keys with expiration time" { set res [run_script { - redis.call("SET", "key1{t}", "value") - local encoded = redis.call("DUMP", "key1{t}") + redict.call("SET", "key1{t}", "value") + local encoded = redict.call("DUMP", "key1{t}") - redis.call("RESTORE", "key2{t}", 1, encoded, "REPLACE") - redis.call("DEBUG", "SLEEP", 0.01) - redis.call("RESTORE", "key3{t}", 1, encoded, "REPLACE") + redict.call("RESTORE", "key2{t}", 1, encoded, "REPLACE") + redict.call("DEBUG", "SLEEP", 0.01) + redict.call("RESTORE", "key3{t}", 1, encoded, "REPLACE") - return {redis.call("PEXPIRETIME", "key2{t}"), redis.call("PEXPIRETIME", "key3{t}")} + return {redict.call("PEXPIRETIME", "key2{t}"), redict.call("PEXPIRETIME", "key3{t}")} } 3 key1{t} key2{t} key3{t}] # Can get the expiration time and they are all equal. @@ -1919,20 +1919,20 @@ start_server {tags {"scripting"}} { test "allow-oom shebang flag" { r set x 123 - + r config set maxmemory 1 # Fail to execute deny-oom command in OOM condition (backwards compatibility mode without flags) assert_error {OOM command not allowed when used memory > 'maxmemory'*} { r eval { - redis.call('set','x',1) + redict.call('set','x',1) return 1 } 1 x } # Can execute non deny-oom commands in OOM condition (backwards compatibility mode without flags) assert_equal [ r eval { - return redis.call('get','x') + return redict.call('get','x') } 1 x ] {123} @@ -1946,7 +1946,7 @@ start_server {tags {"scripting"}} { # Script with allow-oom can write despite being in OOM state assert_equal [ r eval {#!lua flags=allow-oom - redis.call('set','x',1) + redict.call('set','x',1) return 1 } 1 x ] 1 @@ -1954,13 +1954,13 @@ start_server {tags {"scripting"}} { # read-only scripts implies allow-oom assert_equal [ r eval {#!lua flags=no-writes - redis.call('get','x') + redict.call('get','x') return 1 } 0 ] 1 assert_equal [ r eval_ro {#!lua flags=no-writes - redis.call('get','x') + redict.call('get','x') return 1 } 1 x ] 1 @@ -1968,7 +1968,7 @@ start_server {tags {"scripting"}} { # Script with no shebang can read in OOM state assert_equal [ r eval { - redis.call('get','x') + redict.call('get','x') return 1 } 1 x ] 1 @@ -1976,7 +1976,7 @@ start_server {tags {"scripting"}} { # Script with no shebang can read in OOM state (eval_ro variant) assert_equal [ r eval_ro { - redis.call('get','x') + redict.call('get','x') return 1 } 1 x ] 1 @@ -1987,12 +1987,12 @@ start_server {tags {"scripting"}} { test "no-writes shebang flag" { assert_error {ERR Write commands are not allowed from read-only scripts*} { r eval {#!lua flags=no-writes - redis.call('set','x',1) + redict.call('set','x',1) return 1 } 1 x } } - + start_server {tags {"external:skip"}} { r -1 set x "some value" test "no-writes shebang flag on replica" { @@ -2006,20 +2006,20 @@ start_server {tags {"scripting"}} { assert_equal [ r eval {#!lua flags=no-writes - return redis.call('get','x') + return redict.call('get','x') } 1 x ] "some value" assert_error {READONLY You can't write against a read only replica.} { r eval {#!lua - return redis.call('get','x') + return redict.call('get','x') } 1 x } # test no-write inside multi-exec r multi r eval {#!lua flags=no-writes - redis.call('get','x') + redict.call('get','x') return 1 } 1 x assert_equal [r exec] 1 @@ -2027,7 +2027,7 @@ start_server {tags {"scripting"}} { # test no shebang without write inside multi-exec r multi r eval { - redis.call('get','x') + redict.call('get','x') return 1 } 1 x assert_equal [r exec] 1 @@ -2048,7 +2048,7 @@ start_server {tags {"scripting"}} { # test no shebang with write inside multi-exec $rr2 eval { - redis.call('set','x',1) + redict.call('set','x',1) return 1 } 1 x @@ -2066,25 +2066,25 @@ start_server {tags {"scripting"}} { assert_equal [ r eval {#!lua flags=no-writes - return redis.call('get','x') + return redict.call('get','x') } 1 x ] "some value" assert_equal [ r eval { - return redis.call('get','x') + return redict.call('get','x') } 1 x ] "some value" assert_error {NOREPLICAS *} { r eval {#!lua - return redis.call('get','x') + return redict.call('get','x') } 1 x } assert_error {NOREPLICAS *} { r eval { - return redis.call('set','x', 1) + return redict.call('set','x', 1) } 1 x } @@ -2104,11 +2104,11 @@ start_server {tags {"scripting"}} { # that the replica dropped, and then runs another write set rd [redict_deferring_client -1] $rd eval { - redis.call('set','x',"script value") + redict.call('set','x',"script value") while true do - local info = redis.call('info','replication') + local info = redict.call('info','replication') if (string.match(info, "connected_slaves:0")) then - redis.call('set','x',info) + redict.call('set','x',info) break end end @@ -2143,7 +2143,7 @@ start_server {tags {"scripting"}} { assert_error {MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'.} { r eval { - return redis.call('get','x') + return redict.call('get','x') } 1 x } @@ -2162,24 +2162,24 @@ start_server {tags {"scripting"}} { assert_error {*Can not execute the command on a stale replica*} { r eval {#!lua flags=allow-stale,no-writes - return redis.call('get','x') + return redict.call('get','x') } 1 x } - + assert_match {foobar} [ r eval {#!lua flags=allow-stale,no-writes - return redis.call('echo','foobar') + return redict.call('echo','foobar') } 0 ] - + # Test again with EVALSHA set sha [ r script load {#!lua flags=allow-stale,no-writes - return redis.call('echo','foobar') + return redict.call('echo','foobar') } ] assert_match {foobar} [r evalsha $sha 0] - + r replicaof no one r config set replica-serve-stale-data yes set _ {} @@ -2206,18 +2206,18 @@ start_server {tags {"scripting"}} { r config set maxmemory 1 # Script aborted due to Redict state (OOM) should report script execution error with detailed internal error assert_error {OOM command not allowed when used memory > 'maxmemory'*} { - r eval {return redis.call('set','x','y')} 1 x + r eval {return redict.call('set','x','y')} 1 x } assert_equal [errorrstat OOM r] {count=1} assert_equal [s total_error_replies] {1} assert_match {calls=0*rejected_calls=1,failed_calls=0*} [cmdrstat set r] assert_match {calls=1*rejected_calls=0,failed_calls=1*} [cmdrstat eval r] - # redis.pcall() failure due to Redict state (OOM) returns lua error table with Redict error message without '-' prefix + # redict.pcall() failure due to Redict state (OOM) returns lua error table with Redict error message without '-' prefix r config resetstat assert_equal [ r eval { - local t = redis.pcall('set','x','y') + local t = redict.pcall('set','x','y') if t['err'] == "OOM command not allowed when used memory > 'maxmemory'." then return 1 else @@ -2231,11 +2231,11 @@ start_server {tags {"scripting"}} { assert_equal [s total_error_replies] {1} assert_match {calls=0*rejected_calls=1,failed_calls=0*} [cmdrstat set r] assert_match {calls=1*rejected_calls=0,failed_calls=0*} [cmdrstat eval r] - + # Returning an error object from lua is handled as a valid RESP error result. r config resetstat assert_error {OOM command not allowed when used memory > 'maxmemory'.} { - r eval { return redis.pcall('set','x','y') } 1 x + r eval { return redict.pcall('set','x','y') } 1 x } assert_equal [errorrstat ERR r] {} assert_equal [errorrstat OOM r] {count=1} @@ -2247,18 +2247,18 @@ start_server {tags {"scripting"}} { r config resetstat # Script aborted due to error result of Redict command assert_error {ERR DB index is out of range*} { - r eval {return redis.call('select',99)} 0 + r eval {return redict.call('select',99)} 0 } assert_equal [errorrstat ERR r] {count=1} assert_equal [s total_error_replies] {1} assert_match {calls=1*rejected_calls=0,failed_calls=1*} [cmdrstat select r] assert_match {calls=1*rejected_calls=0,failed_calls=1*} [cmdrstat eval r] - - # redis.pcall() failure due to error in Redict command returns lua error table with redict error message without '-' prefix + + # redict.pcall() failure due to error in Redict command returns lua error table with redict error message without '-' prefix r config resetstat assert_equal [ r eval { - local t = redis.pcall('select',99) + local t = redict.pcall('select',99) if t['err'] == "ERR DB index is out of range" then return 1 else @@ -2274,18 +2274,18 @@ start_server {tags {"scripting"}} { # Script aborted due to scripting specific error state (write cmd with eval_ro) should report script execution error with detailed internal error r config resetstat assert_error {ERR Write commands are not allowed from read-only scripts*} { - r eval_ro {return redis.call('set','x','y')} 1 x + r eval_ro {return redict.call('set','x','y')} 1 x } assert_equal [errorrstat ERR r] {count=1} assert_equal [s total_error_replies] {1} assert_match {calls=0*rejected_calls=1,failed_calls=0*} [cmdrstat set r] assert_match {calls=1*rejected_calls=0,failed_calls=1*} [cmdrstat eval_ro r] - # redis.pcall() failure due to scripting specific error state (write cmd with eval_ro) returns lua error table with Redict error message without '-' prefix + # redict.pcall() failure due to scripting specific error state (write cmd with eval_ro) returns lua error table with Redict error message without '-' prefix r config resetstat assert_equal [ r eval_ro { - local t = redis.pcall('set','x','y') + local t = redict.pcall('set','x','y') if t['err'] == "ERR Write commands are not allowed from read-only scripts." then return 1 else @@ -2302,35 +2302,35 @@ start_server {tags {"scripting"}} { # make sure geoadd will failed r set Sicily 1 assert_error {WRONGTYPE Operation against a key holding the wrong kind of value*} { - r eval {return redis.call('GEOADD', 'Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania')} 1 x + r eval {return redict.call('GEOADD', 'Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania')} 1 x } assert_equal [errorrstat WRONGTYPE r] {count=1} assert_equal [s total_error_replies] {1} assert_match {calls=1*rejected_calls=0,failed_calls=1*} [cmdrstat geoadd r] assert_match {calls=1*rejected_calls=0,failed_calls=1*} [cmdrstat eval r] } {} {cluster:skip} - - test "LUA redis.error_reply API" { + + test "LUA redict.error_reply API" { r config resetstat assert_error {MY_ERR_CODE custom msg} { - r eval {return redis.error_reply("MY_ERR_CODE custom msg")} 0 + r eval {return redict.error_reply("MY_ERR_CODE custom msg")} 0 } assert_equal [errorrstat MY_ERR_CODE r] {count=1} } - test "LUA redis.error_reply API with empty string" { + test "LUA redict.error_reply API with empty string" { r config resetstat assert_error {ERR} { - r eval {return redis.error_reply("")} 0 + r eval {return redict.error_reply("")} 0 } assert_equal [errorrstat ERR r] {count=1} } - test "LUA redis.status_reply API" { + test "LUA redict.status_reply API" { r config resetstat r readraw 1 assert_equal [ - r eval {return redis.status_reply("MY_OK_CODE custom msg")} 0 + r eval {return redict.status_reply("MY_OK_CODE custom msg")} 0 ] {+MY_OK_CODE custom msg} r readraw 0 assert_equal [errorrstat MY_ERR_CODE r] {} ;# error stats were not incremented @@ -2352,13 +2352,13 @@ start_server {tags {"scripting"}} { assert_error "ERR Lua redict lib command arguments must be strings or integers*" { r eval { local x={} - return redis.call("ping", x) + return redict.call("ping", x) } 0 } # run another command, to make sure the cached argv array survived assert_equal [ r eval { - return redis.call("ping", "asdf") + return redict.call("ping", "asdf") } 0 ] {asdf} } @@ -2375,13 +2375,13 @@ start_server {tags {"scripting"}} { # This value will be recycled to be used in the next argument. # We use SETNX to avoid saving the string which will prevent us to reuse it in the next command. r eval { - return redis.call("SETNX", "foo", string.rep("a", 63)) + return redict.call("SETNX", "foo", string.rep("a", 63)) } 0 # Jemalloc will allocate for the request 45 bytes, 56 bytes. # we can't test for smaller sizes because OBJ_ENCODING_EMBSTR_SIZE_LIMIT is 44 where no trim is done. r eval { - return redis.call("SET", "foo", string.rep("a", 45)) + return redict.call("SET", "foo", string.rep("a", 45)) } 0 # Assert the string has been trimmed and the 80 bytes from the previous alloc were not kept. diff --git a/tests/unit/sort.tcl b/tests/unit/sort.tcl index b5acd32d3..5ad634da5 100644 --- a/tests/unit/sort.tcl +++ b/tests/unit/sort.tcl @@ -117,7 +117,7 @@ foreach command {SORT SORT_RO} { test "SORT extracts STORE correctly" { r command getkeys sort abc store def } {abc def} - + test "SORT_RO get keys" { r command getkeys sort_ro abc } {abc} @@ -185,8 +185,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 {redict.call('sort',KEYS[1],'by','nosort','asc'), + redict.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 1628fe6d4..991b137dc 100644 --- a/tests/unit/tracking.tcl +++ b/tests/unit/tracking.tcl @@ -20,7 +20,7 @@ start_server {tags {"tracking network logreqres:skip"}} { # Client to be used for SET and GET commands # We don't read this client's buffer - set rd_sg [redict_client] + set rd_sg [redict_client] proc clean_all {} { uplevel { @@ -223,7 +223,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 redict.call('set', 'key1', '2')" 1 key1 assert_equal "2" [$rd_sg GET key1] $rd_sg CLIENT TRACKING off } @@ -234,12 +234,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 "redict.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 "redict.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] @@ -247,12 +247,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 "redict.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 "redict.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] @@ -284,11 +284,11 @@ start_server {tags {"tracking network logreqres:skip"}} { test {Different clients can redirect to the same connection} { r CLIENT TRACKING on REDIRECT $redir_id - $rd CLIENT TRACKING on REDIRECT $redir_id + $rd CLIENT TRACKING on REDIRECT $redir_id assert_equal OK [$rd read] ; # Consume the TRACKING reply $rd_sg MSET key1{t} 1 key2{t} 1 r GET key1{t} - $rd GET key2{t} + $rd GET key2{t} assert_equal 1 [$rd read] ; # Consume the GET reply $rd_sg INCR key1{t} $rd_sg INCR key2{t} @@ -299,19 +299,19 @@ start_server {tags {"tracking network logreqres:skip"}} { } test {Different clients using different protocols can track the same key} { - $rd HELLO 3 + $rd HELLO 3 set reply [$rd read] ; # Consume the HELLO reply assert_equal 3 [dict get $reply proto] - $rd CLIENT TRACKING on + $rd CLIENT TRACKING on assert_equal OK [$rd read] ; # Consume the TRACKING reply $rd_sg set key1 1 r GET key1 - $rd GET key1 + $rd GET key1 assert_equal 1 [$rd read] ; # Consume the GET reply $rd_sg INCR key1 set res1 [lindex [$rd_redirection read] 2] $rd PING ; # Non redirecting client has to talk to the server in order to get invalidation message - set res2 [lindex [split [$rd read] " "] 1] + set res2 [lindex [split [$rd read] " "] 1] assert_equal PONG [$rd read] ; # Consume the PING reply, which comes together with the invalidation message assert {$res1 eq {key1}} assert {$res2 eq {key1}} @@ -346,7 +346,7 @@ start_server {tags {"tracking network logreqres:skip"}} { r CLIENT TRACKING off r CLIENT TRACKING on OPTOUT REDIRECT $redir_id $rd_sg SET key1 1 - r GET key1 + r GET key1 $rd_sg SET key1 2 set res [lindex [$rd_redirection read] 2] assert {$res eq {key1}} @@ -392,7 +392,7 @@ start_server {tags {"tracking network logreqres:skip"}} { r CLIENT TRACKING on $rd_sg SET key1 1 r GET key1 - r CLIENT TRACKING off + r CLIENT TRACKING off r CLIENT TRACKING on BCAST $rd_sg INCR key1 set inv_msg [r PING] @@ -402,7 +402,7 @@ start_server {tags {"tracking network logreqres:skip"}} { } test {BCAST with prefix collisions throw errors} { - set r [redict_client] + set r [redict_client] catch {$r CLIENT TRACKING ON BCAST PREFIX FOOBAR PREFIX FOO} output assert_match {ERR Prefix 'FOOBAR'*'FOO'*} $output @@ -587,9 +587,9 @@ start_server {tags {"tracking network logreqres:skip"}} { # Keys are defined to be evicted 100 at a time by default. # If after eviction the number of keys still surpasses the limit - # defined in tracking-table-max-keys, we increases eviction - # effort to 200, and then 300, etc. - # This test tests this effort incrementation. + # defined in tracking-table-max-keys, we increases eviction + # effort to 200, and then 300, etc. + # This test tests this effort incrementation. test {Server is able to evacuate enough keys when num of keys surpasses limit by more than defined initial effort} { clean_all set NUM_OF_KEYS_TO_TEST 250 @@ -616,11 +616,11 @@ start_server {tags {"tracking network logreqres:skip"}} { r CLIENT TRACKING on REDIRECT $redir_id $rd_sg SET key1 1 $rd_sg SET key2 2 - r GET key1 + r GET key1 r GET key2 $rd CLIENT TRACKING on BCAST PREFIX prefix: assert [string match *OK* [$rd read]] - $rd_sg SET prefix:key1 1 + $rd_sg SET prefix:key1 1 $rd_sg SET prefix:key2 2 set info [r info] regexp "\r\ntracking_total_items:(.*?)\r\n" $info _ total_items @@ -752,7 +752,7 @@ start_server {tags {"tracking network logreqres:skip"}} { test {Regression test for #11715} { # This issue manifests when a client invalidates keys through the max key # limit, which invalidates keys to get Redict below the limit, but no command is - # then executed. This can occur in several ways but the simplest is through + # then executed. This can occur in several ways but the simplest is through # multi-exec which queues commands. clean_all r config set tracking-table-max-keys 2