forked from third-party-mirrors/zfs_autobackup
more --test test
This commit is contained in:
parent
d08f7bf3c1
commit
cba6470500
@ -547,7 +547,7 @@ class ZfsDataset():
|
|||||||
|
|
||||||
def __init__(self, zfs_node, name, force_exists=None):
|
def __init__(self, zfs_node, name, force_exists=None):
|
||||||
"""name: full path of the zfs dataset
|
"""name: full path of the zfs dataset
|
||||||
exists: specify if you already know a dataset exists or not. for performance reasons. (otherwise it will have to check with zfs list when needed)
|
exists: specify if you already know a dataset exists or not. for performance and testing reasons. (otherwise it will have to check with zfs list when needed)
|
||||||
"""
|
"""
|
||||||
self.zfs_node=zfs_node
|
self.zfs_node=zfs_node
|
||||||
self.name=name #full name
|
self.name=name #full name
|
||||||
|
@ -16,7 +16,7 @@ if ! [ -e /root/.ssh/id_rsa ]; then
|
|||||||
ssh -oStrictHostKeyChecking=no localhost true || exit 1
|
ssh -oStrictHostKeyChecking=no localhost true || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
coverage run --source bin.zfs_autobackup -m unittest discover -v
|
coverage run --source bin.zfs_autobackup -m unittest discover -vv
|
||||||
EXIT=$?
|
EXIT=$?
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
@ -36,10 +36,25 @@ class TestZfsNode(unittest2.TestCase):
|
|||||||
with patch('time.strftime', return_value="20101111000000"):
|
with patch('time.strftime', return_value="20101111000000"):
|
||||||
self.generate_resume()
|
self.generate_resume()
|
||||||
|
|
||||||
|
#--test should resume and succeed
|
||||||
|
with OutputIO() as buf:
|
||||||
|
with redirect_stdout(buf):
|
||||||
|
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --test".split(" ")).run())
|
||||||
|
|
||||||
|
print(buf.getvalue())
|
||||||
|
|
||||||
|
#did we really resume?
|
||||||
|
if "0.6.5" in ZFS_USERSPACE:
|
||||||
|
#abort this late, for beter coverage
|
||||||
|
self.skipTest("Resume not supported in this ZFS userspace version")
|
||||||
|
else:
|
||||||
|
self.assertIn(": resuming", buf.getvalue())
|
||||||
|
|
||||||
|
|
||||||
#should resume and succeed
|
#should resume and succeed
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --debug".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --verbose".split(" ")).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
|
|
||||||
@ -76,10 +91,24 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
with patch('time.strftime', return_value="20101111000001"):
|
with patch('time.strftime', return_value="20101111000001"):
|
||||||
self.generate_resume()
|
self.generate_resume()
|
||||||
|
|
||||||
|
#--test should resume and succeed
|
||||||
|
with OutputIO() as buf:
|
||||||
|
with redirect_stdout(buf):
|
||||||
|
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --test".split(" ")).run())
|
||||||
|
|
||||||
|
print(buf.getvalue())
|
||||||
|
|
||||||
|
#did we really resume?
|
||||||
|
if "0.6.5" in ZFS_USERSPACE:
|
||||||
|
#abort this late, for beter coverage
|
||||||
|
self.skipTest("Resume not supported in this ZFS userspace version")
|
||||||
|
else:
|
||||||
|
self.assertIn(": resuming", buf.getvalue())
|
||||||
|
|
||||||
#should resume and succeed
|
#should resume and succeed
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --debug".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --verbose".split(" ")).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
|
|
||||||
@ -107,7 +136,7 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
|
|
||||||
|
|
||||||
# # generate an invalid resume token, and verify if its aborted automaticly
|
# # generate an invalid resume token, and verify if its aborted automaticly
|
||||||
#FIXME: fails due to incorrectly created parent
|
# # FIXME: fails due to incorrectly created parent
|
||||||
# def test_resumeabort(self):
|
# def test_resumeabort(self):
|
||||||
|
|
||||||
# if "0.6.5" in ZFS_USERSPACE:
|
# if "0.6.5" in ZFS_USERSPACE:
|
||||||
@ -117,6 +146,8 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
# with patch('time.strftime', return_value="20101111000000"):
|
# with patch('time.strftime', return_value="20101111000000"):
|
||||||
# self.generate_resume()
|
# self.generate_resume()
|
||||||
|
|
||||||
|
# asdf
|
||||||
|
|
||||||
# #remove corresponding source snapshot
|
# #remove corresponding source snapshot
|
||||||
# shelltest("zfs destroy test_source1/fs1@test-20101111000000")
|
# shelltest("zfs destroy test_source1/fs1@test-20101111000000")
|
||||||
|
|
||||||
|
@ -456,10 +456,18 @@ test_target1/test_source2/fs2/sub@test-20101111000000 canmount - -
|
|||||||
r=shelltest("touch /test_target1/test_source1/fs1/change.txt")
|
r=shelltest("touch /test_target1/test_source1/fs1/change.txt")
|
||||||
r=shelltest("zfs snapshot test_target1/test_source1/fs1@incompatible1")
|
r=shelltest("zfs snapshot test_target1/test_source1/fs1@incompatible1")
|
||||||
|
|
||||||
|
|
||||||
|
with patch('time.strftime', return_value="20101111000002"):
|
||||||
|
#--test should fail, now incompatible
|
||||||
|
self.assertTrue(ZfsAutobackup("test test_target1 --verbose --allow-empty --test".split(" ")).run())
|
||||||
|
|
||||||
with patch('time.strftime', return_value="20101111000002"):
|
with patch('time.strftime', return_value="20101111000002"):
|
||||||
#should fail, now incompatible
|
#should fail, now incompatible
|
||||||
self.assertTrue(ZfsAutobackup("test test_target1 --verbose --allow-empty".split(" ")).run())
|
self.assertTrue(ZfsAutobackup("test test_target1 --verbose --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
|
with patch('time.strftime', return_value="20101111000003"):
|
||||||
|
#--test should succeed by destroying incompatibles
|
||||||
|
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --allow-empty --destroy-incompatible --test".split(" ")).run())
|
||||||
|
|
||||||
with patch('time.strftime', return_value="20101111000003"):
|
with patch('time.strftime', return_value="20101111000003"):
|
||||||
#should succeed by destroying incompatibles
|
#should succeed by destroying incompatibles
|
||||||
@ -646,6 +654,7 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
|
|
||||||
def test_test(self):
|
def test_test(self):
|
||||||
|
|
||||||
|
#initial
|
||||||
with patch('time.strftime', return_value="20101111000000"):
|
with patch('time.strftime', return_value="20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --test".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --test".split(" ")).run())
|
||||||
|
|
||||||
@ -662,6 +671,40 @@ test_source2/fs3/sub
|
|||||||
test_target1
|
test_target1
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
#actual make initial backup
|
||||||
|
with patch('time.strftime', return_value="20101111000001"):
|
||||||
|
self.assertFalse(ZfsAutobackup("test test_target1 --verbose".split(" ")).run())
|
||||||
|
|
||||||
|
|
||||||
|
#test incremental
|
||||||
|
with patch('time.strftime', return_value="20101111000000"):
|
||||||
|
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --test".split(" ")).run())
|
||||||
|
|
||||||
|
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
||||||
|
self.assertMultiLineEqual(r,"""
|
||||||
|
test_source1
|
||||||
|
test_source1/fs1
|
||||||
|
test_source1/fs1@test-20101111000001
|
||||||
|
test_source1/fs1/sub
|
||||||
|
test_source1/fs1/sub@test-20101111000001
|
||||||
|
test_source2
|
||||||
|
test_source2/fs2
|
||||||
|
test_source2/fs2/sub
|
||||||
|
test_source2/fs2/sub@test-20101111000001
|
||||||
|
test_source2/fs3
|
||||||
|
test_source2/fs3/sub
|
||||||
|
test_target1
|
||||||
|
test_target1/test_source1
|
||||||
|
test_target1/test_source1/fs1
|
||||||
|
test_target1/test_source1/fs1@test-20101111000001
|
||||||
|
test_target1/test_source1/fs1/sub
|
||||||
|
test_target1/test_source1/fs1/sub@test-20101111000001
|
||||||
|
test_target1/test_source2
|
||||||
|
test_target1/test_source2/fs2
|
||||||
|
test_target1/test_source2/fs2/sub
|
||||||
|
test_target1/test_source2/fs2/sub@test-20101111000001
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# TODO:
|
# TODO:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user