2012-06-22 10:05:41 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
# Connects to the destination server, then immediately disconnects,
|
|
|
|
# simulating a source crash.
|
|
|
|
#
|
|
|
|
# It then connects again, to check that the destination is still
|
|
|
|
# listening.
|
|
|
|
|
2012-06-27 17:28:24 +01:00
|
|
|
require 'flexnbd/fake_source'
|
2012-07-03 14:39:05 +01:00
|
|
|
include FlexNBD
|
2012-06-27 17:28:24 +01:00
|
|
|
|
2012-06-22 10:05:41 +01:00
|
|
|
addr, port = *ARGV
|
|
|
|
|
2012-07-03 14:39:05 +01:00
|
|
|
FakeSource.new( addr, port, "Failed to connect" ).close
|
2012-06-27 15:45:33 +01:00
|
|
|
# Sleep to be sure we don't try to connect too soon. That wouldn't
|
|
|
|
# be a problem for the destination, but it would prevent us from
|
2012-06-27 17:28:24 +01:00
|
|
|
# determining success or failure here in the case where we try to
|
|
|
|
# reconnect before the destination has tidied up after the first
|
|
|
|
# thread went away.
|
|
|
|
sleep(0.5)
|
2012-07-03 14:39:05 +01:00
|
|
|
FakeSource.new( addr, port, "Failed to reconnect" ).close
|
2012-06-22 10:05:41 +01:00
|
|
|
|
|
|
|
exit 0
|