From 30c81b4f8a12d0fe3ab81ea23383e1c361aab796 Mon Sep 17 00:00:00 2001 From: Edwin Eefting Date: Mon, 14 Oct 2024 17:25:15 +0200 Subject: [PATCH] broke more stuff :) --- tests/test_zfsautobackup.py | 1 + tests/test_zfsautobackup40.py | 13 ++++++++++--- zfs_autobackup/ZfsDataset.py | 14 +++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/test_zfsautobackup.py b/tests/test_zfsautobackup.py index b9bcd65..2a77e5d 100644 --- a/tests/test_zfsautobackup.py +++ b/tests/test_zfsautobackup.py @@ -545,6 +545,7 @@ def test_destroyincompat(self): # should fail, now incompatible self.assertTrue(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run()) + # FIXME: tries to get the guid of the non existing snapshot because of --test mode with mocktime("20101111000003"): # --test should succeed by destroying incompatibles self.assertFalse(ZfsAutobackup( diff --git a/tests/test_zfsautobackup40.py b/tests/test_zfsautobackup40.py index a6ef3e9..1cd1349 100644 --- a/tests/test_zfsautobackup40.py +++ b/tests/test_zfsautobackup40.py @@ -343,7 +343,10 @@ def test_migrate_from_mismatching_bookmarkname(self): shelltest("zfs destroy test_source1/fs1@migrate1") with mocktime("20101111000000"): - self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --debug".split(" ")).run()) + self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --test".split(" ")).run()) + + with mocktime("20101111000000"): + self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose".split(" ")).run()) r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS) self.assertMultiLineEqual(r, """ @@ -376,13 +379,17 @@ def test_migrate_from_mismatching_snapshotname(self): shelltest("zfs snapshot test_source1/fs1@migrate1") shelltest("zfs create test_target1/test_source1") - shelltest("zfs send test_source1/fs1@migrate1| zfs recv test_target1/test_source1/fs1") + shelltest("zfs send test_source1/fs1@migrate1| zfs recv test_target1/test_source1/fs1") # rename it so the names mismatch and guid matching is needed to resolve it shelltest("zfs rename test_source1/fs1@migrate1 test_source1/fs1@randomsnapshotname") + # testmode + with mocktime("20101111000000"): + self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --test".split(" ")).run()) + with mocktime("20101111000000"): - self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --debug".split(" ")).run()) + self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose".split(" ")).run()) r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS) self.assertMultiLineEqual(r, """ diff --git a/zfs_autobackup/ZfsDataset.py b/zfs_autobackup/ZfsDataset.py index 22e7723..882f943 100644 --- a/zfs_autobackup/ZfsDataset.py +++ b/zfs_autobackup/ZfsDataset.py @@ -653,7 +653,7 @@ def find_exact_bookmark(self, bookmark_name): return None def find_snapshot_index(self, snapshot): - """find snapshot index by snapshot (can be a snapshot_name or + """find exact snapshot index by snapshot (can be a snapshot_name or ZfsDataset) Args: @@ -663,11 +663,11 @@ def find_snapshot_index(self, snapshot): if not isinstance(snapshot, ZfsDataset): snapshot_name = snapshot else: - snapshot_name = snapshot.tagless_suffix + snapshot_name = snapshot.suffix index = 0 for snapshot in self.snapshots: - if snapshot.tagless_suffix == snapshot_name: + if snapshot.suffix == snapshot_name: return index index = index + 1 @@ -1122,7 +1122,7 @@ def find_common_snapshot(self, target_dataset, guid_check, bookmark_tag): raise (Exception("Cant find common bookmark or snapshot with target.")) - def find_incompatible_snapshots(self, common_snapshot, raw): + def find_incompatible_snapshots(self, target_common_snapshot, raw): """returns a list[snapshots] that is incompatible for a zfs recv onto the common_snapshot. all direct followup snapshots with written=0 are compatible. @@ -1130,15 +1130,15 @@ def find_incompatible_snapshots(self, common_snapshot, raw): in raw-mode nothing is compatible. issue #219 Args: - :type common_snapshot: ZfsDataset + :type target_common_snapshot: ZfsDataset :type raw: bool """ ret = [] - if common_snapshot and self.snapshots: + if target_common_snapshot and self.snapshots: followup = True - for snapshot in self.snapshots[self.find_snapshot_index(common_snapshot) + 1:]: + for snapshot in self.snapshots[self.find_snapshot_index(target_common_snapshot) + 1:]: if raw or not followup or int(snapshot.properties['written']) != 0: followup = False ret.append(snapshot)