Skip to content

Commit

Permalink
Add test demonstrating snapshot restore
Browse files Browse the repository at this point in the history
Issue: #78
  • Loading branch information
scottmuc committed Jul 28, 2024
1 parent d350746 commit 78c8f6c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions devices/erebor/features/file_server.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ Feature: A FreeBSD ZFS NAS
Then my zpool has more storage available

Scenario: Restoring from a snapshot
Given that a snapshot has been made
When a file has been deleted
And I restore from the snapshot
Then my files are all still available
16 changes: 16 additions & 0 deletions devices/erebor/features/step_definitions/initial_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,26 @@ def delete_zpool(name)
@vagrant.exec "sudo zpool replace testpool /dev/md0 /dev/md4"
@vagrant.exec "sudo zpool replace testpool /dev/md1 /dev/md5"
@vagrant.exec "sudo zpool replace testpool /dev/md2 /dev/md6"
@vagrant.exec "sudo zpool online -e testpool /dev/md4"
@vagrant.exec "sudo zpool online -e testpool /dev/md5"
@vagrant.exec "sudo zpool online -e testpool /dev/md6"
end

Then('my zpool has more storage available') do
@new_size = @vagrant.exec "zpool list | grep testpool | awk '{ print $2 }'"
expect(@new_size).not_to eq @start_size
end

Given('that a snapshot has been made') do
@vagrant.exec "sudo zfs snapshot testpool@test"
end

When('a file has been deleted') do
@vagrant.exec "sudo rm /testpool/data/Moby_Dick.txt"
output = @vagrant.exec "ls /testpool/data/"
expect(output).not_to match(/Moby_Dick\.txt/)
end

When('I restore from the snapshot') do
@vagrant.exec "sudo cp /testpool/.zfs/snapshot/test/data/Moby_Dick.txt /testpool/data/Moby_Dick.txt"
end

0 comments on commit 78c8f6c

Please sign in to comment.