2012-06-22 10:05:41 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
# Simulate the hello message going astray, or the source hanging after
|
|
|
|
# receiving it.
|
|
|
|
#
|
|
|
|
# We then connect again, to confirm that the destination is still
|
|
|
|
# listening for an incoming migration.
|
|
|
|
|
|
|
|
addr, port = *ARGV
|
2018-02-02 21:34:14 +00:00
|
|
|
require 'flexnbd/fake_source'
|
2012-07-03 14:39:05 +01:00
|
|
|
include FlexNBD
|
2012-06-22 10:05:41 +01:00
|
|
|
|
2018-02-02 21:34:14 +00:00
|
|
|
client = FakeSource.new(addr, port, 'Timed out connecting')
|
2012-07-03 14:39:05 +01:00
|
|
|
client.read_hello
|
2012-06-22 10:05:41 +01:00
|
|
|
|
|
|
|
# Now we do two things:
|
|
|
|
|
|
|
|
# - In the parent process, we sleep for CLIENT_MAX_WAIT_SECS+5, which
|
|
|
|
# will make the destination give up and close the connection.
|
|
|
|
# - In the child process, we sleep for CLIENT_MAX_WAIT_SECS+1, which
|
|
|
|
# should be able to reconnect despite the parent process not having
|
|
|
|
# closed its end yet.
|
|
|
|
|
|
|
|
kidpid = fork do
|
2012-07-03 14:39:05 +01:00
|
|
|
client.close
|
|
|
|
new_client = nil
|
2018-02-02 21:34:14 +00:00
|
|
|
sleep(FlexNBD::CLIENT_MAX_WAIT_SECS + 1)
|
|
|
|
new_client = FakeSource.new(addr, port, 'Timed out reconnecting.')
|
2012-07-03 14:39:05 +01:00
|
|
|
new_client.read_hello
|
2012-06-22 10:05:41 +01:00
|
|
|
exit 0
|
|
|
|
end
|
|
|
|
|
|
|
|
# Sleep for longer than the child, to give the flexnbd process a bit
|
|
|
|
# of slop
|
2018-02-02 21:34:14 +00:00
|
|
|
sleep(FlexNBD::CLIENT_MAX_WAIT_SECS + 3)
|
2012-07-03 14:39:05 +01:00
|
|
|
client.close
|
2012-06-22 10:05:41 +01:00
|
|
|
|
2018-02-02 21:34:14 +00:00
|
|
|
_, status = Process.waitpid2(kidpid)
|
2012-06-22 10:05:41 +01:00
|
|
|
exit status.exitstatus
|