Skip to content

Commit

Permalink
broke more stuff :)
Browse files Browse the repository at this point in the history
  • Loading branch information
psy0rz committed Oct 14, 2024
1 parent 25b71ba commit 30c81b4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions tests/test_zfsautobackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
13 changes: 10 additions & 3 deletions tests/test_zfsautobackup40.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, """
Expand Down Expand Up @@ -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, """
Expand Down
14 changes: 7 additions & 7 deletions zfs_autobackup/ZfsDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -1122,23 +1122,23 @@ 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.
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)
Expand Down

0 comments on commit 30c81b4

Please sign in to comment.