tests: Add a migration test with many clients connecting in two waves
This commit is contained in:
@@ -96,19 +96,9 @@ class TestWriteDuringMigration < Test::Unit::TestCase
|
|||||||
dst_result = Process::waitpid2(@dst_proc)
|
dst_result = Process::waitpid2(@dst_proc)
|
||||||
src_result = Process::waitpid2(@src_proc)
|
src_result = Process::waitpid2(@src_proc)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def source_writer
|
||||||
def test_write_during_migration
|
|
||||||
|
|
||||||
Dir.mktmpdir() do |tmpdir|
|
|
||||||
Dir.chdir( tmpdir ) do
|
|
||||||
make_files()
|
|
||||||
|
|
||||||
launch_servers()
|
|
||||||
|
|
||||||
src_writer = Thread.new do
|
|
||||||
client = FlexNBD::FakeSource.new( "127.0.0.1", @source_port, "Timed out connecting" )
|
client = FlexNBD::FakeSource.new( "127.0.0.1", @source_port, "Timed out connecting" )
|
||||||
offsets = Range.new(0, (@size - @write_data.size) / 4096 ).to_a
|
offsets = Range.new(0, (@size - @write_data.size) / 4096 ).to_a
|
||||||
loop do
|
loop do
|
||||||
@@ -121,10 +111,7 @@ class TestWriteDuringMigration < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
start_mirror()
|
def assert_both_sides_identical
|
||||||
wait_for_quit()
|
|
||||||
src_writer.join
|
|
||||||
|
|
||||||
# puts `md5sum #{@source_file} #{@dest_file}`
|
# puts `md5sum #{@source_file} #{@dest_file}`
|
||||||
|
|
||||||
# Ensure each block matches
|
# Ensure each block matches
|
||||||
@@ -142,8 +129,42 @@ class TestWriteDuringMigration < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_write_during_migration
|
||||||
|
Dir.mktmpdir() do |tmpdir|
|
||||||
|
Dir.chdir( tmpdir ) do
|
||||||
|
make_files()
|
||||||
|
|
||||||
|
launch_servers()
|
||||||
|
|
||||||
|
src_writer = Thread.new { source_writer }
|
||||||
|
|
||||||
|
start_mirror()
|
||||||
|
wait_for_quit()
|
||||||
|
src_writer.join
|
||||||
|
assert_both_sides_identical
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_many_clients_during_migration
|
||||||
|
Dir.mktmpdir() do |tmpdir|
|
||||||
|
Dir.chdir( tmpdir ) do
|
||||||
|
make_files()
|
||||||
|
|
||||||
|
launch_servers()
|
||||||
|
|
||||||
|
src_writers_1 = (1..5).collect { Thread.new { source_writer } }
|
||||||
|
|
||||||
|
start_mirror()
|
||||||
|
|
||||||
|
src_writers_2 = (1..5).collect { Thread.new { source_writer } }
|
||||||
|
|
||||||
|
wait_for_quit()
|
||||||
|
( src_writers_1 + src_writers_2 ).each {|t| t.join }
|
||||||
|
assert_both_sides_identical
|
||||||
|
end
|
||||||
|
end end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user