Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
psy0rz committed Jul 17, 2020
1 parent 9fe13a4 commit 51c15ec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ Note that the thinner will ONLY destroy snapshots that are matching the naming p

### Destroying missing datasets

When a dataset has been destroyed on the source, but still exists on the target we call it a missing dataset. Missing datasets will be still thinned out according to the schedule.
When a dataset has been destroyed or deselected on the source, but still exists on the target we call it a missing dataset. Missing datasets will be still thinned out according to the schedule.

The final snapshot will never be destroyed, unless you specify a **deadline** with the `--destroy-missing` option:

Expand Down
28 changes: 24 additions & 4 deletions test_destroymissing.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ def test_destroymissing(self):
self.assertNotIn(": Destroy missing", buf.getvalue())


with self.subTest("missing dataset of us that still has children"):

#just deselect it so it counts as 'missing'
shelltest("zfs set autobackup:test=child test_source1/fs1")

with OutputIO() as buf:
with redirect_stdout(buf), redirect_stderr(buf):
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --no-snapshot --destroy-missing 0s".split(" ")).run())

print(buf.getvalue())
#should have done the snapshot cleanup for destoy missing:
self.assertIn("fs1@test-10101111000000: Destroying", buf.getvalue())

self.assertIn("fs1: Destroy missing: Still has children here.", buf.getvalue())

shelltest("zfs inherit autobackup:test test_source1/fs1")


with self.subTest("Normal destroyed leaf"):
shelltest("zfs destroy -r test_source1/fs1/sub")

Expand Down Expand Up @@ -60,9 +78,8 @@ def test_destroymissing(self):
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --no-snapshot --destroy-missing 0s".split(" ")).run())

print(buf.getvalue())
#should have done the snapshot cleanup for destoy missing:
self.assertIn("fs1@test-10101111000000: Destroying", buf.getvalue())
#but cant finish because still in use:

#cant finish because still in use:
self.assertIn("fs1: Destroy missing: Still in use", buf.getvalue())

shelltest("zfs destroy test_target1/test_source1/fs1@other1")
Expand Down Expand Up @@ -102,6 +119,10 @@ def test_destroymissing(self):
#on second run it sees the dangling ex-parent but doesnt know what to do with it (since it has no own snapshot)
self.assertIn("test_source1: Destroy missing: has no snapshots made by us.", buf.getvalue())




#end result
r=shelltest("zfs list -H -o name -r -t all test_target1")
self.assertMultiLineEqual(r,"""
test_target1
Expand All @@ -112,4 +133,3 @@ def test_destroymissing(self):
test_target1/test_source2/fs2/sub@test-10101111000000
test_target1/test_source2/fs2/sub@test-20101111000000
""")

0 comments on commit 51c15ec

Please sign in to comment.