broke more stuff :)

This commit is contained in:
Edwin Eefting 2024-10-14 17:25:15 +02:00
parent 25b71ba032
commit 30c81b4f8a
No known key found for this signature in database
GPG Key ID: 0F3C35D8E9887737
3 changed files with 18 additions and 10 deletions

View File

@ -545,6 +545,7 @@ test_target1/test_source2/fs2/sub@test-20101111000000 canmount - -
# 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(

View File

@ -343,7 +343,10 @@ test_target1/test_source2/fs2/sub@test-20101111000002
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 @@ test_target1/test_source2/fs2/sub@test-20101111000000
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 --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, """

View File

@ -653,7 +653,7 @@ class ZfsDataset:
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 @@ class ZfsDataset:
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 @@ class ZfsDataset:
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 @@ class ZfsDataset:
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)