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
d92f2f5a
Commit
d92f2f5a
authored
Apr 12, 2022
by
Oran Agra
Browse files
test suite improvements pulled back from 7.0 for cherry picked commits
parent
e1c09d59
Changes
3
Show whitespace changes
Inline
Side-by-side
tests/support/redis.tcl
View file @
d92f2f5a
...
@@ -254,6 +254,12 @@ proc ::redis::redis_read_bool fd {
...
@@ -254,6 +254,12 @@ proc ::redis::redis_read_bool fd {
return -code error
"Bad protocol, '
$v
' as bool type"
return -code error
"Bad protocol, '
$v
' as bool type"
}
}
proc ::redis::redis_read_verbatim_str fd
{
set v
[
redis_bulk_read $fd
]
# strip the first 4 chars
(
"txt:"
)
return
[
string range $v 4 end
]
}
proc ::redis::redis_read_reply
{
id fd
}
{
proc ::redis::redis_read_reply
{
id fd
}
{
if
{
$::redis::readraw
(
$id
)}
{
if
{
$::redis::readraw
(
$id
)}
{
return
[
redis_read_line $fd
]
return
[
redis_read_line $fd
]
...
@@ -268,6 +274,7 @@ proc ::redis::redis_read_reply {id fd} {
...
@@ -268,6 +274,7 @@ proc ::redis::redis_read_reply {id fd} {
+
{
return
[
redis_read_line $fd
]}
+
{
return
[
redis_read_line $fd
]}
,
{
return
[
expr
{
double
([
redis_read_line $fd
])}]}
,
{
return
[
expr
{
double
([
redis_read_line $fd
])}]}
#
{
return
[
redis_read_bool $fd
]}
#
{
return
[
redis_read_bool $fd
]}
=
{
return
[
redis_read_verbatim_str $fd
]}
-
{
return -code error
[
redis_read_line $fd
]}
-
{
return -code error
[
redis_read_line $fd
]}
$
{
return
[
redis_bulk_read $fd
]}
$
{
return
[
redis_bulk_read $fd
]}
> -
> -
...
@@ -317,6 +324,7 @@ proc ::redis::redis_readable {fd id} {
...
@@ -317,6 +324,7 @@ proc ::redis::redis_readable {fd id} {
: -
: -
+
{
redis_call_callback $id reply
[
string range $line 1 end-1
]}
+
{
redis_call_callback $id reply
[
string range $line 1 end-1
]}
-
{
redis_call_callback $id err
[
string range $line 1 end-1
]}
-
{
redis_call_callback $id err
[
string range $line 1 end-1
]}
(
{
redis_call_callback $id reply
[
string range $line 1 end-1
]}
$
{
$
{
dict set ::redis::state
(
$id
)
bulk
\
dict set ::redis::state
(
$id
)
bulk
\
[
expr
[
string range $line 1 end-1
]
+2
]
[
expr
[
string range $line 1 end-1
]
+2
]
...
...
tests/support/util.tcl
View file @
d92f2f5a
...
@@ -771,3 +771,20 @@ proc punsubscribe {client {channels {}}} {
...
@@ -771,3 +771,20 @@ proc punsubscribe {client {channels {}}} {
$client punsubscribe
{*}
$channels
$client punsubscribe
{*}
$channels
consume_subscribe_messages $client punsubscribe $channels
consume_subscribe_messages $client punsubscribe $channels
}
}
proc wait_for_blocked_client
{}
{
wait_for_condition 50 100
{
[
s blocked_clients
]
ne 0
}
else
{
fail
"no blocked clients"
}
}
proc wait_for_blocked_clients_count
{
count
{
maxtries 100
}
{
delay 10
}}
{
wait_for_condition $maxtries $delay
{
[
s blocked_clients
]
== $count
}
else
{
fail
"Timeout waiting for blocked clients"
}
}
tests/test_helper.tcl
View file @
d92f2f5a
...
@@ -116,6 +116,7 @@ set ::stop_on_failure 0
...
@@ -116,6 +116,7 @@ set ::stop_on_failure 0
set ::dump_logs 0
set ::dump_logs 0
set ::loop 0
set ::loop 0
set ::tlsdir
"tests/tls"
set ::tlsdir
"tests/tls"
set ::singledb 0
# Set to 1 when we are running in client mode. The Redis test uses a
# Set to 1 when we are running in client mode. The Redis test uses a
# server-client model to run tests simultaneously. The server instance
# server-client model to run tests simultaneously. The server instance
...
@@ -193,7 +194,7 @@ proc reconnect {args} {
...
@@ -193,7 +194,7 @@ proc reconnect {args} {
dict set srv
"client"
$client
dict set srv
"client"
$client
# select the right db when we don't have to authenticate
# select the right db when we don't have to authenticate
if
{
!
[
dict exists $config
"requirepass"
]}
{
if
{
!
[
dict exists $config
"requirepass"
]
&& !$::singledb
}
{
$client select 9
$client select 9
}
}
...
@@ -212,8 +213,14 @@ proc redis_deferring_client {args} {
...
@@ -212,8 +213,14 @@ proc redis_deferring_client {args} {
set client
[
redis
[
srv $level
"host"
]
[
srv $level
"port"
]
1 $::tls
]
set client
[
redis
[
srv $level
"host"
]
[
srv $level
"port"
]
1 $::tls
]
# select the right db and read the response
(
OK
)
# select the right db and read the response
(
OK
)
if
{
!$::singledb
}
{
$client select 9
$client select 9
$client read
$client read
}
else
{
# For timing/symmetry with the above select
$client ping
$client read
}
return $client
return $client
}
}
...
@@ -227,8 +234,13 @@ proc redis_client {args} {
...
@@ -227,8 +234,13 @@ proc redis_client {args} {
# create client that defers reading reply
# create client that defers reading reply
set client
[
redis
[
srv $level
"host"
]
[
srv $level
"port"
]
0 $::tls
]
set client
[
redis
[
srv $level
"host"
]
[
srv $level
"port"
]
0 $::tls
]
# select the right db and read the response
(
OK
)
# select the right db and read the response
(
OK
)
, or at least ping
# the server if we're in a singledb mode.
if
{
$::singledb
}
{
$client ping
}
else
{
$client select 9
$client select 9
}
return $client
return $client
}
}
...
@@ -565,6 +577,7 @@ proc print_help_screen {} {
...
@@ -565,6 +577,7 @@ proc print_help_screen {} {
"--port <port> TCP port to use against external host."
"--port <port> TCP port to use against external host."
"--baseport <port> Initial port number for spawned redis servers."
"--baseport <port> Initial port number for spawned redis servers."
"--portcount <num> Port range for spawned redis servers."
"--portcount <num> Port range for spawned redis servers."
"--singledb Use a single database, avoid SELECT."
"--help Print this help screen."
"--help Print this help screen."
}
"
\n
"
]
}
"
\n
"
]
}
}
...
@@ -671,6 +684,8 @@ for {set j 0} {$j < [llength $argv]} {incr j} {
...
@@ -671,6 +684,8 @@ for {set j 0} {$j < [llength $argv]} {incr j} {
}
elseif
{
$opt
eq
{
--timeout
}}
{
}
elseif
{
$opt
eq
{
--timeout
}}
{
set ::timeout $arg
set ::timeout $arg
incr j
incr j
}
elseif
{
$opt
eq
{
--singledb
}}
{
set ::singledb 1
}
elseif
{
$opt
eq
{
--help
}}
{
}
elseif
{
$opt
eq
{
--help
}}
{
print_help_screen
print_help_screen
exit 0
exit 0
...
...
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