forked from redis/redis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cluster: Tcl script to check avg pfail->fail time.
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# This simple script is used in order to estimate the average PFAIL->FAIL | ||
# state switch after a failure. | ||
|
||
set ::sleep_time 10 ; # How much to sleep to trigger PFAIL. | ||
set ::fail_port 30016 ; # Node to put in sleep. | ||
set ::other_port 30001 ; # Node to use to monitor the flag switch. | ||
|
||
proc avg vector { | ||
set sum 0.0 | ||
foreach x $vector { | ||
set sum [expr {$sum+$x}] | ||
} | ||
expr {$sum/[llength $vector]} | ||
} | ||
|
||
set samples {} | ||
while 1 { | ||
exec redis-cli -p $::fail_port debug sleep $::sleep_time > /dev/null & | ||
|
||
# Wait for fail? to appear. | ||
while 1 { | ||
set output [exec redis-cli -p $::other_port cluster nodes] | ||
if {[string match {*fail\?*} $output]} break | ||
after 100 | ||
} | ||
|
||
puts "FAIL?" | ||
set start [clock milliseconds] | ||
|
||
# Wait for fail? to disappear. | ||
while 1 { | ||
set output [exec redis-cli -p $::other_port cluster nodes] | ||
if {![string match {*fail\?*} $output]} break | ||
after 100 | ||
} | ||
|
||
puts "FAIL" | ||
set now [clock milliseconds] | ||
set elapsed [expr {$now-$start}] | ||
puts $elapsed | ||
lappend samples $elapsed | ||
|
||
puts "AVG([llength $samples]): [avg $samples]" | ||
|
||
# Wait for the instance to be available again. | ||
exec redis-cli -p $::fail_port ping | ||
|
||
# Wait for the fail flag to be cleared. | ||
after 2000 | ||
} |