Add test coverage for CLIENT UNBLOCK (#7712)
plus minor other fixes to list.tcl
This commit is contained in:
parent
21784def70
commit
daef1f00c2
@ -1,3 +1,11 @@
|
|||||||
|
proc wait_for_blocked_client {} {
|
||||||
|
wait_for_condition 50 100 {
|
||||||
|
[s blocked_clients] ne 0
|
||||||
|
} else {
|
||||||
|
fail "no blocked clients"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
start_server {
|
start_server {
|
||||||
tags {"list"}
|
tags {"list"}
|
||||||
overrides {
|
overrides {
|
||||||
@ -52,7 +60,7 @@ start_server {
|
|||||||
|
|
||||||
test {LPOS when RANK is greater than matches} {
|
test {LPOS when RANK is greater than matches} {
|
||||||
r DEL mylist
|
r DEL mylist
|
||||||
r LPUSH l a
|
r LPUSH mylist a
|
||||||
assert {[r LPOS mylist b COUNT 10 RANK 5] eq {}}
|
assert {[r LPOS mylist b COUNT 10 RANK 5] eq {}}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,6 +225,8 @@ start_server {
|
|||||||
r del list
|
r del list
|
||||||
|
|
||||||
$rd blpop list 0
|
$rd blpop list 0
|
||||||
|
after 100 ;# Make sure rd is blocked before MULTI
|
||||||
|
|
||||||
r multi
|
r multi
|
||||||
r lpush list a
|
r lpush list a
|
||||||
r del list
|
r del list
|
||||||
@ -887,4 +897,45 @@ start_server {
|
|||||||
$rd2 close
|
$rd2 close
|
||||||
r ping
|
r ping
|
||||||
} {PONG}
|
} {PONG}
|
||||||
|
|
||||||
|
test "client unblock tests" {
|
||||||
|
r del l
|
||||||
|
set rd [redis_deferring_client]
|
||||||
|
$rd client id
|
||||||
|
set id [$rd read]
|
||||||
|
|
||||||
|
# test default args
|
||||||
|
$rd blpop l 0
|
||||||
|
wait_for_blocked_client
|
||||||
|
r client unblock $id
|
||||||
|
assert_equal {} [$rd read]
|
||||||
|
|
||||||
|
# test with timeout
|
||||||
|
$rd blpop l 0
|
||||||
|
wait_for_blocked_client
|
||||||
|
r client unblock $id TIMEOUT
|
||||||
|
assert_equal {} [$rd read]
|
||||||
|
|
||||||
|
# test with error
|
||||||
|
$rd blpop l 0
|
||||||
|
wait_for_blocked_client
|
||||||
|
r client unblock $id ERROR
|
||||||
|
catch {[$rd read]} e
|
||||||
|
assert_equal $e "UNBLOCKED client unblocked via CLIENT UNBLOCK"
|
||||||
|
|
||||||
|
# test with invalid client id
|
||||||
|
catch {[r client unblock asd]} e
|
||||||
|
assert_equal $e "ERR value is not an integer or out of range"
|
||||||
|
|
||||||
|
# test with non blocked client
|
||||||
|
set myid [r client id]
|
||||||
|
catch {[r client unblock $myid]} e
|
||||||
|
assert_equal $e {invalid command name "0"}
|
||||||
|
|
||||||
|
# finally, see the this client and list are still functional
|
||||||
|
$rd blpop l 0
|
||||||
|
wait_for_blocked_client
|
||||||
|
r lpush l foo
|
||||||
|
assert_equal {l foo} [$rd read]
|
||||||
|
} {}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user