mirror of
https://github.com/psy0rz/zfs_autobackup.git
synced 2025-06-01 01:20:58 +03:00
more testing
This commit is contained in:
parent
b22113aad4
commit
bc17825582
@ -9,6 +9,15 @@ from pprint import *
|
|||||||
from bin.zfs_autobackup import *
|
from bin.zfs_autobackup import *
|
||||||
|
|
||||||
|
|
||||||
|
def shelltest(cmd):
|
||||||
|
"""execute and print result as nice copypastable string for unit tests (adds extra newlines on top/bottom)"""
|
||||||
|
ret=(subprocess.check_output(cmd , shell=True).decode('utf-8'))
|
||||||
|
print("######### result of: {}".format(cmd))
|
||||||
|
print(ret,end='')
|
||||||
|
print("#########")
|
||||||
|
ret='\n'+ret
|
||||||
|
return(ret)
|
||||||
|
|
||||||
def prepare_zpools():
|
def prepare_zpools():
|
||||||
print("Preparing zfs filesystems...")
|
print("Preparing zfs filesystems...")
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
coverage run --source bin.zfs_autobackup -m unittest -v $@; coverage report
|
coverage run --source bin.zfs_autobackup -m unittest -v $@
|
||||||
|
|
||||||
|
echo
|
||||||
|
coverage report
|
||||||
|
|
||||||
|
@ -13,13 +13,63 @@ class TestZfsNode(unittest.TestCase):
|
|||||||
description="[Source]"
|
description="[Source]"
|
||||||
node=ZfsNode("test", logger, description=description)
|
node=ZfsNode("test", logger, description=description)
|
||||||
|
|
||||||
with self.subTest("### no changes, no snapshot"):
|
with self.subTest("first snapshot"):
|
||||||
node.consistent_snapshot(node.selected_datasets, "snap1", 100000)
|
node.consistent_snapshot(node.selected_datasets, "test-1",100000)
|
||||||
s=pformat(subprocess.check_call("zfs list -r -t all" , shell=True))
|
r=shelltest("zfs list -H -o name -r -t all")
|
||||||
print(s)
|
self.assertEqual(r,"""
|
||||||
|
test_source1
|
||||||
|
test_source1/fs1
|
||||||
|
test_source1/fs1@test-1
|
||||||
|
test_source1/fs1/sub
|
||||||
|
test_source1/fs1/sub@test-1
|
||||||
|
test_source2
|
||||||
|
test_source2/fs2
|
||||||
|
test_source2/fs2/sub
|
||||||
|
test_source2/fs2/sub@test-1
|
||||||
|
test_source2/fs3
|
||||||
|
test_source2/fs3/sub
|
||||||
|
test_target1
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
with self.subTest("second snapshot, no changes, no snapshot"):
|
||||||
|
node.consistent_snapshot(node.selected_datasets, "test-2",100000)
|
||||||
|
r=shelltest("zfs list -H -o name -r -t all")
|
||||||
|
self.assertEqual(r,"""
|
||||||
|
test_source1
|
||||||
|
test_source1/fs1
|
||||||
|
test_source1/fs1@test-1
|
||||||
|
test_source1/fs1/sub
|
||||||
|
test_source1/fs1/sub@test-1
|
||||||
|
test_source2
|
||||||
|
test_source2/fs2
|
||||||
|
test_source2/fs2/sub
|
||||||
|
test_source2/fs2/sub@test-1
|
||||||
|
test_source2/fs3
|
||||||
|
test_source2/fs3/sub
|
||||||
|
test_target1
|
||||||
|
""")
|
||||||
|
|
||||||
|
with self.subTest("second snapshot, no changes, empty snapshot"):
|
||||||
|
node.consistent_snapshot(node.selected_datasets, "test-2",0)
|
||||||
|
r=shelltest("zfs list -H -o name -r -t all")
|
||||||
|
self.assertEqual(r,"""
|
||||||
|
test_source1
|
||||||
|
test_source1/fs1
|
||||||
|
test_source1/fs1@test-1
|
||||||
|
test_source1/fs1@test-2
|
||||||
|
test_source1/fs1/sub
|
||||||
|
test_source1/fs1/sub@test-1
|
||||||
|
test_source1/fs1/sub@test-2
|
||||||
|
test_source2
|
||||||
|
test_source2/fs2
|
||||||
|
test_source2/fs2/sub
|
||||||
|
test_source2/fs2/sub@test-1
|
||||||
|
test_source2/fs2/sub@test-2
|
||||||
|
test_source2/fs3
|
||||||
|
test_source2/fs3/sub
|
||||||
|
test_target1
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_getselected(self):
|
def test_getselected(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user