Test that a disconnect after the write request but before the data is an error

This commit is contained in:
Alex Young
2012-07-03 15:25:39 +01:00
parent a767d4bc8c
commit d16aebf36e
13 changed files with 52 additions and 11 deletions

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# encoding: utf-8
# We connect, pause the server, issue a write request, disconnect,
# then cont the server. This ensures that our disconnect happens
# while the server is trying to read the write data.
require 'flexnbd/fake_source'
include FlexNBD
addr, port, srv_pid = *ARGV
client = FakeSource.new( addr, port, "Timed out connecting" )
client.read_hello
Process.kill( "STOP", srv_pid.to_i )
client.write_write_request( 0, 8 )
client.close
Process.kill( "CONT", srv_pid.to_i )
# This sleep ensures that we don't return control to the test runner
# too soon, giving the flexnbd process time to fall over if it's going
# to.
sleep(0.25)
# ...and can we reconnect?
client2 = FakeSource.new( addr, port, "Timed out connecting" )
client2.close
exit(0)