Test the source handles a dest crash after write correctly

This commit is contained in:
Alex Young
2012-07-03 14:52:27 +01:00
parent 64ebbe7688
commit a767d4bc8c
2 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
#!/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
server = FakeDest.new( *ARGV )
client = server.accept( "Timed out waiting for a connection" )
client.write_hello
client.read_request
client.close
new_client = server.accept( "Timed out waiting for a reconnection" )
new_client.close
server.close
exit 0

View File

@@ -82,6 +82,13 @@ class TestSourceErrorHandling < Test::Unit::TestCase
end
def test_disconnect_before_write_reply_causes_retry
run_fake( "dest/close_after_write" )
@env.mirror12_unchecked
assert_success
end
private
def run_fake(name)
@env.run_fake( name, @env.ip, @env.port2 )