Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
1a589818
Unverified
Commit
1a589818
authored
Jul 10, 2023
by
Oran Agra
Committed by
GitHub
Jul 10, 2023
Browse files
Release Redis 7.2 RC3
parents
a51eb05b
c7b3ce90
Changes
153
Hide whitespace changes
Inline
Side-by-side
tests/unit/acl.tcl
View file @
1a589818
...
@@ -323,6 +323,23 @@ start_server {tags {"acl external:skip"}} {
...
@@ -323,6 +323,23 @@ start_server {tags {"acl external:skip"}} {
$rd close
$rd close
}
{
0
}
}
{
0
}
test
{
blocked command gets rejected when reprocessed after permission change
}
{
r auth default
""
r config resetstat
set rd
[
redis_deferring_client
]
r ACL setuser psuser reset on nopass +@all allkeys
$rd AUTH psuser pspass
$rd read
$rd BLPOP list1 0
wait_for_blocked_client
r ACL setuser psuser resetkeys
r LPUSH list1 foo
assert_error
{
*NOPERM No permissions to access a key*
}
{
$rd
read
}
$rd ping
$rd close
assert_match
{
*calls=0,usec=0,*,rejected_calls=1,failed_calls=0
}
[
cmdrstat blpop r
]
}
test
{
Users can be configured to authenticate with any password
}
{
test
{
Users can be configured to authenticate with any password
}
{
r ACL setuser newuser nopass
r ACL setuser newuser nopass
r AUTH newuser zipzapblabla
r AUTH newuser zipzapblabla
...
...
tests/unit/bitfield.tcl
View file @
1a589818
...
@@ -214,6 +214,16 @@ start_server {tags {"bitops"}} {
...
@@ -214,6 +214,16 @@ start_server {tags {"bitops"}} {
}
}
r del mystring
r del mystring
}
}
test
{
BITFIELD_RO with only key as argument
}
{
set res
[
r bitfield_ro bits
]
assert
{
$res
eq
{}}
}
test
{
BITFIELD_RO fails when write option is used
}
{
catch
{
r bitfield_ro bits set u8 0 100 get u8 0
}
err
assert_match
{
*ERR BITFIELD_RO only supports the GET subcommand*
}
$err
}
}
}
start_server
{
tags
{
"repl external:skip"
}}
{
start_server
{
tags
{
"repl external:skip"
}}
{
...
@@ -240,12 +250,12 @@ start_server {tags {"repl external:skip"}} {
...
@@ -240,12 +250,12 @@ start_server {tags {"repl external:skip"}} {
assert_equal 100
[
$slave
bitfield_ro bits get u8 0
]
assert_equal 100
[
$slave
bitfield_ro bits get u8 0
]
}
}
test
{
BITFIELD_RO with only key as argument
}
{
test
{
BITFIELD_RO with only key as argument
on read-only replica
}
{
set res
[
$slave
bitfield_ro bits
]
set res
[
$slave
bitfield_ro bits
]
assert
{
$res
eq
{}}
assert
{
$res
eq
{}}
}
}
test
{
BITFIELD_RO fails when write option is used
}
{
test
{
BITFIELD_RO fails when write option is used
on read-only replica
}
{
catch
{
$slave
bitfield_ro bits set u8 0 100 get u8 0
}
err
catch
{
$slave
bitfield_ro bits set u8 0 100 get u8 0
}
err
assert_match
{
*ERR BITFIELD_RO only supports the GET subcommand*
}
$err
assert_match
{
*ERR BITFIELD_RO only supports the GET subcommand*
}
$err
}
}
...
...
tests/unit/cluster/cluster-response-tls.tcl
0 → 100644
View file @
1a589818
source tests/support/cluster.tcl
proc get_port_from_moved_error
{
e
}
{
set ip_port
[
lindex
[
split $e
" "
]
2
]
return
[
lindex
[
split $ip_port
":"
]
1
]
}
proc get_pport_by_port
{
port
}
{
foreach srv $::servers
{
set srv_port
[
dict get $srv port
]
if
{
$port
== $srv_port
}
{
return
[
dict get $srv pport
]
}
}
return 0
}
proc get_port_from_node_info
{
line
}
{
set fields
[
split $line
" "
]
set addr
[
lindex $fields 1
]
set ip_port
[
lindex
[
split $addr
"@"
]
0
]
return
[
lindex
[
split $ip_port
":"
]
1
]
}
proc cluster_response_tls
{
tls_cluster
}
{
test
"CLUSTER SLOTS with different connection type -- tls-cluster
$tls
_cluster"
{
set slots1
[
R 0 cluster slots
]
set pport
[
srv 0 pport
]
set cluster_client
[
redis_cluster 127.0.0.1:$pport 0
]
set slots2
[
$cluster
_client cluster slots
]
$cluster_client close
# Compare the ports in the first row
assert_no_match
[
lindex $slots1 0 2 1
]
[
lindex $slots2 0 2 1
]
}
test
"CLUSTER NODES return port according to connection type -- tls-cluster
$tls
_cluster"
{
set nodes
[
R 0 cluster nodes
]
set port1
[
get_port_from_node_info
[
lindex
[
split $nodes
"
\r\n
"
]
0
]]
set pport
[
srv 0 pport
]
set cluster_client
[
redis_cluster 127.0.0.1:$pport 0
]
set nodes
[
$cluster
_client cluster nodes
]
set port2
[
get_port_from_node_info
[
lindex
[
split $nodes
"
\r\n
"
]
0
]]
$cluster_client close
assert_not_equal $port1 $port2
}
set cluster
[
redis_cluster 127.0.0.1:
[
srv 0 port
]]
set cluster_pport
[
redis_cluster 127.0.0.1:
[
srv 0 pport
]
0
]
$cluster refresh_nodes_map
test
"Set many keys in the cluster -- tls-cluster
$tls
_cluster"
{
for
{
set i 0
}
{
$i
< 5000
}
{
incr i
}
{
$cluster set $i $i
assert
{
[
$cluster
get $i
]
eq $i
}
}
}
test
"Test cluster responses during migration of slot x -- tls-cluster
$tls
_cluster"
{
set slot 10
array set nodefrom
[
$cluster
masternode_for_slot $slot
]
array set nodeto
[
$cluster
masternode_notfor_slot $slot
]
$nodeto
(
link
)
cluster setslot $slot importing $nodefrom
(
id
)
$nodefrom
(
link
)
cluster setslot $slot migrating $nodeto
(
id
)
# Get a key from that slot
set key
[
$nodefrom
(
link
)
cluster GETKEYSINSLOT $slot
"1"
]
# MOVED REPLY
catch
{
$nodeto
(
link
)
set $key
"newVal"
}
e_moved1
assert_match
"*MOVED*"
$e_moved1
# ASK REPLY
catch
{
$nodefrom
(
link
)
set
"abc{
$key
}"
"newVal"
}
e_ask1
assert_match
"*ASK*"
$e_ask1
# UNSTABLE REPLY
assert_error
"*TRYAGAIN*"
{
$nodefrom
(
link
)
mset
"a{
$key
}"
"newVal"
$key
"newVal2"
}
# Connecting using another protocol
array set nodefrom_pport
[
$cluster
_pport masternode_for_slot $slot
]
array set nodeto_pport
[
$cluster
_pport masternode_notfor_slot $slot
]
# MOVED REPLY
catch
{
$nodeto
_pport
(
link
)
set $key
"newVal"
}
e_moved2
assert_match
"*MOVED*"
$e_moved2
# ASK REPLY
catch
{
$nodefrom
_pport
(
link
)
set
"abc{
$key
}"
"newVal"
}
e_ask2
assert_match
"*ASK*"
$e_ask2
# Compare MOVED error's port
set port1
[
get_port_from_moved_error $e_moved1
]
set port2
[
get_port_from_moved_error $e_moved2
]
assert_not_equal $port1 $port2
assert_equal $port1 $nodefrom
(
port
)
assert_equal $port2
[
get_pport_by_port $nodefrom
(
port
)]
# Compare ASK error's port
set port1
[
get_port_from_moved_error $e_ask1
]
set port2
[
get_port_from_moved_error $e_ask2
]
assert_not_equal $port1 $port2
assert_equal $port1 $nodeto
(
port
)
assert_equal $port2
[
get_pport_by_port $nodeto
(
port
)]
}
}
if
{
$::tls
}
{
start_cluster 3 3
{
tags
{
external:skip cluster tls
}
overrides
{
tls-cluster yes tls-replication yes
}}
{
cluster_response_tls yes
}
start_cluster 3 3
{
tags
{
external:skip cluster tls
}
overrides
{
tls-cluster no tls-replication no
}}
{
cluster_response_tls no
}
}
tests/unit/cluster/hostnames.tcl
View file @
1a589818
# Returns 1 if no node knows node_id, 0 if any node knows it.
proc node_is_forgotten
{
node_id
}
{
for
{
set j 0
}
{
$j
<
[
llength $::servers
]}
{
incr j
}
{
set cluster_nodes
[
R $j CLUSTER NODES
]
if
{
[
string match
"*
$node
_id*"
$cluster_nodes
]
}
{
return 0
}
}
return 1
}
# Isolate a node from the cluster and give it a new nodeid
proc isolate_node
{
id
}
{
set node_id
[
R $id CLUSTER MYID
]
R $id CLUSTER RESET HARD
# Here we additionally test that CLUSTER FORGET propagates to all nodes.
set other_id
[
expr $id == 0 ? 1 : 0
]
R $other_id CLUSTER FORGET $node_id
wait_for_condition 50 100
{
[
node_is_forgotten $node_id
]
}
else
{
fail
"CLUSTER FORGET was not propagated to all nodes"
}
}
# Check if cluster's view of hostnames is consistent
proc are_hostnames_propagated
{
match_string
}
{
for
{
set j 0
}
{
$j
<
[
llength $::servers
]}
{
incr j
}
{
set cfg
[
R $j cluster slots
]
foreach node $cfg
{
for
{
set i 2
}
{
$i
<
[
llength $node
]}
{
incr i
}
{
if
{
!
[
string match $match_string
[
lindex
[
lindex
[
lindex $node $i
]
3
]
1
]]
}
{
return 0
}
}
}
}
return 1
}
proc get_slot_field
{
slot_output shard_id node_id attrib_id
}
{
proc get_slot_field
{
slot_output shard_id node_id attrib_id
}
{
return
[
lindex
[
lindex
[
lindex $slot_output $shard_id
]
$node_id
]
$attrib_id
]
return
[
lindex
[
lindex
[
lindex $slot_output $shard_id
]
$node_id
]
$attrib_id
]
}
}
...
...
tests/unit/cluster/human-announced-nodename.tcl
0 → 100644
View file @
1a589818
# Check if cluster's view of human announced nodename is reported in logs
start_cluster 3 0
{
tags
{
external:skip cluster
}}
{
test
"Set cluster human announced nodename and let it propagate"
{
for
{
set j 0
}
{
$j
<
[
llength $::servers
]}
{
incr j
}
{
R $j config set cluster-announce-hostname
"host-
$j.com
"
R $j config set cluster-announce-human-nodename
"nodename-
$j
"
}
# We wait for everyone to agree on the hostnames. Since they are gossiped
# the same way as nodenames, it implies everyone knows the nodenames too.
wait_for_condition 50 100
{
[
are_hostnames_propagated
"host-*.com"
]
eq 1
}
else
{
fail
"cluster hostnames were not propagated"
}
}
test
"Human nodenames are visible in log messages"
{
# Pause instance 0, so everyone thinks it is dead
pause_process
[
srv 0 pid
]
# We're going to use a message we will know will be sent, node unreachable,
# since it includes the other node gossiping.
wait_for_log_messages -1
{
"*Node * (nodename-2) reported node * (nodename-0) as not reachable*"
}
0 20 500
wait_for_log_messages -2
{
"*Node * (nodename-1) reported node * (nodename-0) as not reachable*"
}
0 20 500
resume_process
[
srv 0 pid
]
}
}
tests/unit/cluster/misc.tcl
View file @
1a589818
...
@@ -18,7 +18,6 @@ start_cluster 2 2 {tags {external:skip cluster}} {
...
@@ -18,7 +18,6 @@ start_cluster 2 2 {tags {external:skip cluster}} {
set id
[
R 0 CLUSTER MYID
]
set id
[
R 0 CLUSTER MYID
]
assert_equal
{
0
}
[
R 0 CLUSTER count-failure-reports $id
]
assert_equal
{
0
}
[
R 0 CLUSTER count-failure-reports $id
]
assert_match
"*shard-id*"
[
R 0 CLUSTER slaves $id
]
R 0 flushall
R 0 flushall
assert_equal
{
OK
}
[
R 0 CLUSTER flushslots
]
assert_equal
{
OK
}
[
R 0 CLUSTER flushslots
]
...
...
tests/unit/cluster/multi-slot-operations.tcl
View file @
1a589818
...
@@ -48,6 +48,17 @@ test "Continuous slots distribution" {
...
@@ -48,6 +48,17 @@ test "Continuous slots distribution" {
assert_match
"*13105 13500*14001 15000*16001 16383*"
[
$master5
CLUSTER SLOTS
]
assert_match
"*13105 13500*14001 15000*16001 16383*"
[
$master5
CLUSTER SLOTS
]
}
}
test
"ADDSLOTS command with several boundary conditions test suite"
{
assert_error
"ERR Invalid or out of range slot"
{
R 0 cluster ADDSLOTS 3001 aaa
}
assert_error
"ERR Invalid or out of range slot"
{
R 0 cluster ADDSLOTS 3001 -1000
}
assert_error
"ERR Invalid or out of range slot"
{
R 0 cluster ADDSLOTS 3001 30003
}
assert_error
"ERR Slot 3200 is already busy"
{
R 0 cluster ADDSLOTS 3200
}
assert_error
"ERR Slot 8501 is already busy"
{
R 0 cluster ADDSLOTS 8501
}
assert_error
"ERR Slot 3001 specified multiple times"
{
R 0 cluster ADDSLOTS 3001 3002 3001
}
}
test
"ADDSLOTSRANGE command with several boundary conditions test suite"
{
test
"ADDSLOTSRANGE command with several boundary conditions test suite"
{
# Add multiple slots with incorrect argument number
# Add multiple slots with incorrect argument number
assert_error
"ERR wrong number of arguments for 'cluster|addslotsrange' command"
{
R 0 cluster ADDSLOTSRANGE 3001 3020 3030
}
assert_error
"ERR wrong number of arguments for 'cluster|addslotsrange' command"
{
R 0 cluster ADDSLOTSRANGE 3001 3020 3030
}
...
...
tests/unit/dump.tcl
View file @
1a589818
...
@@ -96,6 +96,34 @@ start_server {tags {"dump"}} {
...
@@ -96,6 +96,34 @@ start_server {tags {"dump"}} {
set e
set e
}
{
*syntax*
}
}
{
*syntax*
}
test
{
RESTORE should not store key that are already expired, with REPLACE will propagate it as DEL or UNLINK
}
{
r del key1
{
t
}
key2
{
t
}
r set key1
{
t
}
value2
r lpush key2
{
t
}
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
r set key
{
t
}
value
set encoded
[
r dump key
{
t
}]
set now
[
clock milliseconds
]
set repl
[
attach_to_replication_stream
]
# Keys that have expired will not be stored.
r config set lazyfree-lazy-server-del no
assert_equal
{
OK
}
[
r restore key1
{
t
}
[
expr $now-5000
]
$encoded replace absttl
]
r config set lazyfree-lazy-server-del yes
assert_equal
{
OK
}
[
r restore key2
{
t
}
[
expr $now-5000
]
$encoded replace absttl
]
assert_equal
{
0
}
[
r exists key1
{
t
}
key2
{
t
}]
# Verify the propagate of DEL and UNLINK.
assert_replication_stream $repl
{
{
select *
}
{
del key1
{
t
}}
{
unlink key2
{
t
}}
}
close_replication_stream $repl
}
{}
{
needs:repl
}
test
{
DUMP of non existing key returns nil
}
{
test
{
DUMP of non existing key returns nil
}
{
r dump nonexisting_key
r dump nonexisting_key
}
{}
}
{}
...
...
tests/unit/expire.tcl
View file @
1a589818
...
@@ -321,7 +321,7 @@ start_server {tags {"expire"}} {
...
@@ -321,7 +321,7 @@ start_server {tags {"expire"}} {
r set foo1 bar ex 100
r set foo1 bar ex 100
r set foo2 bar px 100000
r set foo2 bar px 100000
r set foo3 bar exat
[
expr
[
clock seconds
]
+100
]
r set foo3 bar exat
[
expr
[
clock seconds
]
+100
]
r set foo4 bar
pxat
[
expr
[
clock milliseconds
]
+100000
]
r set foo4 bar
PXAT
[
expr
[
clock milliseconds
]
+100000
]
r setex foo5 100 bar
r setex foo5 100 bar
r psetex foo6 100000 bar
r psetex foo6 100000 bar
# EXPIRE-family commands
# EXPIRE-family commands
...
@@ -491,7 +491,7 @@ start_server {tags {"expire"}} {
...
@@ -491,7 +491,7 @@ start_server {tags {"expire"}} {
{
set foo1 bar PXAT *
}
{
set foo1 bar PXAT *
}
{
set foo1 bar PXAT *
}
{
set foo1 bar PXAT *
}
{
set foo1 bar PXAT *
}
{
set foo1 bar PXAT *
}
{
set foo1 bar
PXAT
*
}
{
set foo1 bar
pxat
*
}
{
set foo1 bar PXAT *
}
{
set foo1 bar PXAT *
}
{
set foo1 bar PXAT *
}
{
set foo1 bar PXAT *
}
{
set foo2 bar
}
{
set foo2 bar
}
...
...
tests/unit/geo.tcl
View file @
1a589818
...
@@ -99,6 +99,18 @@ proc verify_geo_edge_response_bymember {expected_response expected_store_respons
...
@@ -99,6 +99,18 @@ proc verify_geo_edge_response_bymember {expected_response expected_store_respons
assert_match $expected_store_response $response
assert_match $expected_store_response $response
}
}
proc verify_geo_edge_response_generic
{
expected_response
}
{
catch
{
r geodist src
{
t
}
member 1 km
}
response
assert_match $expected_response $response
catch
{
r geohash src
{
t
}
member
}
response
assert_match $expected_response $response
catch
{
r geopos src
{
t
}
member
}
response
assert_match $expected_response $response
}
# The following list represents sets of random seed, search position
# The following list represents sets of random seed, search position
# and radius that caused bugs in the past. It is used by the randomized
# and radius that caused bugs in the past. It is used by the randomized
# test later as a starting point. When the regression vectors are scanned
# test later as a starting point. When the regression vectors are scanned
...
@@ -128,6 +140,7 @@ start_server {tags {"geo"}} {
...
@@ -128,6 +140,7 @@ start_server {tags {"geo"}} {
verify_geo_edge_response_bylonlat
"WRONGTYPE*"
"WRONGTYPE*"
verify_geo_edge_response_bylonlat
"WRONGTYPE*"
"WRONGTYPE*"
verify_geo_edge_response_bymember
"WRONGTYPE*"
"WRONGTYPE*"
verify_geo_edge_response_bymember
"WRONGTYPE*"
"WRONGTYPE*"
verify_geo_edge_response_generic
"WRONGTYPE*"
}
}
test
{
GEO with non existing src key
}
{
test
{
GEO with non existing src key
}
{
...
...
tests/unit/info.tcl
View file @
1a589818
...
@@ -287,21 +287,26 @@ start_server {tags {"info" "external:skip"}} {
...
@@ -287,21 +287,26 @@ start_server {tags {"info" "external:skip"}} {
set cycle2
[
getInfoProperty $info2 eventloop_cycles
]
set cycle2
[
getInfoProperty $info2 eventloop_cycles
]
set el_sum2
[
getInfoProperty $info2 eventloop_duration_sum
]
set el_sum2
[
getInfoProperty $info2 eventloop_duration_sum
]
set cmd_sum2
[
getInfoProperty $info2 eventloop_duration_cmd_sum
]
set cmd_sum2
[
getInfoProperty $info2 eventloop_duration_cmd_sum
]
if
{
$::verbose
}
{
puts
"eventloop metrics cycle1:
$cycle1
, cycle2:
$cycle2
"
}
assert_morethan $cycle2 $cycle1
assert_morethan $cycle2 $cycle1
assert_lessthan $cycle2
[
expr $cycle1+10
]
;
# we expect 2 or 3 cycles here, but allow some tolerance
assert_lessthan $cycle2
[
expr $cycle1+10
]
;
# we expect 2 or 3 cycles here, but allow some tolerance
if
{
$::verbose
}
{
puts
"eventloop metrics el_sum1:
$el
_sum1, el_sum2:
$el
_sum2"
}
assert_morethan $el_sum2 $el_sum1
assert_morethan $el_sum2 $el_sum1
assert_lessthan $el_sum2
[
expr $el_sum1+5000
]
;
# we expect roughly 100ms here, but allow some tolerance
assert_lessthan $el_sum2
[
expr $el_sum1+30000
]
;
# we expect roughly 100ms here, but allow some tolerance
if
{
$::verbose
}
{
puts
"eventloop metrics cmd_sum1:
$cmd
_sum1, cmd_sum2:
$cmd
_sum2"
}
assert_morethan $cmd_sum2 $cmd_sum1
assert_morethan $cmd_sum2 $cmd_sum1
assert_lessthan $cmd_sum2
[
expr $cmd_sum1+
3
000
]
;
# we expect about tens of ms here, but allow some tolerance
assert_lessthan $cmd_sum2
[
expr $cmd_sum1+
15
000
]
;
# we expect about tens of ms here, but allow some tolerance
}
}
test
{
stats: instantaneous metrics
}
{
test
{
stats: instantaneous metrics
}
{
r config resetstat
r config resetstat
after 1600
;
# hz is 10, wait for 16 cron tick so that sample array is fulfilled
after 1600
;
# hz is 10, wait for 16 cron tick so that sample array is fulfilled
set value
[
s instantaneous_eventloop_cycles_per_sec
]
set value
[
s instantaneous_eventloop_cycles_per_sec
]
if
{
$::verbose
}
{
puts
"instantaneous metrics instantaneous_eventloop_cycles_per_sec:
$value
"
}
assert_morethan $value 0
assert_morethan $value 0
assert_lessthan $value 15
;
# default hz is 10
assert_lessthan $value 15
;
# default hz is 10
set value
[
s instantaneous_eventloop_duration_usec
]
set value
[
s instantaneous_eventloop_duration_usec
]
if
{
$::verbose
}
{
puts
"instantaneous metrics instantaneous_eventloop_duration_usec:
$value
"
}
assert_morethan $value 0
assert_morethan $value 0
assert_lessthan $value 22000
;
# default hz is 10, so duration < 1000 / 10, allow some tolerance
assert_lessthan $value 22000
;
# default hz is 10, so duration < 1000 / 10, allow some tolerance
}
}
...
...
tests/unit/introspection-2.tcl
View file @
1a589818
...
@@ -153,6 +153,21 @@ start_server {tags {"introspection"}} {
...
@@ -153,6 +153,21 @@ start_server {tags {"introspection"}} {
assert_equal
{
key1 key2
}
[
r command getkeys lcs key1 key2
]
assert_equal
{
key1 key2
}
[
r command getkeys lcs key1 key2
]
}
}
test
{
COMMAND GETKEYS MORE THAN 256 KEYS
}
{
set all_keys
[
list
]
set numkeys 260
for
{
set i 1
}
{
$i
<= $numkeys
}
{
incr i
}
{
lappend all_keys
"key
$i
"
}
set all_keys_with_target
[
linsert $all_keys 0 target
]
# we are using ZUNIONSTORE command since in order to reproduce allocation of a new buffer in getKeysPrepareResult
# when numkeys in result > 0
# we need a command that the final number of keys is not known in the first call to getKeysPrepareResult
# before the fix in that case data of old buffer was not copied to the new result buffer
# causing all previous keys
(
numkeys
)
data to be uninitialize
assert_equal $all_keys_with_target
[
r command getkeys ZUNIONSTORE target $numkeys
{*}
$all
_keys
]
}
test
"COMMAND LIST syntax error"
{
test
"COMMAND LIST syntax error"
{
assert_error
"ERR syntax error*"
{
r command list bad_arg
}
assert_error
"ERR syntax error*"
{
r command list bad_arg
}
assert_error
"ERR syntax error*"
{
r command list filterby bad_arg
}
assert_error
"ERR syntax error*"
{
r command list filterby bad_arg
}
...
...
tests/unit/introspection.tcl
View file @
1a589818
...
@@ -275,27 +275,6 @@ start_server {tags {"introspection"}} {
...
@@ -275,27 +275,6 @@ start_server {tags {"introspection"}} {
r client list
r client list
}
{
*name= *
}
}
{
*name= *
}
test
{
Coverage: Basic CLIENT CACHING
}
{
set rd_redirection
[
redis_deferring_client
]
$rd_redirection client id
set redir_id
[
$rd
_redirection read
]
r CLIENT TRACKING on OPTIN REDIRECT $redir_id
r CLIENT CACHING yes
r CLIENT TRACKING off
}
{
OK
}
test
{
Coverage: Basic CLIENT REPLY
}
{
r CLIENT REPLY on
}
{
OK
}
test
{
Coverage: Basic CLIENT TRACKINGINFO
}
{
r CLIENT TRACKINGINFO
}
{
flags off redirect -1 prefixes
{}}
test
{
Coverage: Basic CLIENT GETREDIR
}
{
r CLIENT GETREDIR
}
{
-1
}
test
{
CLIENT SETNAME does not accept spaces
}
{
test
{
CLIENT SETNAME does not accept spaces
}
{
catch
{
r client setname
"foo bar"
}
e
catch
{
r client setname
"foo bar"
}
e
set e
set e
...
@@ -652,6 +631,10 @@ start_server {tags {"introspection"}} {
...
@@ -652,6 +631,10 @@ start_server {tags {"introspection"}} {
}
}
test
{
redis-server command line arguments - error cases
}
{
test
{
redis-server command line arguments - error cases
}
{
# Take '--invalid' as the option.
catch
{
exec src/redis-server --invalid
}
err
assert_match
{
*Bad directive or wrong number of arguments*
}
$err
catch
{
exec src/redis-server --port
}
err
catch
{
exec src/redis-server --port
}
err
assert_match
{
*'port'*wrong number of arguments*
}
$err
assert_match
{
*'port'*wrong number of arguments*
}
$err
...
...
tests/unit/maxmemory.tcl
View file @
1a589818
...
@@ -571,3 +571,20 @@ start_server {tags {"maxmemory" "external:skip"}} {
...
@@ -571,3 +571,20 @@ start_server {tags {"maxmemory" "external:skip"}} {
r config set maxmemory-policy noeviction
r config set maxmemory-policy noeviction
}
}
}
}
start_server
{
tags
{
"maxmemory"
"external:skip"
}}
{
test
{
lru/lfu value of the key just added
}
{
r config set maxmemory-policy allkeys-lru
r set foo a
assert
{[
r object idletime foo
]
<= 2
}
r del foo
r set foo 1
r get foo
assert
{[
r object idletime foo
]
<= 2
}
r config set maxmemory-policy allkeys-lfu
r del foo
r set foo a
assert
{[
r object freq foo
]
== 5
}
}
}
tests/unit/moduleapi/async_rm_call.tcl
View file @
1a589818
...
@@ -15,7 +15,18 @@ start_server {tags {"modules"}} {
...
@@ -15,7 +15,18 @@ start_server {tags {"modules"}} {
assert_equal
{
0
}
[
r llen l
]
assert_equal
{
0
}
[
r llen l
]
}
}
foreach cmd
{
do_rm_call_async do_rm_call_async_script_mode
}
{
test
"Blpop on threaded async RM_Call"
{
set rd
[
redis_deferring_client
]
$rd do_rm_call_async_on_thread blpop l 0
wait_for_blocked_clients_count 1
r lpush l a
assert_equal
[
$rd
read
]
{
l a
}
wait_for_blocked_clients_count 0
$rd close
}
foreach cmd
{
do_rm_call_async do_rm_call_async_script_mode
}
{
test
"Blpop on async RM_Call using
$cmd
"
{
test
"Blpop on async RM_Call using
$cmd
"
{
set rd
[
redis_deferring_client
]
set rd
[
redis_deferring_client
]
...
@@ -25,6 +36,7 @@ start_server {tags {"modules"}} {
...
@@ -25,6 +36,7 @@ start_server {tags {"modules"}} {
r lpush l a
r lpush l a
assert_equal
[
$rd
read
]
{
l a
}
assert_equal
[
$rd
read
]
{
l a
}
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
}
}
test
"Brpop on async RM_Call using
$cmd
"
{
test
"Brpop on async RM_Call using
$cmd
"
{
...
@@ -35,6 +47,7 @@ start_server {tags {"modules"}} {
...
@@ -35,6 +47,7 @@ start_server {tags {"modules"}} {
r lpush l a
r lpush l a
assert_equal
[
$rd
read
]
{
l a
}
assert_equal
[
$rd
read
]
{
l a
}
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
}
}
test
"Brpoplpush on async RM_Call using
$cmd
"
{
test
"Brpoplpush on async RM_Call using
$cmd
"
{
...
@@ -45,6 +58,7 @@ start_server {tags {"modules"}} {
...
@@ -45,6 +58,7 @@ start_server {tags {"modules"}} {
r lpush l1 a
r lpush l1 a
assert_equal
[
$rd
read
]
{
a
}
assert_equal
[
$rd
read
]
{
a
}
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
r lpop l2
r lpop l2
}
{
a
}
}
{
a
}
...
@@ -56,6 +70,7 @@ start_server {tags {"modules"}} {
...
@@ -56,6 +70,7 @@ start_server {tags {"modules"}} {
r lpush l1 a
r lpush l1 a
assert_equal
[
$rd
read
]
{
a
}
assert_equal
[
$rd
read
]
{
a
}
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
r lpop l2
r lpop l2
}
{
a
}
}
{
a
}
...
@@ -67,6 +82,7 @@ start_server {tags {"modules"}} {
...
@@ -67,6 +82,7 @@ start_server {tags {"modules"}} {
r zadd s 10 foo
r zadd s 10 foo
assert_equal
[
$rd
read
]
{
s foo 10
}
assert_equal
[
$rd
read
]
{
s foo 10
}
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
}
}
test
"Bzpopmax on async RM_Call using
$cmd
"
{
test
"Bzpopmax on async RM_Call using
$cmd
"
{
...
@@ -77,6 +93,7 @@ start_server {tags {"modules"}} {
...
@@ -77,6 +93,7 @@ start_server {tags {"modules"}} {
r zadd s 10 foo
r zadd s 10 foo
assert_equal
[
$rd
read
]
{
s foo 10
}
assert_equal
[
$rd
read
]
{
s foo 10
}
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
}
}
}
}
...
@@ -88,6 +105,7 @@ start_server {tags {"modules"}} {
...
@@ -88,6 +105,7 @@ start_server {tags {"modules"}} {
r lpush l a
r lpush l a
assert_equal
[
$rd
read
]
{
l a
}
assert_equal
[
$rd
read
]
{
l a
}
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
}
}
test
{
Test multiple async RM_Call waiting on the same event
}
{
test
{
Test multiple async RM_Call waiting on the same event
}
{
...
@@ -101,6 +119,8 @@ start_server {tags {"modules"}} {
...
@@ -101,6 +119,8 @@ start_server {tags {"modules"}} {
assert_equal
[
$rd1
read
]
{
l element
}
assert_equal
[
$rd1
read
]
{
l element
}
assert_equal
[
$rd2
read
]
{
l element
}
assert_equal
[
$rd2
read
]
{
l element
}
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd1 close
$rd2 close
}
}
test
{
async RM_Call calls RM_Call
}
{
test
{
async RM_Call calls RM_Call
}
{
...
@@ -136,6 +156,7 @@ start_server {tags {"modules"}} {
...
@@ -136,6 +156,7 @@ start_server {tags {"modules"}} {
}
}
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
}
}
test
{
Become replica while having async RM_Call running
}
{
test
{
Become replica while having async RM_Call running
}
{
...
@@ -156,6 +177,7 @@ start_server {tags {"modules"}} {
...
@@ -156,6 +177,7 @@ start_server {tags {"modules"}} {
r lpush l 1
r lpush l 1
# make sure the async rm_call was aborted
# make sure the async rm_call was aborted
assert_equal
[
r llen l
]
{
1
}
assert_equal
[
r llen l
]
{
1
}
$rd close
}
}
test
{
Pipeline with blocking RM_Call
}
{
test
{
Pipeline with blocking RM_Call
}
{
...
@@ -175,6 +197,7 @@ start_server {tags {"modules"}} {
...
@@ -175,6 +197,7 @@ start_server {tags {"modules"}} {
assert_equal
[
$rd
read
]
{
PONG
}
assert_equal
[
$rd
read
]
{
PONG
}
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
}
}
test
{
blocking RM_Call abort
}
{
test
{
blocking RM_Call abort
}
{
...
@@ -195,6 +218,7 @@ start_server {tags {"modules"}} {
...
@@ -195,6 +218,7 @@ start_server {tags {"modules"}} {
r lpush l 1
r lpush l 1
# make sure the async rm_call was aborted
# make sure the async rm_call was aborted
assert_equal
[
r llen l
]
{
1
}
assert_equal
[
r llen l
]
{
1
}
$rd close
}
}
}
}
...
@@ -220,6 +244,7 @@ start_server {tags {"modules"}} {
...
@@ -220,6 +244,7 @@ start_server {tags {"modules"}} {
close_replication_stream $repl
close_replication_stream $repl
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
}
}
test
{
Test unblock handler are executed as a unit
}
{
test
{
Test unblock handler are executed as a unit
}
{
...
@@ -245,6 +270,7 @@ start_server {tags {"modules"}} {
...
@@ -245,6 +270,7 @@ start_server {tags {"modules"}} {
close_replication_stream $repl
close_replication_stream $repl
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
}
}
test
{
Test no propagation of blocking command
}
{
test
{
Test no propagation of blocking command
}
{
...
@@ -269,6 +295,7 @@ start_server {tags {"modules"}} {
...
@@ -269,6 +295,7 @@ start_server {tags {"modules"}} {
close_replication_stream $repl
close_replication_stream $repl
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
}
}
}
}
...
@@ -303,6 +330,7 @@ start_server {tags {"modules"}} {
...
@@ -303,6 +330,7 @@ start_server {tags {"modules"}} {
close_replication_stream $repl
close_replication_stream $repl
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
}
}
test
{
Test unblock handler are executed as a unit with lazy expire
}
{
test
{
Test unblock handler are executed as a unit with lazy expire
}
{
...
@@ -355,9 +383,10 @@ start_server {tags {"modules"}} {
...
@@ -355,9 +383,10 @@ start_server {tags {"modules"}} {
}
}
close_replication_stream $repl
close_replication_stream $repl
r DEBUG SET-ACTIVE-EXPIRE 1
r DEBUG SET-ACTIVE-EXPIRE 1
wait_for_blocked_clients_count 0
$rd close
}
}
wait_for_blocked_clients_count 0
}
}
start_server
{
tags
{
"modules"
}}
{
start_server
{
tags
{
"modules"
}}
{
...
@@ -376,5 +405,6 @@ start_server {tags {"modules"}} {
...
@@ -376,5 +405,6 @@ start_server {tags {"modules"}} {
assert_equal
[
$rd
read
]
{
4
}
assert_equal
[
$rd
read
]
{
4
}
wait_for_blocked_clients_count 0
wait_for_blocked_clients_count 0
$rd close
}
}
}
}
\ No newline at end of file
tests/unit/moduleapi/blockedclient.tcl
View file @
1a589818
...
@@ -253,6 +253,34 @@ foreach call_type {nested normal} {
...
@@ -253,6 +253,34 @@ foreach call_type {nested normal} {
assert_match
{
*calls=2,*,rejected_calls=0,failed_calls=2
}
[
cmdrstat do_bg_rm_call r
]
assert_match
{
*calls=2,*,rejected_calls=0,failed_calls=2
}
[
cmdrstat do_bg_rm_call r
]
}
}
set master
[
srv 0 client
]
set master_host
[
srv 0 host
]
set master_port
[
srv 0 port
]
start_server
[
list overrides
[
list loadmodule
"
$testmodule
"
]]
{
set replica
[
srv 0 client
]
set replica_host
[
srv 0 host
]
set replica_port
[
srv 0 port
]
# Start the replication process...
$replica replicaof $master_host $master_port
wait_for_sync $replica
test
{
WAIT command on module blocked client
}
{
pause_process
[
srv 0 pid
]
$master do_bg_rm_call_format ! hset bk1 foo bar
assert_equal
[
$master
wait 1 1000
]
0
resume_process
[
srv 0 pid
]
assert_equal
[
$master
wait 1 1000
]
1
assert_equal
[
$replica
hget bk1 foo
]
bar
}
}
test
{
Unblock by timer
}
{
assert_match
"OK"
[
r unblock_by_timer 100
]
}
test
"Unload the module - blockedclient"
{
test
"Unload the module - blockedclient"
{
assert_equal
{
OK
}
[
r module unload blockedclient
]
assert_equal
{
OK
}
[
r module unload blockedclient
]
}
}
...
...
tests/unit/moduleapi/blockonkeys.tcl
View file @
1a589818
...
@@ -34,6 +34,31 @@ start_server {tags {"modules"}} {
...
@@ -34,6 +34,31 @@ start_server {tags {"modules"}} {
assert_equal
{
42
}
[
r fsl.getall src
]
assert_equal
{
42
}
[
r fsl.getall src
]
}
}
test
"Module client blocked on keys: BPOPPUSH unblocked by timer"
{
set rd1
[
redis_deferring_client
]
r del src dst
set repl
[
attach_to_replication_stream
]
$rd1 fsl.bpoppush src dst 0
wait_for_blocked_clients_count 1
r fsl.pushtimer src 9000 10
wait_for_blocked_clients_count 0
assert_equal
{
9000
}
[
r fsl.getall dst
]
assert_equal
{}
[
r fsl.getall src
]
assert_replication_stream $repl
{
{
select *
}
{
fsl.push src 9000
}
{
fsl.bpoppush src dst 0
}
}
close_replication_stream $repl
}
{}
{
needs:repl
}
test
{
Module client blocked on keys
(
no metadata
)
: No block
}
{
test
{
Module client blocked on keys
(
no metadata
)
: No block
}
{
r del k
r del k
r fsl.push k 33
r fsl.push k 33
...
@@ -303,4 +328,39 @@ start_server {tags {"modules"}} {
...
@@ -303,4 +328,39 @@ start_server {tags {"modules"}} {
assert_equal
{
someval
}
[
$rd
read
]
assert_equal
{
someval
}
[
$rd
read
]
$rd close
$rd close
}
}
set master
[
srv 0 client
]
set master_host
[
srv 0 host
]
set master_port
[
srv 0 port
]
start_server
[
list overrides
[
list loadmodule
"
$testmodule
"
]]
{
set replica
[
srv 0 client
]
set replica_host
[
srv 0 host
]
set replica_port
[
srv 0 port
]
# Start the replication process...
$replica replicaof $master_host $master_port
wait_for_sync $replica
test
{
WAIT command on module blocked client on keys
}
{
set rd
[
redis_deferring_client -1
]
$rd set x y
$rd read
pause_process
[
srv 0 pid
]
$master del k
$rd fsl.bpop k 0
wait_for_blocked_client -1
$master fsl.push k 34
$master fsl.push k 35
assert_equal
{
34
}
[
$rd
read
]
assert_equal
[
$master
wait 1 1000
]
0
resume_process
[
srv 0 pid
]
assert_equal
[
$master
wait 1 1000
]
1
$rd close
assert_equal
{
35
}
[
$replica
fsl.getall k
]
}
}
}
}
tests/unit/moduleapi/commandfilter.tcl
View file @
1a589818
...
@@ -139,5 +139,27 @@ test {Blocking Commands don't run through command filter when reprocessed} {
...
@@ -139,5 +139,27 @@ test {Blocking Commands don't run through command filter when reprocessed} {
assert_equal
[
$rd
read
]
1
assert_equal
[
$rd
read
]
1
# validate that we moved the correct elements to the correct side of the list
# validate that we moved the correct elements to the correct side of the list
assert_equal
[
r lpop list2
{
t
}]
1
assert_equal
[
r lpop list2
{
t
}]
1
$rd close
}
}
}
}
test
{
Filtering based on client id
}
{
start_server
{
tags
{
"modules"
}}
{
r module load $testmodule log-key 0
set rr
[
redis_client
]
set cid
[
$rr
client id
]
r unfilter_clientid $cid
r rpush mylist elem1 @replaceme elem2
assert_equal
[
r lrange mylist 0 -1
]
{
elem1 --replaced-- elem2
}
r del mylist
assert_equal
[
$rr
rpush mylist elem1 @replaceme elem2
]
3
assert_equal
[
r lrange mylist 0 -1
]
{
elem1 @replaceme elem2
}
$rr close
}
}
\ No newline at end of file
tests/unit/moduleapi/datatype.tcl
View file @
1a589818
...
@@ -89,4 +89,46 @@ start_server {tags {"modules"}} {
...
@@ -89,4 +89,46 @@ start_server {tags {"modules"}} {
$rd read
$rd read
$rd close
$rd close
}
}
test
{
DataType: check the type name
}
{
r flushdb
r datatype.set foo 111 bar
assert_type test___dt foo
}
test
{
SCAN module datatype
}
{
r flushdb
populate 1000
r datatype.set foo 111 bar
set type
[
r type foo
]
set cur 0
set keys
{}
while 1
{
set res
[
r scan $cur type $type
]
set cur
[
lindex $res 0
]
set k
[
lindex $res 1
]
lappend keys
{*}
$k
if
{
$cur
== 0
}
break
}
assert_equal 1
[
llength $keys
]
}
test
{
SCAN module datatype with case sensitive
}
{
r flushdb
populate 1000
r datatype.set foo 111 bar
set type
"tEsT___dT"
set cur 0
set keys
{}
while 1
{
set res
[
r scan $cur type $type
]
set cur
[
lindex $res 0
]
set k
[
lindex $res 1
]
lappend keys
{*}
$k
if
{
$cur
== 0
}
break
}
assert_equal 1
[
llength $keys
]
}
}
}
tests/unit/moduleapi/misc.tcl
View file @
1a589818
...
@@ -148,6 +148,19 @@ start_server {overrides {save {900 1}} tags {"modules"}} {
...
@@ -148,6 +148,19 @@ start_server {overrides {save {900 1}} tags {"modules"}} {
$rd_trk close
$rd_trk close
}
}
test
{
publish to self inside rm_call
}
{
r hello 3
r subscribe foo
# published message comes after the response of the command that issued it.
assert_equal
[
r test.rm_call publish foo bar
]
{
1
}
assert_equal
[
r read
]
{
message foo bar
}
r unsubscribe foo
r hello 2
set _
""
}
{}
{
resp3
}
test
{
test module get/set client name by id api
}
{
test
{
test module get/set client name by id api
}
{
catch
{
r test.getname
}
e
catch
{
r test.getname
}
e
assert_equal
"-ERR No name"
$e
assert_equal
"-ERR No name"
$e
...
...
Prev
1
…
3
4
5
6
7
8
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment