WIP on cache tools

This commit is contained in:
Joe Thornber
2013-09-11 11:40:46 +01:00
parent d3ce6b811b
commit 6615b25e4b
19 changed files with 560 additions and 54 deletions

View File

@@ -28,3 +28,22 @@ Feature: cache_dump
{-h|--help}
{-V|--version}
"""
Scenario: accepts an output file
Given valid cache metadata
When I run cache_dump with -o metadata.xml metadata.bin
Then it should pass
Scenario: missing input file
When I run cache_dump
Then it should fail with:
"""
No input file provided.
"""
Scenario: dump/restore is a noop
Given valid cache metadata
When I cache_dump
And I cache_restore
And I cache_dump
Then cache dumps 1 and 2 should be identical

View File

@@ -40,6 +40,10 @@ Feature: thin_restore
No input file provided.
"""
Scenario: input file not found
When I run cache_restore with -i foo.xml -o metadata.bin
Then it should fail
Scenario: missing output file
When I run cache_restore with -i metadata.xml
Then it should fail with:
@@ -47,9 +51,8 @@ Feature: thin_restore
No output file provided.
"""
Scenario: dump/restore is a noop
Given valid cache metadata
When I dump cache
And I restore cache
And I dump cache
Then cache dumps 1 and 2 should be identical
Scenario: successfully restores a valid xml file
Given a small xml file
And an empty dev file
When I run cache_restore with -i metadata.xml -o metadata.bin
Then it should pass

View File

@@ -64,22 +64,41 @@ When(/^I run cache_restore with (.*?)$/) do |opts|
run_simple("cache_restore #{opts}", false)
end
When(/^I run cache_dump$/) do
run_simple("cache_dump", false)
end
When(/^I run cache_dump with (.*?)$/) do |opts|
run_simple("cache_dump #{opts}", false)
end
Given(/^valid cache metadata$/) do
pending # express the regexp above with the code you wish you had
end
in_current_dir do
system("cache_xml create --nr-cache-blocks uniform[1000-5000] --nr-mappings uniform[500-1000] > #{xml_file}")
end
When(/^I dump cache$/) do
pending # express the regexp above with the code you wish you had
end
When(/^I restore cache$/) do
pending # express the regexp above with the code you wish you had
run_simple("dd if=/dev/zero of=#{dev_file} bs=4k count=1024")
run_simple("cache_restore -i #{xml_file} -o #{dev_file}")
end
Then(/^cache dumps (\d+) and (\d+) should be identical$/) do |arg1, arg2|
pending # express the regexp above with the code you wish you had
run_simple("diff -ub #{dump_files[d1.to_i]} #{dump_files[d2.to_i]}", true)
end
Given(/^a small xml file$/) do
in_current_dir do
system("cache_xml create --nr-cache-blocks 3 --nr-mappings 3 --layout linear --dirty-percent 100 > #{xml_file}")
end
end
Given(/^an empty dev file$/) do
run_simple("dd if=/dev/zero of=#{dev_file} bs=4k count=1024")
end
When(/^I cache_dump$/) do
run_simple("cache_dump #{dev_file} -o #{new_dump_file}", true)
end
When(/^I cache_restore$/) do
run_simple("cache_restore -i #{dump_files[-1]} -o #{dev_file}", true)
end