2012-07-03 14:52:27 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
# Wait for a sender connection, send a correct hello, wait for a write
|
|
|
|
# request, then disconnect. Simulate a server which crashes after
|
|
|
|
# receiving the write, and before it can send a reply. We then reopen
|
|
|
|
# the server socket to check that the sender retries: since the
|
|
|
|
# command-line has gone away, and can't feed an error back to the
|
|
|
|
# user, we have to keep trying.
|
|
|
|
|
|
|
|
require 'flexnbd/fake_dest'
|
|
|
|
include FlexNBD
|
|
|
|
|
2012-07-03 15:25:39 +01:00
|
|
|
addr, port = *ARGV
|
2018-02-02 21:34:14 +00:00
|
|
|
server = FakeDest.new(addr, port)
|
|
|
|
client = server.accept('Timed out waiting for a connection')
|
2012-07-03 14:52:27 +01:00
|
|
|
client.write_hello
|
|
|
|
client.read_request
|
|
|
|
client.close
|
|
|
|
|
2018-02-02 21:34:14 +00:00
|
|
|
new_client = server.accept('Timed out waiting for a reconnection')
|
2012-07-03 14:52:27 +01:00
|
|
|
new_client.close
|
|
|
|
|
|
|
|
server.close
|
|
|
|
|
|
|
|
exit 0
|