Unverified Commit d375595d authored by Oran Agra's avatar Oran Agra Committed by GitHub
Browse files

Merge pull request #10652 from oranagra/redis-7.0.0

Redis 7.0.0
parents fb4e0d40 c1f30206
......@@ -90,7 +90,8 @@ start_server {tags {"modules"}} {
}
}
test {Busy module command} {
foreach call_type {nested normal} {
test "Busy module command - $call_type" {
set busy_time_limit 50
set old_time_limit [lindex [r config get busy-reply-threshold] 1]
r config set busy-reply-threshold $busy_time_limit
......@@ -98,7 +99,15 @@ start_server {tags {"modules"}} {
# run command that blocks until released
set start [clock clicks -milliseconds]
if {$call_type == "nested"} {
$rd do_rm_call slow_fg_command 0
} else {
$rd slow_fg_command 0
}
$rd flush
# send another command after the blocked one, to make sure we don't attempt to process it
$rd ping
$rd flush
# make sure we get BUSY error, and that we didn't get it too early
......@@ -112,11 +121,16 @@ start_server {tags {"modules"}} {
} else {
fail "Failed waiting for busy command to end"
}
$rd read
assert_equal [$rd read] "1"
assert_equal [$rd read] "PONG"
#run command that blocks for 200ms
# run command that blocks for 200ms
set start [clock clicks -milliseconds]
if {$call_type == "nested"} {
$rd do_rm_call slow_fg_command 200000
} else {
$rd slow_fg_command 200000
}
$rd flush
after 10 ;# try to make sure redis started running the command before we proceed
......@@ -128,6 +142,7 @@ start_server {tags {"modules"}} {
$rd close
r config set busy-reply-threshold $old_time_limit
}
}
test {RM_Call from blocked client} {
set busy_time_limit 50
......@@ -141,6 +156,10 @@ start_server {tags {"modules"}} {
set start [clock clicks -milliseconds]
$rd do_bg_rm_call hgetall hash
# send another command after the blocked one, to make sure we don't attempt to process it
$rd ping
$rd flush
# wait till we know we're blocked inside the module
wait_for_condition 50 100 {
[r is_in_slow_bg_operation] eq 1
......@@ -162,10 +181,10 @@ start_server {tags {"modules"}} {
assert_equal [r ping] {PONG}
r config set busy-reply-threshold $old_time_limit
set res [$rd read]
assert_equal [$rd read] {foo bar}
assert_equal [$rd read] {PONG}
$rd close
set _ $res
} {foo bar}
}
test {blocked client reaches client output buffer limit} {
r hset hash big [string repeat x 50000]
......@@ -184,9 +203,13 @@ start_server {tags {"modules"}} {
r config resetstat
# simple module command that replies with string error
assert_error "ERR Unknown Redis command 'hgetalllll'." {r do_rm_call hgetalllll}
assert_error "ERR unknown command 'hgetalllll', with args beginning with:" {r do_rm_call hgetalllll}
assert_equal [errorrstat ERR r] {count=1}
# simple module command that replies with string error
assert_error "ERR unknown subcommand 'bla'. Try CONFIG HELP." {r do_rm_call config bla}
assert_equal [errorrstat ERR r] {count=2}
# module command that replies with string error from bg thread
assert_error "NULL reply returned" {r do_bg_rm_call hgetalllll}
assert_equal [errorrstat NULL r] {count=1}
......@@ -194,7 +217,7 @@ start_server {tags {"modules"}} {
# module command that returns an arity error
r do_rm_call set x x
assert_error "ERR wrong number of arguments for 'do_rm_call' command" {r do_rm_call}
assert_equal [errorrstat ERR r] {count=2}
assert_equal [errorrstat ERR r] {count=3}
# RM_Call that propagates an error
assert_error "WRONGTYPE*" {r do_rm_call hgetall x}
......@@ -206,8 +229,8 @@ start_server {tags {"modules"}} {
assert_equal [errorrstat WRONGTYPE r] {count=2}
assert_match {*calls=2,*,rejected_calls=0,failed_calls=2} [cmdrstat hgetall r]
assert_equal [s total_error_replies] 5
assert_match {*calls=4,*,rejected_calls=0,failed_calls=3} [cmdrstat do_rm_call r]
assert_equal [s total_error_replies] 6
assert_match {*calls=5,*,rejected_calls=0,failed_calls=4} [cmdrstat do_rm_call r]
assert_match {*calls=2,*,rejected_calls=0,failed_calls=2} [cmdrstat do_bg_rm_call r]
}
......
......@@ -2,22 +2,6 @@
source tests/support/cli.tcl
proc cluster_info {r field} {
if {[regexp "^$field:(.*?)\r\n" [$r cluster info] _ value]} {
set _ $value
}
}
# Provide easy access to CLUSTER INFO properties. Same semantic as "proc s".
proc csi {args} {
set level 0
if {[string is integer [lindex $args 0]]} {
set level [lindex $args 0]
set args [lrange $args 1 end]
}
cluster_info [srv $level "client"] [lindex $args 0]
}
set testmodule [file normalize tests/modules/blockonkeys.so]
set testmodule_nokey [file normalize tests/modules/blockonbackground.so]
set testmodule_blockedclient [file normalize tests/modules/blockedclient.so]
......
......@@ -36,6 +36,7 @@ start_server {tags {"modules"}} {
# Compare the maps. We need to pop "group" first.
dict unset redis_reply group
dict unset module_reply group
dict unset module_reply module
assert_equal $redis_reply $module_reply
}
......
......@@ -83,6 +83,17 @@ tags "modules" {
$rd1 close
}
test {Test expired key space event} {
set prev_expired [s expired_keys]
r set exp 1 PX 10
wait_for_condition 100 10 {
[s expired_keys] eq $prev_expired + 1
} else {
fail "key not expired"
}
assert_equal [r get testkeyspace:expired] 1
}
test "Unload the module - testkeyspace" {
assert_equal {OK} [r module unload testkeyspace]
}
......
set testmodule [file normalize tests/modules/mallocsize.so]
start_server {tags {"modules"}} {
r module load $testmodule
test {MallocSize of raw bytes} {
assert_equal [r mallocsize.setraw key 40] {OK}
assert_morethan [r memory usage key] 40
}
test {MallocSize of string} {
assert_equal [r mallocsize.setstr key abcdefg] {OK}
assert_morethan [r memory usage key] 7 ;# Length of "abcdefg"
}
test {MallocSize of dict} {
assert_equal [r mallocsize.setdict key f1 v1 f2 v2] {OK}
assert_morethan [r memory usage key] 8 ;# Length of "f1v1f2v2"
}
}
......@@ -11,6 +11,7 @@ start_server {tags {"modules"}} {
assert_equal [r config get moduleconfigs.memory_numeric] "moduleconfigs.memory_numeric 1024"
assert_equal [r config get moduleconfigs.string] "moduleconfigs.string {secret password}"
assert_equal [r config get moduleconfigs.enum] "moduleconfigs.enum one"
assert_equal [r config get moduleconfigs.flags] "moduleconfigs.flags {one two}"
assert_equal [r config get moduleconfigs.numeric] "moduleconfigs.numeric -1"
}
......@@ -29,6 +30,10 @@ start_server {tags {"modules"}} {
assert_equal [r config get moduleconfigs.string] "moduleconfigs.string {super \0secret password}"
r config set moduleconfigs.enum two
assert_equal [r config get moduleconfigs.enum] "moduleconfigs.enum two"
r config set moduleconfigs.flags two
assert_equal [r config get moduleconfigs.flags] "moduleconfigs.flags two"
r config set moduleconfigs.flags "two three"
assert_equal [r config get moduleconfigs.flags] "moduleconfigs.flags {two three}"
r config set moduleconfigs.numeric -2
assert_equal [r config get moduleconfigs.numeric] "moduleconfigs.numeric -2"
}
......@@ -54,7 +59,7 @@ start_server {tags {"modules"}} {
test {Enums only able to be set to passed in values} {
# Module authors specify what values are valid for enums, check that only those values are ok on a set
catch {[r config set moduleconfigs.enum four]} e
assert_match {*argument must be one of the following*} $e
assert_match {*must be one of the following*} $e
}
test {Unload removes module configs} {
......@@ -67,6 +72,7 @@ start_server {tags {"modules"}} {
assert_equal [r config get moduleconfigs.memory_numeric] "moduleconfigs.memory_numeric 1024"
assert_equal [r config get moduleconfigs.string] "moduleconfigs.string {secret password}"
assert_equal [r config get moduleconfigs.enum] "moduleconfigs.enum one"
assert_equal [r config get moduleconfigs.flags] "moduleconfigs.flags {one two}"
assert_equal [r config get moduleconfigs.numeric] "moduleconfigs.numeric -1"
r module unload moduleconfigs
}
......@@ -80,6 +86,7 @@ start_server {tags {"modules"}} {
assert_equal [r config get moduleconfigs.string] "moduleconfigs.string tclortickle"
# Configs that were not changed should still be their module specified value
assert_equal [r config get moduleconfigs.enum] "moduleconfigs.enum one"
assert_equal [r config get moduleconfigs.flags] "moduleconfigs.flags {one two}"
assert_equal [r config get moduleconfigs.numeric] "moduleconfigs.numeric -1"
}
......@@ -140,6 +147,7 @@ start_server {tags {"modules"}} {
r config set moduleconfigs.mutable_bool yes
r config set moduleconfigs.memory_numeric 750
r config set moduleconfigs.enum two
r config set moduleconfigs.flags "two three"
r config rewrite
restart_server 0 true false
# Ensure configs we rewrote are present and that the conf file is readable
......@@ -147,6 +155,7 @@ start_server {tags {"modules"}} {
assert_equal [r config get moduleconfigs.memory_numeric] "moduleconfigs.memory_numeric 750"
assert_equal [r config get moduleconfigs.string] "moduleconfigs.string {super \0secret password}"
assert_equal [r config get moduleconfigs.enum] "moduleconfigs.enum two"
assert_equal [r config get moduleconfigs.flags] "moduleconfigs.flags {two three}"
assert_equal [r config get moduleconfigs.numeric] "moduleconfigs.numeric -1"
r module unload moduleconfigs
}
......@@ -221,11 +230,12 @@ start_server {tags {"modules"}} {
set stdout [dict get $noload stdout]
assert_equal [count_message_lines $stdout "Module Configurations were not set, likely a missing LoadConfigs call. Unloading the module."] 1
start_server [list overrides [list loadmodule "$testmodule" moduleconfigs.string "bootedup" moduleconfigs.enum two]] {
start_server [list overrides [list loadmodule "$testmodule" moduleconfigs.string "bootedup" moduleconfigs.enum two moduleconfigs.flags "two three"]] {
assert_equal [r config get moduleconfigs.string] "moduleconfigs.string bootedup"
assert_equal [r config get moduleconfigs.mutable_bool] "moduleconfigs.mutable_bool yes"
assert_equal [r config get moduleconfigs.immutable_bool] "moduleconfigs.immutable_bool no"
assert_equal [r config get moduleconfigs.enum] "moduleconfigs.enum two"
assert_equal [r config get moduleconfigs.flags] "moduleconfigs.flags {two three}"
assert_equal [r config get moduleconfigs.numeric] "moduleconfigs.numeric -1"
assert_equal [r config get moduleconfigs.memory_numeric] "moduleconfigs.memory_numeric 1024"
}
......
......@@ -108,10 +108,16 @@ tags "modules" {
{set asdf3 3 PXAT *}
{exec}
{incr notifications}
{incr notifications}
{incr testkeyspace:expired}
{del asdf*}
{incr notifications}
{incr notifications}
{incr testkeyspace:expired}
{del asdf*}
{incr notifications}
{incr notifications}
{incr testkeyspace:expired}
{del asdf*}
}
close_replication_stream $repl
......
set testmodule [file normalize tests/modules/publish.so]
start_server {tags {"modules"}} {
r module load $testmodule
test {PUBLISH and SPUBLISH via a module} {
set rd1 [redis_deferring_client]
set rd2 [redis_deferring_client]
assert_equal {1} [ssubscribe $rd1 {chan1}]
assert_equal {1} [subscribe $rd2 {chan1}]
assert_equal 1 [r publish.shard chan1 hello]
assert_equal 1 [r publish.classic chan1 world]
assert_equal {message chan1 hello} [$rd1 read]
assert_equal {message chan1 world} [$rd2 read]
}
}
......@@ -15,8 +15,8 @@ start_server {tags {"modules"}} {
set docs_reply [r command docs subcommands.bitarray]
set docs [dict create {*}[lindex $docs_reply 1]]
set subcmds_in_cmd_docs [dict create {*}[dict get $docs subcommands]]
assert_equal [dict get $subcmds_in_cmd_docs "subcommands.bitarray|get"] {group module}
assert_equal [dict get $subcmds_in_cmd_docs "subcommands.bitarray|set"] {group module}
assert_equal [dict get $subcmds_in_cmd_docs "subcommands.bitarray|get"] {group module module subcommands}
assert_equal [dict get $subcmds_in_cmd_docs "subcommands.bitarray|set"] {group module module subcommands}
}
test "Module pure-container command fails on arity error" {
......@@ -25,6 +25,10 @@ start_server {tags {"modules"}} {
# Subcommands can be called
assert_equal [r subcommands.bitarray get k1] {OK}
# Subcommand arity error
catch {r subcommands.bitarray get k1 8 90} e
assert_match {*wrong number of arguments for 'subcommands.bitarray|get' command} $e
}
test "Module get current command fullname" {
......
......@@ -122,5 +122,10 @@ if {$system_name eq {linux}} {
r config set oom-score-adj absolute
assert_equal [get_oom_score_adj] $custom_oom
}
test {CONFIG SET out-of-range oom score} {
assert_error {ERR *must be between -2000 and 2000*} {r config set oom-score-adj-values "-2001 -2001 -2001"}
assert_error {ERR *must be between -2000 and 2000*} {r config set oom-score-adj-values "2001 2001 2001"}
}
}
}
......@@ -311,7 +311,7 @@ start_server {tags {"other"}} {
assert_error {*unknown command*} {r GET|SET}
assert_error {*unknown command*} {r GET|SET|OTHER}
assert_error {*unknown command*} {r CONFIG|GET GET_XX}
assert_error {*Unknown subcommand*} {r CONFIG GET_XX}
assert_error {*unknown subcommand*} {r CONFIG GET_XX}
}
}
......
......@@ -390,4 +390,17 @@ start_server {tags {"pubsub network"}} {
r config set notify-keyspace-events EA
assert_equal {AE} [lindex [r config get notify-keyspace-events] 1]
}
test "Keyspace notifications: new key test" {
r config set notify-keyspace-events En
set rd1 [redis_deferring_client]
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 bar bar
assert_equal "pmessage * __keyevent@${db}__:new foo" [$rd1 read]
assert_equal "pmessage * __keyevent@${db}__:new bar" [$rd1 read]
$rd1 close
}
}
start_server {tags {"pubsubshard external:skip"}} {
proc __consume_ssubscribe_messages {client type channels} {
set numsub -1
set counts {}
for {set i [llength $channels]} {$i > 0} {incr i -1} {
set msg [$client read]
assert_equal $type [lindex $msg 0]
# when receiving subscribe messages the channels names
# are ordered. when receiving unsubscribe messages
# they are unordered
set idx [lsearch -exact $channels [lindex $msg 1]]
if {[string match "sunsubscribe" $type]} {
assert {$idx >= 0}
} else {
assert {$idx == 0}
}
set channels [lreplace $channels $idx $idx]
# aggregate the subscription count to return to the caller
lappend counts [lindex $msg 2]
}
# we should have received messages for channels
assert {[llength $channels] == 0}
return $counts
}
proc __consume_subscribe_messages {client type channels} {
set numsub -1
set counts {}
for {set i [llength $channels]} {$i > 0} {incr i -1} {
set msg [$client read]
assert_equal $type [lindex $msg 0]
# when receiving subscribe messages the channels names
# are ordered. when receiving unsubscribe messages
# they are unordered
set idx [lsearch -exact $channels [lindex $msg 1]]
if {[string match "unsubscribe" $type]} {
assert {$idx >= 0}
} else {
assert {$idx == 0}
}
set channels [lreplace $channels $idx $idx]
# aggregate the subscription count to return to the caller
lappend counts [lindex $msg 2]
}
# we should have received messages for channels
assert {[llength $channels] == 0}
return $counts
}
proc ssubscribe {client channels} {
$client ssubscribe {*}$channels
__consume_ssubscribe_messages $client ssubscribe $channels
}
proc subscribe {client channels} {
$client subscribe {*}$channels
__consume_subscribe_messages $client subscribe $channels
}
proc sunsubscribe {client {channels {}}} {
$client sunsubscribe {*}$channels
__consume_subscribe_messages $client sunsubscribe $channels
}
proc unsubscribe {client {channels {}}} {
$client unsubscribe {*}$channels
__consume_subscribe_messages $client unsubscribe $channels
}
test "SPUBLISH/SSUBSCRIBE basics" {
set rd1 [redis_deferring_client]
......
......@@ -52,7 +52,7 @@ start_server {tags {"scripting"}} {
assert_match {*command not allowed when used memory*} $e
r config set maxmemory 0
}
} {OK} {needs:config-maxmemory}
} ;# is_eval
test {EVAL - Does Lua interpreter replies to our requests?} {
......@@ -447,12 +447,12 @@ start_server {tags {"scripting"}} {
test {Globals protection reading an undeclared global variable} {
catch {run_script {return a} 0} e
set e
} {ERR*attempted to access * global*}
} {ERR *attempted to access * global*}
test {Globals protection setting an undeclared global*} {
catch {run_script {a=10} 0} e
set e
} {ERR*attempted to create global*}
} {ERR *Attempt to modify a readonly table*}
test {Test an example script DECR_IF_GT} {
set decr_if_gt {
......@@ -735,6 +735,112 @@ start_server {tags {"scripting"}} {
return redis.acl_check_cmd('invalid-cmd','arg')
} 0}
}
test "Binary code loading failed" {
assert_error {ERR *attempt to call a nil value*} {run_script {
return loadstring(string.dump(function() return 1 end))()
} 0}
}
test "Try trick global protection 1" {
catch {
run_script {
setmetatable(_G, {})
} 0
} e
set _ $e
} {*Attempt to modify a readonly table*}
test "Try trick global protection 2" {
catch {
run_script {
local g = getmetatable(_G)
g.__index = {}
} 0
} e
set _ $e
} {*Attempt to modify a readonly table*}
test "Try trick global protection 3" {
catch {
run_script {
redis = function() return 1 end
} 0
} e
set _ $e
} {*Attempt to modify a readonly table*}
test "Try trick global protection 4" {
catch {
run_script {
_G = {}
} 0
} e
set _ $e
} {*Attempt to modify a readonly table*}
test "Try trick readonly table on redis table" {
catch {
run_script {
redis.call = function() return 1 end
} 0
} e
set _ $e
} {*Attempt to modify a readonly table*}
test "Try trick readonly table on json table" {
catch {
run_script {
cjson.encode = function() return 1 end
} 0
} e
set _ $e
} {*Attempt to modify a readonly table*}
test "Try trick readonly table on cmsgpack table" {
catch {
run_script {
cmsgpack.pack = function() return 1 end
} 0
} e
set _ $e
} {*Attempt to modify a readonly table*}
test "Try trick readonly table on bit table" {
catch {
run_script {
bit.lshift = function() return 1 end
} 0
} e
set _ $e
} {*Attempt to modify a readonly table*}
test "Test loadfile are not available" {
catch {
run_script {
loadfile('some file')
} 0
} e
set _ $e
} {*Script attempted to access nonexistent global variable 'loadfile'*}
test "Test dofile are not available" {
catch {
run_script {
dofile('some file')
} 0
} e
set _ $e
} {*Script attempted to access nonexistent global variable 'dofile'*}
test "Test print are not available" {
catch {
run_script {
print('some data')
} 0
} e
set _ $e
} {*Script attempted to access nonexistent global variable 'print'*}
}
# Start a new server since the last test in this stanza will kill the
......@@ -1324,7 +1430,7 @@ start_server {tags {"scripting"}} {
] 1
r config set maxmemory 0
}
} {OK} {needs:config-maxmemory}
test "no-writes shebang flag" {
assert_error {ERR Write commands are not allowed from read-only scripts*} {
......
......@@ -53,17 +53,17 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
r config set masterauth ""
r acl setuser slowlog-test-user +get +set
r config set slowlog-log-slower-than 0
r config set slowlog-log-slower-than 10000
r config set slowlog-log-slower-than -1
set slowlog_resp [r slowlog get]
# Make sure normal configs work, but the two sensitive
# commands are omitted or redacted
assert_equal 5 [llength $slowlog_resp]
assert_equal {slowlog reset} [lindex [lindex [r slowlog get] 4] 3]
assert_equal {acl setuser (redacted) (redacted) (redacted)} [lindex [lindex [r slowlog get] 3] 3]
assert_equal {config set masterauth (redacted)} [lindex [lindex [r slowlog get] 2] 3]
assert_equal {acl setuser (redacted) (redacted) (redacted)} [lindex [lindex [r slowlog get] 1] 3]
assert_equal {config set slowlog-log-slower-than 0} [lindex [lindex [r slowlog get] 0] 3]
assert_equal {slowlog reset} [lindex [lindex $slowlog_resp 4] 3]
assert_equal {acl setuser (redacted) (redacted) (redacted)} [lindex [lindex $slowlog_resp 3] 3]
assert_equal {config set masterauth (redacted)} [lindex [lindex $slowlog_resp 2] 3]
assert_equal {acl setuser (redacted) (redacted) (redacted)} [lindex [lindex $slowlog_resp 1] 3]
assert_equal {config set slowlog-log-slower-than 0} [lindex [lindex $slowlog_resp 0] 3]
} {} {needs:repl}
test {SLOWLOG - Some commands can redact sensitive fields} {
......@@ -72,13 +72,14 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
r migrate [srv 0 host] [srv 0 port] key 9 5000
r migrate [srv 0 host] [srv 0 port] key 9 5000 AUTH user
r migrate [srv 0 host] [srv 0 port] key 9 5000 AUTH2 user password
r config set slowlog-log-slower-than -1
set slowlog_resp [r slowlog get]
r config set slowlog-log-slower-than 10000
# Make sure all 3 commands were logged, but the sensitive fields are omitted
assert_equal 4 [llength [r slowlog get]]
assert_match {* key 9 5000} [lindex [lindex [r slowlog get] 2] 3]
assert_match {* key 9 5000 AUTH (redacted)} [lindex [lindex [r slowlog get] 1] 3]
assert_match {* key 9 5000 AUTH2 (redacted) (redacted)} [lindex [lindex [r slowlog get] 0] 3]
assert_equal 4 [llength $slowlog_resp]
assert_match {* key 9 5000} [lindex [lindex $slowlog_resp 2] 3]
assert_match {* key 9 5000 AUTH (redacted)} [lindex [lindex $slowlog_resp 1] 3]
assert_match {* key 9 5000 AUTH2 (redacted) (redacted)} [lindex [lindex $slowlog_resp 0] 3]
} {} {needs:repl}
test {SLOWLOG - Rewritten commands are logged as their original command} {
......
......@@ -507,8 +507,8 @@ start_server {tags {"hash"}} {
catch {r hincrby smallhash str 1} smallerr
catch {r hincrby bighash str 1} bigerr
set rv {}
lappend rv [string match "ERR*not an integer*" $smallerr]
lappend rv [string match "ERR*not an integer*" $bigerr]
lappend rv [string match "ERR *not an integer*" $smallerr]
lappend rv [string match "ERR *not an integer*" $bigerr]
} {1 1}
test {HINCRBY fails against hash value with spaces (right)} {
......@@ -517,8 +517,8 @@ start_server {tags {"hash"}} {
catch {r hincrby smallhash str 1} smallerr
catch {r hincrby bighash str 1} bigerr
set rv {}
lappend rv [string match "ERR*not an integer*" $smallerr]
lappend rv [string match "ERR*not an integer*" $bigerr]
lappend rv [string match "ERR *not an integer*" $smallerr]
lappend rv [string match "ERR *not an integer*" $bigerr]
} {1 1}
test {HINCRBY can detect overflows} {
......@@ -579,8 +579,8 @@ start_server {tags {"hash"}} {
catch {r hincrbyfloat smallhash str 1} smallerr
catch {r hincrbyfloat bighash str 1} bigerr
set rv {}
lappend rv [string match "ERR*not*float*" $smallerr]
lappend rv [string match "ERR*not*float*" $bigerr]
lappend rv [string match "ERR *not*float*" $smallerr]
lappend rv [string match "ERR *not*float*" $bigerr]
} {1 1}
test {HINCRBYFLOAT fails against hash value with spaces (right)} {
......@@ -589,15 +589,15 @@ start_server {tags {"hash"}} {
catch {r hincrbyfloat smallhash str 1} smallerr
catch {r hincrbyfloat bighash str 1} bigerr
set rv {}
lappend rv [string match "ERR*not*float*" $smallerr]
lappend rv [string match "ERR*not*float*" $bigerr]
lappend rv [string match "ERR *not*float*" $smallerr]
lappend rv [string match "ERR *not*float*" $bigerr]
} {1 1}
test {HINCRBYFLOAT fails against hash value that contains a null-terminator in the middle} {
r hset h f "1\x002"
catch {r hincrbyfloat h f 1} err
set rv {}
lappend rv [string match "ERR*not*float*" $err]
lappend rv [string match "ERR *not*float*" $err]
} {1}
test {HSTRLEN against the small hash} {
......@@ -648,6 +648,31 @@ start_server {tags {"hash"}} {
}
}
test {HINCRBYFLOAT over hash-max-listpack-value encoded with a listpack} {
set original_max_value [lindex [r config get hash-max-ziplist-value] 1]
r config set hash-max-listpack-value 8
# hash's value exceeds hash-max-listpack-value
r del smallhash
r del bighash
r hset smallhash tmp 0
r hset bighash tmp 0
r hincrbyfloat smallhash tmp 0.000005
r hincrbyfloat bighash tmp 0.0000005
assert_encoding listpack smallhash
assert_encoding hashtable bighash
# hash's field exceeds hash-max-listpack-value
r del smallhash
r del bighash
r hincrbyfloat smallhash abcdefgh 1
r hincrbyfloat bighash abcdefghi 1
assert_encoding listpack smallhash
assert_encoding hashtable bighash
r config set hash-max-listpack-value $original_max_value
}
test {Hash ziplist regression test for large keys} {
r hset hash kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk a
r hset hash kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk b
......
......@@ -111,21 +111,21 @@ start_server {tags {"incr"}} {
r set novar " 11"
catch {r incrbyfloat novar 1.0} err
format $err
} {ERR*valid*}
} {ERR *valid*}
test {INCRBYFLOAT fails against key with spaces (right)} {
set err {}
r set novar "11 "
catch {r incrbyfloat novar 1.0} err
format $err
} {ERR*valid*}
} {ERR *valid*}
test {INCRBYFLOAT fails against key with spaces (both)} {
set err {}
r set novar " 11 "
catch {r incrbyfloat novar 1.0} err
format $err
} {ERR*valid*}
} {ERR *valid*}
test {INCRBYFLOAT fails against a key holding a list} {
r del mylist
......@@ -146,7 +146,7 @@ start_server {tags {"incr"}} {
# p.s. no way I can force NaN to test it from the API because
# there is no way to increment / decrement by infinity nor to
# perform divisions.
} {ERR*would produce*}
} {ERR *would produce*}
}
test {INCRBYFLOAT decrement} {
......@@ -159,7 +159,7 @@ start_server {tags {"incr"}} {
r setrange foo 2 2
catch {r incrbyfloat foo 1} err
format $err
} {ERR*valid*}
} {ERR *valid*}
test {No negative zero} {
r del foo
......
......@@ -252,6 +252,7 @@ start_server [list overrides [list save ""] ] {
} {} {needs:debug}
}
run_solo {list-large-memory} {
start_server [list overrides [list save ""] ] {
# test if the server supports such large configs (avoid 32 bit builds)
......@@ -349,6 +350,7 @@ if {[lindex [r config get proto-max-bulk-len] 1] == 10000000000} {
} {} {large-memory}
} ;# skip 32bit builds
}
} ;# run_solo
start_server {
tags {"list"}
......@@ -510,7 +512,11 @@ start_server {
}
foreach resp {3 2} {
if {[lsearch $::denytags "resp3"] >= 0} {
if {$resp == 3} {continue}
} else {
r hello $resp
}
# Make sure we can distinguish between an empty array and a null response
r readraw 1
......@@ -1173,7 +1179,7 @@ foreach {pop} {BLPOP BLMPOP_LEFT} {
test "$pop: with negative timeout" {
set rd [redis_deferring_client]
bpop_command $rd $pop blist1 -1
assert_error "ERR*is negative*" {$rd read}
assert_error "ERR *is negative*" {$rd read}
$rd close
}
......
......@@ -935,6 +935,7 @@ start_server {
}
}
run_solo {set-large-memory} {
start_server [list overrides [list save ""] ] {
# test if the server supports such large configs (avoid 32 bit builds)
......@@ -969,3 +970,4 @@ if {[lindex [r config get proto-max-bulk-len] 1] == 10000000000} {
} {} {large-memory}
} ;# skip 32bit builds
}
} ;# run_solo
......@@ -770,7 +770,7 @@ start_server {tags {"stream xsetid"}} {
catch {r XSETID mystream "1-1"} err
r XADD mystream MAXLEN 0 * a b
set err
} {ERR*smaller*}
} {ERR *smaller*}
test {XSETID cannot SETID on non-existent key} {
catch {r XSETID stream 1-1} err
......@@ -790,7 +790,7 @@ start_server {tags {"stream xsetid"}} {
test {XSETID errors on negstive offset} {
catch {r XSETID stream 1-1 ENTRIESADDED -1 MAXDELETEDID 0-0} err
set _ $err
} {ERR*must be positive}
} {ERR *must be positive}
test {XSETID cannot set the maximal tombstone with larger ID} {
r DEL x
......@@ -799,7 +799,7 @@ start_server {tags {"stream xsetid"}} {
catch {r XSETID x "1-0" ENTRIESADDED 1 MAXDELETEDID "2-0" } err
r XADD mystream MAXLEN 0 * a b
set err
} {ERR*smaller*}
} {ERR *smaller*}
test {XSETID cannot set the offset to less than the length} {
r DEL x
......@@ -808,7 +808,7 @@ start_server {tags {"stream xsetid"}} {
catch {r XSETID x "1-0" ENTRIESADDED 0 MAXDELETEDID "0-0" } err
r XADD mystream MAXLEN 0 * a b
set err
} {ERR*smaller*}
} {ERR *smaller*}
}
start_server {tags {"stream offset"}} {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment