2012-07-03 15:33:00 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
# We connect, pause the server, issue a write request, send data,
|
|
|
|
# disconnect, then cont the server. This ensures that our disconnect
|
|
|
|
# happens before the server can try to write the reply.
|
|
|
|
|
|
|
|
require 'flexnbd/fake_source'
|
|
|
|
include FlexNBD
|
|
|
|
|
|
|
|
addr, port, srv_pid = *ARGV
|
|
|
|
|
|
|
|
client = FakeSource.new( addr, port, "Timed out connecting" )
|
|
|
|
client.read_hello
|
|
|
|
|
2012-07-23 09:48:50 +01:00
|
|
|
system "kill -STOP #{srv_pid}"
|
2012-07-03 15:33:00 +01:00
|
|
|
|
|
|
|
client.write_write_request( 0, 8 )
|
|
|
|
client.write_data( "12345678" )
|
|
|
|
client.close
|
|
|
|
|
2012-07-23 09:48:50 +01:00
|
|
|
system "kill -CONT #{srv_pid}"
|
2012-07-03 15:33:00 +01:00
|
|
|
|
|
|
|
# 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?
|
2012-07-11 15:19:50 +01:00
|
|
|
client2 = FakeSource.new( addr, port, "Timed out reconnecting" )
|
2012-07-03 15:33:00 +01:00
|
|
|
client2.close
|
|
|
|
|
|
|
|
exit(0)
|