Switch from expecting a reconnection to *not* doing do

If we're aborting mirror operations early, a couple of specs need to
change sense.
This commit is contained in:
Alex Young
2012-07-15 22:07:00 +01:00
parent 10625e402b
commit f5850e5aaf
2 changed files with 19 additions and 7 deletions

View File

@@ -1,22 +1,24 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# Simulate a destination which sends the wrong magic. # Simulate a destination which sends the wrong magic.
# We expect the sender to disconnect and reconnect.
require 'flexnbd/fake_dest' require 'flexnbd/fake_dest'
include FlexNBD include FlexNBD
Thread.abort_on_exception
addr, port = *ARGV addr, port = *ARGV
server = FakeDest.new( addr, port ) server = FakeDest.new( addr, port )
client1 = server.accept client1 = server.accept
# Launch a second thread so that we can spot the reconnection attempt # We don't expect a reconnection attempt.
# as soon as it happens, or alternatively die a flaming death on
# timeout.
t = Thread.new do t = Thread.new do
client2 = server.accept( "Timed out waiting for a reconnection", begin
FlexNBD::MS_RETRY_DELAY_SECS + 1 ) client2 = server.accept( "Timed out waiting for a reconnection",
client2.close FlexNBD::MS_RETRY_DELAY_SECS + 1 )
fail "Unexpected reconnection"
rescue Timeout::Error
#expected
end
end end
client1.write_hello( :magic => :wrong ) client1.write_hello( :magic => :wrong )

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# Accept a connection, then immediately close it. This simulates an ACL rejection. # Accept a connection, then immediately close it. This simulates an ACL rejection.
# We do not expect a reconnection.
require 'flexnbd/fake_dest' require 'flexnbd/fake_dest'
include FlexNBD include FlexNBD
@@ -9,6 +10,15 @@ addr, port = *ARGV
server = FakeDest.new( addr, port ) server = FakeDest.new( addr, port )
server.accept.close server.accept.close
begin
server.accept
fail "Unexpected reconnection"
rescue Timeout::Error
# expected
end
server.close server.close
exit(0) exit(0)