From 51c15ec618d775f5e463e23b5c2139e5c0391023 Mon Sep 17 00:00:00 2001 From: Edwin Eefting Date: Fri, 17 Jul 2020 18:15:20 +0200 Subject: [PATCH] more tests --- README.md | 2 +- test_destroymissing.py | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fd8b1cb..747926c 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/test_destroymissing.py b/test_destroymissing.py index 6faa940..a1754ec 100644 --- a/test_destroymissing.py +++ b/test_destroymissing.py @@ -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") @@ -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") @@ -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 @@ -112,4 +133,3 @@ def test_destroymissing(self): test_target1/test_source2/fs2/sub@test-10101111000000 test_target1/test_source2/fs2/sub@test-20101111000000 """) -