Allow blocksize to be changed in Environment
This number is peppered all over the test suite, so changing @blocksize for everything is not a goer, when we really only need to change it for one test.
This commit is contained in:
@@ -6,10 +6,7 @@ class Environment
|
|||||||
:port1, :port2, :nbd1, :nbd2, :file1, :file2)
|
:port1, :port2, :nbd1, :nbd2, :file1, :file2)
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
# Make sure we have a few pages of memory so we can test msync offsets
|
@blocksize = 1024
|
||||||
# NB If you change this, you need to match it in the flexnbd/fake_dest
|
|
||||||
# Flexnbd::FakeDest::Client#write_hello
|
|
||||||
@blocksize = Integer(`getconf PAGE_SIZE`) * 4
|
|
||||||
@filename1 = "/tmp/.flexnbd.test.#{$PROCESS_ID}.#{Time.now.to_i}.1"
|
@filename1 = "/tmp/.flexnbd.test.#{$PROCESS_ID}.#{Time.now.to_i}.1"
|
||||||
@filename2 = "/tmp/.flexnbd.test.#{$PROCESS_ID}.#{Time.now.to_i}.2"
|
@filename2 = "/tmp/.flexnbd.test.#{$PROCESS_ID}.#{Time.now.to_i}.2"
|
||||||
@ip = '127.0.0.1'
|
@ip = '127.0.0.1'
|
||||||
@@ -22,6 +19,11 @@ class Environment
|
|||||||
@fake_pid = nil
|
@fake_pid = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def blocksize=(b)
|
||||||
|
raise RuntimeError, "Unable to change blocksize after files have been opened" if @file1 or @file2
|
||||||
|
@blocksize = b
|
||||||
|
end
|
||||||
|
|
||||||
def prefetch_proxy!
|
def prefetch_proxy!
|
||||||
@nbd1.prefetch_proxy = true
|
@nbd1.prefetch_proxy = true
|
||||||
@nbd2.prefetch_proxy = true
|
@nbd2.prefetch_proxy = true
|
||||||
|
@@ -22,7 +22,7 @@ module FlexNBD
|
|||||||
if opts[:size] == :wrong
|
if opts[:size] == :wrong
|
||||||
write_rand(@sock, 8)
|
write_rand(@sock, 8)
|
||||||
else
|
else
|
||||||
@sock.write("\x00\x00\x00\x00\x00\x01\x00\x00")
|
@sock.write("\x00\x00\x00\x00\x00\x00\x10\x00")
|
||||||
end
|
end
|
||||||
|
|
||||||
@sock.write("\x00" * 128)
|
@sock.write("\x00" * 128)
|
||||||
|
@@ -119,6 +119,10 @@ class TestServeMode < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_write_with_fua_is_accepted
|
def test_write_with_fua_is_accepted
|
||||||
page_size = Integer(`getconf PAGESIZE`)
|
page_size = Integer(`getconf PAGESIZE`)
|
||||||
|
@env = Environment.new
|
||||||
|
@env.blocksize = page_size * 10
|
||||||
|
@env.writefile1('0')
|
||||||
|
@env.serve1
|
||||||
connect_to_server do |client|
|
connect_to_server do |client|
|
||||||
# Write somewhere in the third page
|
# Write somewhere in the third page
|
||||||
pos = page_size * 3 + 100
|
pos = page_size * 3 + 100
|
||||||
|
Reference in New Issue
Block a user