Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
bb06a8c8
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
bb06a8c8
编写于
5月 28, 2020
作者:
S
Salvatore Sanfilippo
提交者:
GitHub
5月 28, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7327 from oranagra/test-port-ranges
tests: each test client work on a distinct port range
上级
28e574bc
1cf33a46
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
48 addition
and
31 deletion
+48
-31
tests/instances.tcl
tests/instances.tcl
+2
-1
tests/support/server.tcl
tests/support/server.tcl
+10
-11
tests/support/util.tcl
tests/support/util.tcl
+13
-8
tests/test_helper.tcl
tests/test_helper.tcl
+21
-9
tests/unit/other.tcl
tests/unit/other.tcl
+2
-2
未找到文件。
tests/instances.tcl
浏览文件 @
bb06a8c8
...
...
@@ -25,6 +25,7 @@ set ::sentinel_instances {}
set ::redis_instances
{}
set ::sentinel_base_port 20000
set ::redis_base_port 30000
set ::redis_port_count 1024
set ::pids
{}
;
# We kill everything at exit
set ::dirs
{}
;
# We remove all the temp dirs at exit
set ::run_matching
{}
;
# If non empty, only tests matching pattern are run.
...
...
@@ -57,7 +58,7 @@ proc exec_instance {type cfgfile} {
# Spawn a redis or sentinel instance, depending on 'type'.
proc spawn_instance
{
type base_port count
{
conf
{}}}
{
for
{
set j 0
}
{
$j
< $count
}
{
incr j
}
{
set port
[
find_available_port $base_port
]
set port
[
find_available_port $base_port
$::redis_port_count
]
incr base_port
puts
"Starting
$type
#
$j
at port
$port
"
...
...
tests/support/server.tcl
浏览文件 @
bb06a8c8
...
...
@@ -214,14 +214,14 @@ proc start_server {options {code undefined}} {
dict set config dir
[
tmpdir server
]
# start every server on a different port
set
::port
[
find_available_port
[
expr
{
$::port
+1
}]
]
set
port
[
find_available_port $::baseport $::portcount
]
if
{
$::tls
}
{
dict set config
"port"
0
dict set config
"tls-port"
$
::
port
dict set config
"tls-port"
$port
dict set config
"tls-cluster"
"yes"
dict set config
"tls-replication"
"yes"
}
else
{
dict set config port $
::
port
dict set config port $port
}
set unixsocket
[
file normalize
[
format
"%s/%s"
[
dict get $config
"dir"
]
"socket"
]]
...
...
@@ -243,10 +243,10 @@ proc start_server {options {code undefined}} {
set server_started 0
while
{
$server
_started == 0
}
{
if
{
$::verbose
}
{
puts -nonewline
"=== (
$tags
) Starting server
${::host}
:
${
::
port}
"
puts -nonewline
"=== (
$tags
) Starting server
${::host}
:
${port}
"
}
send_data_packet $::test_server_fd
"server-spawning"
"port
$
::
port
"
send_data_packet $::test_server_fd
"server-spawning"
"port
$port
"
if
{
$::valgrind
}
{
set pid
[
exec valgrind --track-origins=yes --suppressions=src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full src/redis-server $config_file > $stdout 2> $stderr &
]
...
...
@@ -291,19 +291,19 @@ proc start_server {options {code undefined}} {
# for availability. Other test clients may grab the port before we
# are able to do it for example.
if
{
$port
_busy
}
{
puts
"Port
$
::
port
was already busy, trying another port..."
set
::port
[
find_available_port
[
expr
{
$::port
+1
}]
]
puts
"Port
$port
was already busy, trying another port..."
set
port
[
find_available_port $::baseport $::portcount
]
if
{
$::tls
}
{
dict set config
"tls-port"
$
::
port
dict set config
"tls-port"
$port
}
else
{
dict set config port $
::
port
dict set config port $port
}
create_server_config_file $config_file $config
continue
;
# Try again
}
if
{
$code
ne
"undefined"
}
{
set serverisup
[
server_is_up $::host $
::
port $retrynum
]
set serverisup
[
server_is_up $::host $port $retrynum
]
}
else
{
set serverisup 1
}
...
...
@@ -324,7 +324,6 @@ proc start_server {options {code undefined}} {
# setup properties to be able to initialize a client object
set port_param
[
expr $::tls ?
{
"tls-port"
}
:
{
"port"
}]
set host $::host
set port $::port
if
{[
dict exists $config bind
]}
{
set host
[
dict get $config bind
]
}
if
{[
dict exists $config $port_param
]}
{
set port
[
dict get $config $port_param
]
}
...
...
tests/support/util.tcl
浏览文件 @
bb06a8c8
...
...
@@ -344,21 +344,26 @@ proc roundFloat f {
format
"%.10g"
$f
}
proc find_available_port start
{
for
{
set j $start
}
{
$j
< $start+1024
}
{
incr j
}
{
if
{[
catch
{
set fd1
[
socket 127.0.0.1 $j
]}]
&&
[
catch
{
set fd2
[
socket 127.0.0.1
[
expr $j+10000
]]}]}
{
return $j
set ::last_port_attempted 0
proc find_available_port
{
start count
}
{
set port
[
expr $::last_port_attempted + 1
]
for
{
set attempts 0
}
{
$attempts
< $count
}
{
incr attempts
}
{
if
{
$port
< $start || $port >= $start+$count
}
{
set port $start
}
if
{[
catch
{
set fd1
[
socket 127.0.0.1 $port
]}]
&&
[
catch
{
set fd2
[
socket 127.0.0.1
[
expr $port+10000
]]}]}
{
set ::last_port_attempted $port
return $port
}
else
{
catch
{
close $fd1
close $fd2
}
}
incr port
}
if
{
$j
== $start+1024
}
{
error
"Can't find a non busy port in the
$start-
[
expr
{
$start
+1023
}]
range."
}
error
"Can't find a non busy port in the
$start-
[
expr
{
$start
+$count-1
}]
range."
}
# Test if TERM looks like to support colors
...
...
tests/test_helper.tcl
浏览文件 @
bb06a8c8
...
...
@@ -70,7 +70,9 @@ set ::all_tests {
set ::next_test 0
set ::host 127.0.0.1
set ::port 21111
set ::port 6379
;
# port for external server
set ::baseport 21111
;
# initial port for spawned redis servers
set ::portcount 8000
;
# we don't wanna use more than 10000 to avoid collision with cluster bus ports
set ::traceleaks 0
set ::valgrind 0
set ::tls 0
...
...
@@ -228,26 +230,26 @@ proc test_server_main {} {
set tclsh
[
info nameofexecutable
]
# Open a listening socket, trying different ports in order to find a
# non busy one.
set
port
[
find_available_port 11111
]
set
clientport
[
find_available_port 11111 32
]
if
{
!$::quiet
}
{
puts
"Starting test server at port
$port
"
puts
"Starting test server at port
$
client
port
"
}
socket -server accept_test_clients -myaddr 127.0.0.1 $port
socket -server accept_test_clients -myaddr 127.0.0.1 $
client
port
# Start the client instances
set ::clients_pids
{}
if
{
$::external
}
{
set p
[
exec $tclsh
[
info script
]
{*}
$::argv
\
--client $
port --port $::
port &
]
--client $
client
port &
]
lappend ::clients_pids $p
}
else
{
set start_port
[
expr
{
$::port
+100
}]
set start_port $::baseport
set port_count
[
expr
{
$::portcount
/ $::numclients
}]
for
{
set j 0
}
{
$j
< $::numclients
}
{
incr j
}
{
set start_port
[
find_available_port $start_port
]
set p
[
exec $tclsh
[
info script
]
{*}
$::argv
\
--client $
port --port $start_por
t &
]
--client $
clientport --baseport $start_port --portcount $port_coun
t &
]
lappend ::clients_pids $p
incr start_port
10
incr start_port
$port_count
}
}
...
...
@@ -510,6 +512,10 @@ proc print_help_screen {} {
"--loop Execute the specified set of tests forever."
"--wait-server Wait after server is started (so that you can attach a debugger)."
"--tls Run tests in TLS mode."
"--host <addr> Run tests against an external host."
"--port <port> TCP port to use against external host."
"--baseport <port> Initial port number for spawned redis servers."
"--portcount <num> Port range for spawned redis servers."
"--help Print this help screen."
}
"
\n
"
]
}
...
...
@@ -560,6 +566,12 @@ for {set j 0} {$j < [llength $argv]} {incr j} {
}
elseif
{
$opt
eq
{
--port
}}
{
set ::port $arg
incr j
}
elseif
{
$opt
eq
{
--baseport
}}
{
set ::baseport $arg
incr j
}
elseif
{
$opt
eq
{
--portcount
}}
{
set ::portcount $arg
incr j
}
elseif
{
$opt
eq
{
--accurate
}}
{
set ::accurate 1
}
elseif
{
$opt
eq
{
--force-failure
}}
{
...
...
tests/unit/other.tcl
浏览文件 @
bb06a8c8
...
...
@@ -167,9 +167,9 @@ start_server {tags {"other"}} {
tags
{
protocol
}
{
test
{
PIPELINING stresser
(
also a regression for the old epoll bug
)}
{
if
{
$::tls
}
{
set fd2
[
::tls::socket
$::host $::port
]
set fd2
[
::tls::socket
[
srv host
]
[
srv port
]
]
}
else
{
set fd2
[
socket
$::host $::port
]
set fd2
[
socket
[
srv host
]
[
srv port
]
]
}
fconfigure $fd2 -encoding binary -translation binary
puts -nonewline $fd2
"SELECT 9
\r\n
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录