Skip to content

Commit

Permalink
add test for --include-dataset and --exclude-dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
whoschek committed Jul 26, 2024
1 parent 354caf5 commit 772bfb1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/test_wbackup_zfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,36 @@ def test_basic_replication_recursive1(self):
encryption_prop = dataset_property(dst_root_dataset + "/foo/a", 'encryption')
self.assertEqual(encryption_prop, encryption_algo if self.is_encryption_mode() else 'off')

def test_basic_replication_recursive_with_exclude_dataset(self):
self.assertTrue(dataset_exists(dst_root_dataset))
self.assertFalse(dataset_exists(dst_root_dataset + '/foo'))
self.setup_basic()
boo = create_dataset(src_root_dataset, 'goo')
take_snapshot(boo, fix('g1'))
boo = create_dataset(src_root_dataset, 'boo')
take_snapshot(boo, fix('b1'))
zoo = create_dataset(src_root_dataset, 'zoo')
take_snapshot(zoo, fix('z1'))
for i in range(0, 3):
self.run_wbackup(src_root_dataset, dst_root_dataset, '--recursive',
'--include-dataset=',
'--exclude-dataset=/' + src_root_dataset + '/foo',
'--include-dataset=/' + src_root_dataset + '/foo',
'--exclude-dataset=/' + dst_root_dataset + '/goo/',
'--include-dataset=/' + dst_root_dataset + '/goo',
'--include-dataset=/xxxxxxxxx',
'--exclude-dataset=boo/',
'--include-dataset=boo',
dry_run=(i == 0))
self.assertFalse(dataset_exists(dst_root_dataset + '/foo'))
self.assertFalse(dataset_exists(dst_root_dataset + '/goo'))
self.assertFalse(dataset_exists(dst_root_dataset + '/boo'))
if i == 0:
self.assertSnapshots(dst_root_dataset, 0)
else:
self.assertSnapshots(dst_root_dataset, 3, 's')
self.assertSnapshots(dst_root_dataset + "/zoo", 1, 'z')

def test_complex_replication_flat_with_no_create_bookmark(self):
self.assertFalse(dataset_exists(dst_root_dataset + '/foo'))
self.setup_basic()
Expand Down
2 changes: 2 additions & 0 deletions wbackup_zfs/wbackup_zfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,8 @@ def dataset_regexes(self, datasets: List[str]) -> List[str]:
continue # ignore datasets that make no difference
if dataset.startswith('/'):
dataset = dataset[1:]
if dataset.endswith('/'):
dataset = dataset[0:-1]
if dataset:
regex = re.escape(dataset)
else:
Expand Down

0 comments on commit 772bfb1

Please sign in to comment.