2013-06-19 16:04:01 +05:30
|
|
|
Before do
|
2013-06-28 16:49:24 +05:30
|
|
|
@aruba_timeout_seconds = 120
|
2013-06-19 16:04:01 +05:30
|
|
|
end
|
|
|
|
|
2013-04-11 18:10:47 +05:30
|
|
|
module ThinpWorld
|
|
|
|
def tools_version
|
2013-06-25 15:40:19 +05:30
|
|
|
version = ''
|
|
|
|
|
|
|
|
File.open('VERSION', 'r') do |f|
|
|
|
|
version = f.readline
|
|
|
|
version.chomp!
|
|
|
|
end
|
|
|
|
|
|
|
|
version
|
2013-04-11 18:10:47 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def xml_file
|
|
|
|
'metadata.xml'
|
|
|
|
end
|
|
|
|
|
|
|
|
def dev_file
|
|
|
|
'metadata.bin'
|
|
|
|
end
|
|
|
|
|
2013-06-28 16:49:24 +05:30
|
|
|
def dump_files
|
2013-06-28 16:58:02 +05:30
|
|
|
@dump_files ||= [xml_file]
|
2013-06-28 16:49:24 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def new_dump_file
|
|
|
|
fn = "dump_#{dump_files.size}.xml"
|
|
|
|
@dump_files << fn
|
|
|
|
fn
|
|
|
|
end
|
|
|
|
|
2013-04-23 19:51:44 +05:30
|
|
|
def corrupt_block(n)
|
|
|
|
write_block(n, change_random_byte(read_block(n)))
|
|
|
|
end
|
|
|
|
|
2013-04-11 18:10:47 +05:30
|
|
|
# FIXME: we should really break out the xml stuff from
|
|
|
|
# thinp-test-suite and put in a gem in this repo.
|
|
|
|
def write_valid_xml(path)
|
2013-06-28 16:49:24 +05:30
|
|
|
`thinp_xml create --nr-thins uniform[4..9] --nr-mappings uniform[1000.5000] > #{path}`
|
2013-04-11 18:10:47 +05:30
|
|
|
end
|
2013-04-23 19:51:44 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
def read_block(n)
|
|
|
|
b = nil
|
|
|
|
|
|
|
|
File.open(dev_file, "r") do |f|
|
|
|
|
f.seek(n * 4096)
|
|
|
|
b = f.read(4096)
|
|
|
|
end
|
|
|
|
|
|
|
|
b
|
|
|
|
end
|
|
|
|
|
|
|
|
def write_block(n, b)
|
|
|
|
File.open(dev_file, "w") do |f|
|
|
|
|
f.seek(n * 4096)
|
|
|
|
f.write(b)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def change_random_byte(b)
|
|
|
|
i = rand(b.size)
|
|
|
|
puts "changing byte #{i}"
|
|
|
|
b.setbyte(i, (b.getbyte(i) + 1) % 256)
|
|
|
|
b
|
|
|
|
end
|
2013-04-11 18:10:47 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
World(ThinpWorld)
|