Moved acceptance tests into tests/acceptance

This commit is contained in:
Alex Young
2012-07-03 10:59:31 +01:00
parent c0c9c6f076
commit 988b2ec014
20 changed files with 3 additions and 5 deletions

View File

@@ -0,0 +1,22 @@
#!/usr/bin/env ruby
# Wait for a sender connection, send a correct hello, then disconnect.
# Simulate a server which crashes after sending the hello. 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.close
new_client = server.accept( "Timed out waiting for a reconnection" )
new_client.close
server.close
exit 0

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env ruby
# encoding: utf-8
require 'flexnbd/fake_dest'
include FlexNBD
server = FakeDest.new( *ARGV )
client = server.accept
client.write_hello
handle = client.read_request[:handle]
client.write_error( handle )
client2 = server.accept( "Timed out waiting for a reconnection" )
client.close
client2.close
server.close
exit(0)

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env ruby
# Will open a server, accept a single connection, then sleep for 5
# seconds. After that time, the client should have disconnected,
# which we can can't effectively check.
#
# This allows the test runner to check that the command-line sees the
# right error message after the timeout time.
require 'flexnbd/fake_dest'
include FlexNBD
server = FakeDest.new( *ARGV )
client = server.accept( "Client didn't make a connection" )
# Sleep for one second past the timeout (a bit of slop in case ruby
# doesn't launch things quickly)
sleep(FlexNBD::MS_HELLO_TIME_SECS + 1)
client.close
server.close

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env ruby
# encoding: utf-8
# Open a socket, say hello, receive a write, then sleep for >
# MS_REQUEST_LIMIT_SECS seconds. This should tell the source that the
# write has gone MIA, and we expect a reconnect.
require 'flexnbd/fake_dest'
include FlexNBD
server = FakeDest.new( *ARGV )
client1 = server.accept( server )
client1.write_hello
client1.read_request
t = Thread.start do
client2 = server.accept( "Timed out waiting for a reconnection",
FlexNBD::MS_REQUEST_LIMIT_SECS + 2 )
client2.close
end
sleep( FlexNBD::MS_REQUEST_LIMIT_SECS + 2 )
client1.close
t.join
server.close
exit(0)

View File

@@ -0,0 +1,25 @@
#!/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
server = FakeDest.new( *ARGV )
client1 = server.accept
# 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.
t = Thread.new do
client2 = server.accept( "Timed out waiting for a reconnection",
FlexNBD::MS_RETRY_DELAY_SECS + 1 )
client2.close
end
client1.write_hello( :magic => :wrong )
t.join
exit 0

View File

@@ -0,0 +1,23 @@
#!/usr/bin/env ruby
# Simulate a server which has a disc of the wrong size attached: send
# a valid NBD hello with a random size, then check that we have see an
# EOF on read.
require 'flexnbd/fake_dest'
include FlexNBD
server = FakeDest.new( *ARGV )
client = server.accept
t = Thread.new do
client2 = server.accept( "Timed out waiting for a reconnection",
FlexNBD::MS_RETRY_DELAY_SECS + 1 )
client2.close
end
client.write_hello( :size => :wrong )
t.join
exit 0

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env ruby
# Accept a connection, then immediately close it. This simulates an ACL rejection.
require 'flexnbd/fake_dest'
include FlexNBD
server = FakeDest.new( *ARGV )
server.accept.close
server.close
exit(0)