more tests

This commit is contained in:
Edwin Eefting
2020-07-09 13:15:45 +02:00
parent cba6470500
commit 8699ec5c69
2 changed files with 79 additions and 17 deletions

View File

@ -9,6 +9,7 @@ class TestZfsNode(unittest2.TestCase):
self.longMessage=True self.longMessage=True
# generate a resumable state # generate a resumable state
#NOTE: this generates two resumable test_target1/test_source1/fs1 and test_target1/test_source1/fs1/sub
def generate_resume(self): def generate_resume(self):
r=shelltest("zfs set compress=off test_source1 test_target1") r=shelltest("zfs set compress=off test_source1 test_target1")
@ -135,22 +136,86 @@ 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 def test_initial_resumeabort(self):
# def test_resumeabort(self):
# if "0.6.5" in ZFS_USERSPACE: if "0.6.5" in ZFS_USERSPACE:
# self.skipTest("Resume not supported in this ZFS userspace version") self.skipTest("Resume not supported in this ZFS userspace version")
# #inital backup, leaves resume token #inital backup, leaves resume token
# 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, so it becomes invalid
shelltest("zfs destroy test_source1/fs1@test-20101111000000")
# #remove corresponding source snapshot #NOTE: it can only abort the initial dataset if it has no subs, so abort that one as well:
# shelltest("zfs destroy test_source1/fs1@test-20101111000000") shelltest("zfs recv -A test_target1/test_source1/fs1/sub")
# #try again, should abort old resume #--test try again, should abort old resume
# with patch('time.strftime', return_value="20101111000001"): with patch('time.strftime', return_value="20101111000001"):
# self.assertFalse(ZfsAutobackup("test test_target1 --verbose --debug".split(" ")).run()) self.assertFalse(ZfsAutobackup("test test_target1 --verbose --test".split(" ")).run())
#try again, should abort old resume
with patch('time.strftime', return_value="20101111000001"):
self.assertFalse(ZfsAutobackup("test test_target1 --verbose".split(" ")).run())
r=shelltest("zfs list -H -o name -r -t all test_target1")
self.assertMultiLineEqual(r,"""
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-20101111000000
test_target1/test_source2
test_target1/test_source2/fs2
test_target1/test_source2/fs2/sub
test_target1/test_source2/fs2/sub@test-20101111000000
""")
# generate an invalid resume token, and verify if its aborted automaticly
def test_incremental_resumeabort(self):
if "0.6.5" in ZFS_USERSPACE:
self.skipTest("Resume not supported in this ZFS userspace version")
#initial backup
with patch('time.strftime', return_value="20101111000000"):
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --allow-empty".split(" ")).run())
#icremental backup, leaves resume token
with patch('time.strftime', return_value="20101111000001"):
self.generate_resume()
#remove corresponding source snapshot, so it becomes invalid
shelltest("zfs destroy test_source1/fs1@test-20101111000001")
#--test try again, should abort old resume
with patch('time.strftime', return_value="20101111000002"):
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --test".split(" ")).run())
#try again, should abort old resume
with patch('time.strftime', return_value="20101111000002"):
self.assertFalse(ZfsAutobackup("test test_target1 --verbose".split(" ")).run())
r=shelltest("zfs list -H -o name -r -t all test_target1")
self.assertMultiLineEqual(r,"""
test_target1
test_target1/test_source1
test_target1/test_source1/fs1
test_target1/test_source1/fs1@test-20101111000000
test_target1/test_source1/fs1@test-20101111000002
test_target1/test_source1/fs1/sub
test_target1/test_source1/fs1/sub@test-20101111000000
test_target1/test_source2
test_target1/test_source2/fs2
test_target1/test_source2/fs2/sub
test_target1/test_source2/fs2/sub@test-20101111000000
""")
############# TODO:
def test_ignoretransfererrors(self):
self.skipTest("todo: create some kind of situation where zfs recv exits with an error but transfer is still ok (happens in practice with acltype)")

View File

@ -713,6 +713,3 @@ test_target1/test_source2/fs2/sub@test-20101111000001
self.skipTest("todo: later when travis supports zfs 0.8") self.skipTest("todo: later when travis supports zfs 0.8")
def test_ignoretransfererrors(self):
self.skipTest("todo: create some kind of situation where zfs recv exits with an error but transfer is still ok (happens in practice with acltype)")