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:
Patrick J Cherry
2018-02-06 09:55:32 +00:00
parent 7704f9e5c8
commit da35187af0
3 changed files with 11 additions and 5 deletions

View File

@@ -6,10 +6,7 @@ class Environment
:port1, :port2, :nbd1, :nbd2, :file1, :file2)
def initialize
# Make sure we have a few pages of memory so we can test msync offsets
# 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
@blocksize = 1024
@filename1 = "/tmp/.flexnbd.test.#{$PROCESS_ID}.#{Time.now.to_i}.1"
@filename2 = "/tmp/.flexnbd.test.#{$PROCESS_ID}.#{Time.now.to_i}.2"
@ip = '127.0.0.1'
@@ -22,6 +19,11 @@ class Environment
@fake_pid = nil
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!
@nbd1.prefetch_proxy = true
@nbd2.prefetch_proxy = true