Test the source handles a dest crash after write correctly
This commit is contained in:
24
tests/acceptance/fakes/dest/close_after_write.rb
Executable file
24
tests/acceptance/fakes/dest/close_after_write.rb
Executable 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
|
@@ -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 )
|
||||
|
Reference in New Issue
Block a user