cluster_fail_time.tcl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # This simple script is used in order to estimate the average PFAIL->FAIL
  2. # state switch after a failure.
  3. set ::sleep_time 10 ; # How much to sleep to trigger PFAIL.
  4. set ::fail_port 30016 ; # Node to put in sleep.
  5. set ::other_port 30001 ; # Node to use to monitor the flag switch.
  6. proc avg vector {
  7. set sum 0.0
  8. foreach x $vector {
  9. set sum [expr {$sum+$x}]
  10. }
  11. expr {$sum/[llength $vector]}
  12. }
  13. set samples {}
  14. while 1 {
  15. exec redis-cli -p $::fail_port debug sleep $::sleep_time > /dev/null &
  16. # Wait for fail? to appear.
  17. while 1 {
  18. set output [exec redis-cli -p $::other_port cluster nodes]
  19. if {[string match {*fail\?*} $output]} break
  20. after 100
  21. }
  22. puts "FAIL?"
  23. set start [clock milliseconds]
  24. # Wait for fail? to disappear.
  25. while 1 {
  26. set output [exec redis-cli -p $::other_port cluster nodes]
  27. if {![string match {*fail\?*} $output]} break
  28. after 100
  29. }
  30. puts "FAIL"
  31. set now [clock milliseconds]
  32. set elapsed [expr {$now-$start}]
  33. puts $elapsed
  34. lappend samples $elapsed
  35. puts "AVG([llength $samples]): [avg $samples]"
  36. # Wait for the instance to be available again.
  37. exec redis-cli -p $::fail_port ping
  38. # Wait for the fail flag to be cleared.
  39. after 2000
  40. }