Files
flexnbd-c/tests/acceptance/fakes/dest/hello_wrong_magic.rb

27 lines
623 B
Ruby
Raw Normal View History

2012-06-22 10:05:41 +01:00
#!/usr/bin/env ruby
# Simulate a destination which sends the wrong magic.
# We expect the sender to disconnect and reconnect.
require 'flexnbd/fake_dest'
include FlexNBD
2012-06-22 10:05:41 +01:00
addr, port = *ARGV
server = FakeDest.new( addr, port )
client1 = server.accept
2012-06-22 10:05:41 +01:00
# Launch a second thread so that we can spot the reconnection attempt
# as soon as it happens, or alternatively die a flaming death on
# timeout.
2012-06-22 10:05:41 +01:00
t = Thread.new do
client2 = server.accept( "Timed out waiting for a reconnection",
FlexNBD::MS_RETRY_DELAY_SECS + 1 )
client2.close
2012-06-22 10:05:41 +01:00
end
client1.write_hello( :magic => :wrong )
2012-06-22 10:05:41 +01:00
t.join
exit 0