"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/support/server.tcl" between
redis-6.0.7.tar.gz and redis-6.0.8.tar.gz

About: redis is an advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

server.tcl  (redis-6.0.7):server.tcl  (redis-6.0.8)
skipping to change at line 16 skipping to change at line 16
set err {} set err {}
append err "Can't start the Redis server\n" append err "Can't start the Redis server\n"
append err "CONFIGURATION:" append err "CONFIGURATION:"
append err [exec cat $config_file] append err [exec cat $config_file]
append err "\nERROR:" append err "\nERROR:"
append err [string trim $error] append err [string trim $error]
send_data_packet $::test_server_fd err $err send_data_packet $::test_server_fd err $err
} }
proc check_valgrind_errors stderr { proc check_valgrind_errors stderr {
set fd [open $stderr] set res [find_valgrind_errors $stderr]
set buf [read $fd] if {$res != ""} {
close $fd send_data_packet $::test_server_fd err "Valgrind error: $res\n"
# look for stack trace and other errors, or the absense of a leak free summa
ry
if {[regexp -- { at 0x} $buf] ||
[regexp -- {Warning} $buf] ||
[regexp -- {Invalid} $buf] ||
[regexp -- {Mismatched} $buf] ||
[regexp -- {uninitialized} $buf] ||
[regexp -- {has a fishy} $buf] ||
[regexp -- {overlap} $buf] ||
(![regexp -- {definitely lost: 0 bytes} $buf] &&
![regexp -- {no leaks are possible} $buf])} {
send_data_packet $::test_server_fd err "Valgrind error: $buf\n"
} }
} }
proc clean_persistence config {
# we may wanna keep the logs for later, but let's clean the persistence
# files right away, since they can accumulate and take up a lot of space
set config [dict get $config "config"]
set rdb [format "%s/%s" [dict get $config "dir"] "dump.rdb"]
set aof [format "%s/%s" [dict get $config "dir"] "appendonly.aof"]
catch {exec rm -rf $rdb}
catch {exec rm -rf $aof}
}
proc kill_server config { proc kill_server config {
# nothing to kill when running against external server # nothing to kill when running against external server
if {$::external} return if {$::external} return
# nevermind if its already dead # nevermind if its already dead
if {![is_alive $config]} { if {![is_alive $config]} {
# Check valgrind errors if needed # Check valgrind errors if needed
if {$::valgrind} { if {$::valgrind} {
check_valgrind_errors [dict get $config stderr] check_valgrind_errors [dict get $config stderr]
} }
skipping to change at line 153 skipping to change at line 151
set ping 0 set ping 0
} }
if {$ping} {return 1} if {$ping} {return 1}
after 50 after 50
} }
return 0 return 0
} }
# doesn't really belong here, but highly coupled to code in start_server # doesn't really belong here, but highly coupled to code in start_server
proc tags {tags code} { proc tags {tags code} {
# If we 'tags' contain multiple tags, quoted and seperated by spaces,
# we want to get rid of the quotes in order to have a proper list
set tags [string map { \" "" } $tags]
set ::tags [concat $::tags $tags] set ::tags [concat $::tags $tags]
# We skip unwanted tags
foreach tag $::denytags {
if {[lsearch $::tags $tag] >= 0} {
incr ::num_aborted
send_data_packet $::test_server_fd ignore "Tag: $tag"
set ::tags [lrange $::tags 0 end-[llength $tags]]
return
}
}
uplevel 1 $code uplevel 1 $code
set ::tags [lrange $::tags 0 end-[llength $tags]] set ::tags [lrange $::tags 0 end-[llength $tags]]
} }
# Write the configuration in the dictionary 'config' in the specified # Write the configuration in the dictionary 'config' in the specified
# file name. # file name.
proc create_server_config_file {filename config} { proc create_server_config_file {filename config} {
set fp [open $filename w+] set fp [open $filename w+]
foreach directive [dict keys $config] { foreach directive [dict keys $config] {
puts -nonewline $fp "$directive " puts -nonewline $fp "$directive "
skipping to change at line 219 skipping to change at line 229
# for this reason. # for this reason.
if {[regexp {Could not create server TCP} [exec cat $stdout]]} { if {[regexp {Could not create server TCP} [exec cat $stdout]]} {
set port_busy 1 set port_busy 1
break break
} }
} }
return $port_busy return $port_busy
} }
proc start_server {options {code undefined}} { proc start_server {options {code undefined}} {
# setup defaults
set baseconfig "default.conf"
set overrides {}
set tags {}
set keep_persistence false
# parse options
foreach {option value} $options {
switch $option {
"config" {
set baseconfig $value
}
"overrides" {
set overrides $value
}
"tags" {
# If we 'tags' contain multiple tags, quoted and seperated by sp
aces,
# we want to get rid of the quotes in order to have a proper lis
t
set tags [string map { \" "" } $value]
set ::tags [concat $::tags $tags]
}
"keep_persistence" {
set keep_persistence $value
}
default {
error "Unknown option $option"
}
}
}
# We skip unwanted tags
foreach tag $::denytags {
if {[lsearch $::tags $tag] >= 0} {
incr ::num_aborted
send_data_packet $::test_server_fd ignore "Tag: $tag"
set ::tags [lrange $::tags 0 end-[llength $tags]]
return
}
}
# If we are running against an external server, we just push the # If we are running against an external server, we just push the
# host/port pair in the stack the first time # host/port pair in the stack the first time
if {$::external} { if {$::external} {
if {[llength $::servers] == 0} { if {[llength $::servers] == 0} {
set srv {} set srv {}
dict set srv "host" $::host dict set srv "host" $::host
dict set srv "port" $::port dict set srv "port" $::port
set client [redis $::host $::port 0 $::tls] set client [redis $::host $::port 0 $::tls]
dict set srv "client" $client dict set srv "client" $client
$client select 9 $client select 9
set config {}
dict set config "port" $::port
dict set srv "config" $config
# append the server to the stack # append the server to the stack
lappend ::servers $srv lappend ::servers $srv
} }
uplevel 1 $code r flushall
return if {[catch {set retval [uplevel 1 $code]} error]} {
} if {$::durable} {
set msg [string range $error 10 end]
# setup defaults lappend details $msg
set baseconfig "default.conf" lappend details $::errorInfo
set overrides {} lappend ::tests_failed $details
set tags {}
# parse options incr ::num_failed
foreach {option value} $options { send_data_packet $::test_server_fd err [join $details "\n"]
switch $option { } else {
"config" { # Re-raise, let handler up the stack take care of this.
set baseconfig $value } error $error $::errorInfo
"overrides" { }
set overrides $value }
"tags" {
set tags $value
set ::tags [concat $::tags $value] }
default {
error "Unknown option $option" }
} }
set ::tags [lrange $::tags 0 end-[llength $tags]]
return
} }
set data [split [exec cat "tests/assets/$baseconfig"] "\n"] set data [split [exec cat "tests/assets/$baseconfig"] "\n"]
set config {} set config {}
if {$::tls} { if {$::tls} {
dict set config "tls-cert-file" [format "%s/tests/tls/redis.crt" [pwd]] dict set config "tls-cert-file" [format "%s/tests/tls/redis.crt" [pwd]]
dict set config "tls-key-file" [format "%s/tests/tls/redis.key" [pwd]] dict set config "tls-key-file" [format "%s/tests/tls/redis.key" [pwd]]
dict set config "tls-dh-params-file" [format "%s/tests/tls/redis.dh" [pw d]] dict set config "tls-dh-params-file" [format "%s/tests/tls/redis.dh" [pw d]]
dict set config "tls-ca-cert-file" [format "%s/tests/tls/ca.crt" [pwd]] dict set config "tls-ca-cert-file" [format "%s/tests/tls/ca.crt" [pwd]]
dict set config "loglevel" "debug" dict set config "loglevel" "debug"
skipping to change at line 304 skipping to change at line 353
dict set config $directive $arguments dict set config $directive $arguments
} }
# write new configuration to temporary file # write new configuration to temporary file
set config_file [tmpfile redis.conf] set config_file [tmpfile redis.conf]
create_server_config_file $config_file $config create_server_config_file $config_file $config
set stdout [format "%s/%s" [dict get $config "dir"] "stdout"] set stdout [format "%s/%s" [dict get $config "dir"] "stdout"]
set stderr [format "%s/%s" [dict get $config "dir"] "stderr"] set stderr [format "%s/%s" [dict get $config "dir"] "stderr"]
# if we're inside a test, write the test name to the server log file
if {[info exists ::cur_test]} {
set fd [open $stdout "a+"]
puts $fd "### Starting server for test $::cur_test"
close $fd
}
# We need a loop here to retry with different ports. # We need a loop here to retry with different ports.
set server_started 0 set server_started 0
while {$server_started == 0} { while {$server_started == 0} {
if {$::verbose} { 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"
set pid [spawn_server $config_file $stdout $stderr] set pid [spawn_server $config_file $stdout $stderr]
skipping to change at line 330 skipping to change at line 386
# are able to do it for example. # are able to do it for example.
if {$port_busy} { if {$port_busy} {
puts "Port $port was already busy, trying another port..." puts "Port $port was already busy, trying another port..."
set port [find_available_port $::baseport $::portcount] set port [find_available_port $::baseport $::portcount]
if {$::tls} { if {$::tls} {
dict set config "tls-port" $port dict set config "tls-port" $port
} else { } else {
dict set config port $port dict set config port $port
} }
create_server_config_file $config_file $config create_server_config_file $config_file $config
# Truncate log so wait_server_started will not be looking at
# output of the failed server.
close [open $stdout "w"]
continue; # Try again continue; # Try again
} }
if {$::valgrind} {set retrynum 1000} else {set retrynum 100} if {$::valgrind} {set retrynum 1000} else {set retrynum 100}
if {$code ne "undefined"} { if {$code ne "undefined"} {
set serverisup [server_is_up $::host $port $retrynum] set serverisup [server_is_up $::host $port $retrynum]
} else { } else {
set serverisup 1 set serverisup 1
} }
skipping to change at line 416 skipping to change at line 477
# Print warnings from log # Print warnings from log
puts [format "\nLogged warnings (pid %d):" [dict get $srv "pid"]] puts [format "\nLogged warnings (pid %d):" [dict get $srv "pid"]]
set warnings [warnings_from_file [dict get $srv "stdout"]] set warnings [warnings_from_file [dict get $srv "stdout"]]
if {[string length $warnings] > 0} { if {[string length $warnings] > 0} {
puts "$warnings" puts "$warnings"
} else { } else {
puts "(none)" puts "(none)"
} }
puts "" puts ""
error $error $backtrace if {$::durable} {
set msg [string range $error 10 end]
lappend details $msg
lappend details $backtrace
lappend ::tests_failed $details
incr ::num_failed
send_data_packet $::test_server_fd err [join $details "\n"]
} else {
# Re-raise, let handler up the stack take care of this.
error $error $backtrace
}
} }
# fetch srv back from the server list, in case it was restarted by resta rt_server (new PID) # fetch srv back from the server list, in case it was restarted by resta rt_server (new PID)
set srv [lindex $::servers end] set srv [lindex $::servers end]
# Don't do the leak check when no tests were run # Don't do the leak check when no tests were run
if {$num_tests == $::num_tests} { if {$num_tests == $::num_tests} {
dict set srv "skipleaks" 1 dict set srv "skipleaks" 1
} }
# pop the server object # pop the server object
set ::servers [lrange $::servers 0 end-1] set ::servers [lrange $::servers 0 end-1]
set ::tags [lrange $::tags 0 end-[llength $tags]] set ::tags [lrange $::tags 0 end-[llength $tags]]
kill_server $srv kill_server $srv
if {!$keep_persistence} {
clean_persistence $srv
}
set _ ""
} else { } else {
set ::tags [lrange $::tags 0 end-[llength $tags]] set ::tags [lrange $::tags 0 end-[llength $tags]]
set _ $srv set _ $srv
} }
} }
proc restart_server {level wait_ready} { proc restart_server {level wait_ready} {
set srv [lindex $::servers end+$level] set srv [lindex $::servers end+$level]
kill_server $srv kill_server $srv
set stdout [dict get $srv "stdout"] set stdout [dict get $srv "stdout"]
set stderr [dict get $srv "stderr"] set stderr [dict get $srv "stderr"]
set config_file [dict get $srv "config_file"] set config_file [dict get $srv "config_file"]
# if we're inside a test, write the test name to the server log file
if {[info exists ::cur_test]} {
set fd [open $stdout "a+"]
puts $fd "### Restarting server for test $::cur_test"
close $fd
}
set prev_ready_count [exec grep -i "Ready to accept" | wc -l < $stdout] set prev_ready_count [exec grep -i "Ready to accept" | wc -l < $stdout]
set pid [spawn_server $config_file $stdout $stderr] set pid [spawn_server $config_file $stdout $stderr]
# check that the server actually started # check that the server actually started
wait_server_started $config_file $stdout $pid wait_server_started $config_file $stdout $pid
# update the pid in the servers list # update the pid in the servers list
dict set srv "pid" $pid dict set srv "pid" $pid
# re-set $srv in the servers list # re-set $srv in the servers list
 End of changes. 14 change blocks. 
37 lines changed or deleted 121 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)