"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/instances.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.

instances.tcl  (redis-6.0.7):instances.tcl  (redis-6.0.8)
skipping to change at line 22 skipping to change at line 22
set tcl_precision 17 set tcl_precision 17
source ../support/redis.tcl source ../support/redis.tcl
source ../support/util.tcl source ../support/util.tcl
source ../support/server.tcl source ../support/server.tcl
source ../support/test.tcl source ../support/test.tcl
set ::verbose 0 set ::verbose 0
set ::valgrind 0 set ::valgrind 0
set ::tls 0 set ::tls 0
set ::pause_on_error 0 set ::pause_on_error 0
set ::dont_clean 0
set ::simulate_error 0 set ::simulate_error 0
set ::failed 0 set ::failed 0
set ::sentinel_instances {} set ::sentinel_instances {}
set ::redis_instances {} set ::redis_instances {}
set ::sentinel_base_port 20000 set ::sentinel_base_port 20000
set ::redis_base_port 30000 set ::redis_base_port 30000
set ::redis_port_count 1024 set ::redis_port_count 1024
set ::pids {} ; # We kill everything at exit set ::pids {} ; # We kill everything at exit
set ::dirs {} ; # We remove all the temp dirs at exit set ::dirs {} ; # We remove all the temp dirs at exit
set ::run_matching {} ; # If non empty, only tests matching pattern are run. set ::run_matching {} ; # If non empty, only tests matching pattern are run.
if {[catch {cd tmp}]} { if {[catch {cd tmp}]} {
puts "tmp directory not found." puts "tmp directory not found."
puts "Please run this test from the Redis source root." puts "Please run this test from the Redis source root."
exit 1 exit 1
} }
# Execute the specified instance of the server specified by 'type', using # Execute the specified instance of the server specified by 'type', using
# the provided configuration file. Returns the PID of the process. # the provided configuration file. Returns the PID of the process.
proc exec_instance {type cfgfile} { proc exec_instance {type dirname cfgfile} {
if {$type eq "redis"} { if {$type eq "redis"} {
set prgname redis-server set prgname redis-server
} elseif {$type eq "sentinel"} { } elseif {$type eq "sentinel"} {
set prgname redis-sentinel set prgname redis-sentinel
} else { } else {
error "Unknown instance type." error "Unknown instance type."
} }
set errfile [file join $dirname err.txt]
if {$::valgrind} { if {$::valgrind} {
set pid [exec valgrind --track-origins=yes --suppressions=../../../src/v algrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full ../../ ../src/${prgname} $cfgfile &] set pid [exec valgrind --track-origins=yes --suppressions=../../../src/v algrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full ../../ ../src/${prgname} $cfgfile 2>> $errfile &]
} else { } else {
set pid [exec ../../../src/${prgname} $cfgfile &] set pid [exec ../../../src/${prgname} $cfgfile 2>> $errfile &]
} }
return $pid return $pid
} }
# Spawn a redis or sentinel instance, depending on 'type'. # Spawn a redis or sentinel instance, depending on 'type'.
proc spawn_instance {type base_port count {conf {}}} { proc spawn_instance {type base_port count {conf {}}} {
for {set j 0} {$j < $count} {incr j} { for {set j 0} {$j < $count} {incr j} {
set port [find_available_port $base_port $::redis_port_count] set port [find_available_port $base_port $::redis_port_count]
# Create a directory for this instance. # Create a directory for this instance.
skipping to change at line 96 skipping to change at line 98
puts $cfg "logfile log.txt" puts $cfg "logfile log.txt"
# Add additional config files # Add additional config files
foreach directive $conf { foreach directive $conf {
puts $cfg $directive puts $cfg $directive
} }
close $cfg close $cfg
# Finally exec it and remember the pid for later cleanup. # Finally exec it and remember the pid for later cleanup.
set retry 100 set retry 100
while {$retry} { while {$retry} {
set pid [exec_instance $type $cfgfile] set pid [exec_instance $type $dirname $cfgfile]
# Check availability # Check availability
if {[server_is_up 127.0.0.1 $port 100] == 0} { if {[server_is_up 127.0.0.1 $port 100] == 0} {
puts "Starting $type #$j at port $port failed, try another" puts "Starting $type #$j at port $port failed, try another"
incr retry -1 incr retry -1
set port [find_available_port $base_port $::redis_port_count] set port [find_available_port $base_port $::redis_port_count]
set cfg [open $cfgfile a+] set cfg [open $cfgfile a+]
if {$::tls} { if {$::tls} {
puts $cfg "tls-port $port" puts $cfg "tls-port $port"
} else { } else {
skipping to change at line 147 skipping to change at line 149
set start_pattern {*REDIS BUG REPORT START*} set start_pattern {*REDIS BUG REPORT START*}
set logs [glob */log.txt] set logs [glob */log.txt]
foreach log $logs { foreach log $logs {
set fd [open $log] set fd [open $log]
set found 0 set found 0
while {[gets $fd line] >= 0} { while {[gets $fd line] >= 0} {
if {[string match $start_pattern $line]} { if {[string match $start_pattern $line]} {
puts "\n*** Crash report found in $log ***" puts "\n*** Crash report found in $log ***"
set found 1 set found 1
} }
if {$found} {puts $line} if {$found} {
puts $line
incr ::failed
}
}
}
set logs [glob */err.txt]
foreach log $logs {
set res [find_valgrind_errors $log]
if {$res != ""} {
puts $res
incr ::failed
}
}
}
proc is_alive pid {
if {[catch {exec ps -p $pid} err]} {
return 0
} else {
return 1
}
}
proc stop_instance pid {
catch {exec kill $pid}
if {$::valgrind} {
set max_wait 60000
} else {
set max_wait 10000
}
while {[is_alive $pid]} {
incr wait 10
if {$wait >= $max_wait} {
puts "Forcing process $pid to exit..."
catch {exec kill -KILL $pid}
} elseif {$wait % 1000 == 0} {
puts "Waiting for process $pid to exit..."
} }
after 10
} }
} }
proc cleanup {} { proc cleanup {} {
puts "Cleaning up..." puts "Cleaning up..."
log_crashes
foreach pid $::pids { foreach pid $::pids {
catch {exec kill -9 $pid} puts "killing stale instance $pid"
stop_instance $pid
}
log_crashes
if {$::dont_clean} {
return
} }
foreach dir $::dirs { foreach dir $::dirs {
catch {exec rm -rf $dir} catch {exec rm -rf $dir}
} }
} }
proc abort_sentinel_test msg { proc abort_sentinel_test msg {
incr ::failed incr ::failed
puts "WARNING: Aborting the test." puts "WARNING: Aborting the test."
puts ">>>>>>>> $msg" puts ">>>>>>>> $msg"
skipping to change at line 181 skipping to change at line 227
proc parse_options {} { proc parse_options {} {
for {set j 0} {$j < [llength $::argv]} {incr j} { for {set j 0} {$j < [llength $::argv]} {incr j} {
set opt [lindex $::argv $j] set opt [lindex $::argv $j]
set val [lindex $::argv [expr $j+1]] set val [lindex $::argv [expr $j+1]]
if {$opt eq "--single"} { if {$opt eq "--single"} {
incr j incr j
set ::run_matching "*${val}*" set ::run_matching "*${val}*"
} elseif {$opt eq "--pause-on-error"} { } elseif {$opt eq "--pause-on-error"} {
set ::pause_on_error 1 set ::pause_on_error 1
} elseif {$opt eq {--dont-clean}} {
set ::dont_clean 1
} elseif {$opt eq "--fail"} { } elseif {$opt eq "--fail"} {
set ::simulate_error 1 set ::simulate_error 1
} elseif {$opt eq {--valgrind}} { } elseif {$opt eq {--valgrind}} {
set ::valgrind 1 set ::valgrind 1
} elseif {$opt eq {--tls}} { } elseif {$opt eq {--tls}} {
package require tls 1.6 package require tls 1.6
::tls::init \ ::tls::init \
-cafile "$::tlsdir/ca.crt" \ -cafile "$::tlsdir/ca.crt" \
-certfile "$::tlsdir/redis.crt" \ -certfile "$::tlsdir/redis.crt" \
-keyfile "$::tlsdir/redis.key" -keyfile "$::tlsdir/redis.key"
set ::tls 1 set ::tls 1
} elseif {$opt eq "--help"} { } elseif {$opt eq "--help"} {
puts "--single <pattern> Only runs tests specified by pattern." puts "--single <pattern> Only runs tests specified by pattern."
puts "--dont-clean Keep log files on exit."
puts "--pause-on-error Pause for manual inspection on error." puts "--pause-on-error Pause for manual inspection on error."
puts "--fail Simulate a test failure." puts "--fail Simulate a test failure."
puts "--valgrind Run with valgrind." puts "--valgrind Run with valgrind."
puts "--help Shows this help." puts "--help Shows this help."
exit 0 exit 0
} else { } else {
puts "Unknown option $opt" puts "Unknown option $opt"
exit 1 exit 1
} }
} }
skipping to change at line 376 skipping to change at line 425
# The general form is: # The general form is:
# #
# S <sentinel-id> command arg arg arg ... # S <sentinel-id> command arg arg arg ...
# #
# Example to ping the Sentinel 0 (first instance): S 0 PING # Example to ping the Sentinel 0 (first instance): S 0 PING
proc S {n args} { proc S {n args} {
set s [lindex $::sentinel_instances $n] set s [lindex $::sentinel_instances $n]
[dict get $s link] {*}$args [dict get $s link] {*}$args
} }
# Returns a Redis instance by index.
# Example:
# [Rn 0] info
proc Rn {n} {
return [dict get [lindex $::redis_instances $n] link]
}
# Like R but to chat with Redis instances. # Like R but to chat with Redis instances.
proc R {n args} { proc R {n args} {
set r [lindex $::redis_instances $n] [Rn $n] {*}$args
[dict get $r link] {*}$args
} }
proc get_info_field {info field} { proc get_info_field {info field} {
set fl [string length $field] set fl [string length $field]
append field : append field :
foreach line [split $info "\n"] { foreach line [split $info "\n"] {
set line [string trim $line "\r\n "] set line [string trim $line "\r\n "]
if {[string range $line 0 $fl] eq $field} { if {[string range $line 0 $fl] eq $field} {
return [string range $line [expr {$fl+1}] end] return [string range $line [expr {$fl+1}] end]
} }
skipping to change at line 489 skipping to change at line 544
# #
# The instance can be restarted with restart-instance. # The instance can be restarted with restart-instance.
proc kill_instance {type id} { proc kill_instance {type id} {
set pid [get_instance_attrib $type $id pid] set pid [get_instance_attrib $type $id pid]
set port [get_instance_attrib $type $id port] set port [get_instance_attrib $type $id port]
if {$pid == -1} { if {$pid == -1} {
error "You tried to kill $type $id twice." error "You tried to kill $type $id twice."
} }
exec kill -9 $pid stop_instance $pid
set_instance_attrib $type $id pid -1 set_instance_attrib $type $id pid -1
set_instance_attrib $type $id link you_tried_to_talk_with_killed_instance set_instance_attrib $type $id link you_tried_to_talk_with_killed_instance
# Remove the PID from the list of pids to kill at exit. # Remove the PID from the list of pids to kill at exit.
set ::pids [lsearch -all -inline -not -exact $::pids $pid] set ::pids [lsearch -all -inline -not -exact $::pids $pid]
# Wait for the port it was using to be available again, so that's not # Wait for the port it was using to be available again, so that's not
# an issue to start a new server ASAP with the same port. # an issue to start a new server ASAP with the same port.
set retry 100 set retry 100
while {[incr retry -1]} { while {[incr retry -1]} {
skipping to change at line 524 skipping to change at line 579
} }
# Restart an instance previously killed by kill_instance # Restart an instance previously killed by kill_instance
proc restart_instance {type id} { proc restart_instance {type id} {
set dirname "${type}_${id}" set dirname "${type}_${id}"
set cfgfile [file join $dirname $type.conf] set cfgfile [file join $dirname $type.conf]
set port [get_instance_attrib $type $id port] set port [get_instance_attrib $type $id port]
# Execute the instance with its old setup and append the new pid # Execute the instance with its old setup and append the new pid
# file for cleanup. # file for cleanup.
set pid [exec_instance $type $cfgfile] set pid [exec_instance $type $dirname $cfgfile]
set_instance_attrib $type $id pid $pid set_instance_attrib $type $id pid $pid
lappend ::pids $pid lappend ::pids $pid
# Check that the instance is running # Check that the instance is running
if {[server_is_up 127.0.0.1 $port 100] == 0} { if {[server_is_up 127.0.0.1 $port 100] == 0} {
set logfile [file join $dirname log.txt] set logfile [file join $dirname log.txt]
puts [exec tail $logfile] puts [exec tail $logfile]
abort_sentinel_test "Problems starting $type #$id: ping timeout, maybe s erver start failed, check $logfile" abort_sentinel_test "Problems starting $type #$id: ping timeout, maybe s erver start failed, check $logfile"
} }
 End of changes. 16 change blocks. 
11 lines changed or deleted 66 lines changed or added

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