diff --git a/tests/acceptance/fakes/dest/close_after_write.rb b/tests/acceptance/fakes/dest/close_after_write.rb new file mode 100755 index 0000000..b4ca0a4 --- /dev/null +++ b/tests/acceptance/fakes/dest/close_after_write.rb @@ -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 diff --git a/tests/acceptance/test_source_error_handling.rb b/tests/acceptance/test_source_error_handling.rb index 4dc2d87..09ccab7 100644 --- a/tests/acceptance/test_source_error_handling.rb +++ b/tests/acceptance/test_source_error_handling.rb @@ -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 )