Files
flexnbd-c/tests/acceptance/fakes/source/close_after_connect.rb

25 lines
691 B
Ruby
Raw Normal View History

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.
require 'flexnbd/fake_source'
include FlexNBD::FakeSource
2012-06-22 10:05:41 +01:00
addr, port = *ARGV
connect( 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
# 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)
connect( addr, port, "Failed to reconnect" ).close
2012-06-22 10:05:41 +01:00
exit 0