mirror of
https://github.com/psy0rz/zfs_autobackup.git
synced 2025-06-13 02:12:07 +03:00
dont list bookmarks in existing tests
This commit is contained in:
parent
d79d6af548
commit
cf541c581c
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
from basetest import *
|
from basetest import *
|
||||||
|
|
||||||
|
|
||||||
@ -8,35 +7,34 @@ class TestZfsNode(unittest2.TestCase):
|
|||||||
prepare_zpools()
|
prepare_zpools()
|
||||||
self.longMessage = True
|
self.longMessage = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_destroymissing(self):
|
def test_destroymissing(self):
|
||||||
|
|
||||||
# initial backup
|
# initial backup
|
||||||
with mocktime("19101111000000"): # 1000 years in past
|
with mocktime("19101111000000"): # 1000 years in past
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-holds".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-holds".split(" ")).run())
|
||||||
|
|
||||||
with mocktime("20101111000000"): # far in past
|
with mocktime("20101111000000"): # far in past
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-holds --allow-empty".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1 --no-progress --verbose --no-holds --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
with self.subTest("Should do nothing yet"):
|
with self.subTest("Should do nothing yet"):
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 0s".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 0s".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
self.assertNotIn(": Destroy missing", buf.getvalue())
|
self.assertNotIn(": Destroy missing", buf.getvalue())
|
||||||
|
|
||||||
|
|
||||||
with self.subTest("missing dataset of us that still has children"):
|
with self.subTest("missing dataset of us that still has children"):
|
||||||
|
|
||||||
# just deselect it so it counts as 'missing'
|
# just deselect it so it counts as 'missing'
|
||||||
shelltest("zfs set autobackup:test=child test_source1/fs1")
|
shelltest("zfs set autobackup:test=child test_source1/fs1")
|
||||||
|
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf), redirect_stderr(buf):
|
with redirect_stdout(buf), redirect_stderr(buf):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 0s".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 0s".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
# should have done the snapshot cleanup for destoy missing:
|
# should have done the snapshot cleanup for destoy missing:
|
||||||
@ -46,7 +44,6 @@ class TestZfsNode(unittest2.TestCase):
|
|||||||
|
|
||||||
shelltest("zfs inherit autobackup:test test_source1/fs1")
|
shelltest("zfs inherit autobackup:test test_source1/fs1")
|
||||||
|
|
||||||
|
|
||||||
with self.subTest("Normal destroyed leaf"):
|
with self.subTest("Normal destroyed leaf"):
|
||||||
shelltest("zfs destroy -r test_source1/fs1/sub")
|
shelltest("zfs destroy -r test_source1/fs1/sub")
|
||||||
|
|
||||||
@ -54,7 +51,9 @@ class TestZfsNode(unittest2.TestCase):
|
|||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
# 100y: lastest should not be old enough, while second to latest snapshot IS old enough:
|
# 100y: lastest should not be old enough, while second to latest snapshot IS old enough:
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 100y".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 100y".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
self.assertIn(": Waiting for deadline", buf.getvalue())
|
self.assertIn(": Waiting for deadline", buf.getvalue())
|
||||||
@ -62,20 +61,22 @@ class TestZfsNode(unittest2.TestCase):
|
|||||||
# past deadline, destroy
|
# past deadline, destroy
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 1y".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 1y".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
self.assertIn("sub: Destroying", buf.getvalue())
|
self.assertIn("sub: Destroying", buf.getvalue())
|
||||||
|
|
||||||
|
|
||||||
with self.subTest("Leaf with other snapshot still using it"):
|
with self.subTest("Leaf with other snapshot still using it"):
|
||||||
shelltest("zfs destroy -r test_source1/fs1")
|
shelltest("zfs destroy -r test_source1/fs1")
|
||||||
shelltest("zfs snapshot -r test_target1/test_source1/fs1@other1")
|
shelltest("zfs snapshot -r test_target1/test_source1/fs1@other1")
|
||||||
|
|
||||||
|
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 0s".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 0s".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
|
|
||||||
@ -84,13 +85,14 @@ class TestZfsNode(unittest2.TestCase):
|
|||||||
|
|
||||||
shelltest("zfs destroy test_target1/test_source1/fs1@other1")
|
shelltest("zfs destroy test_target1/test_source1/fs1@other1")
|
||||||
|
|
||||||
|
|
||||||
with self.subTest("In use by clone"):
|
with self.subTest("In use by clone"):
|
||||||
shelltest("zfs clone test_target1/test_source1/fs1@test-20101111000000 test_target1/clone1")
|
shelltest("zfs clone test_target1/test_source1/fs1@test-20101111000000 test_target1/clone1")
|
||||||
|
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf), redirect_stderr(buf):
|
with redirect_stdout(buf), redirect_stderr(buf):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 0s".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 0s".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
# now tries to destroy our own last snapshot (before the final destroy of the dataset)
|
# now tries to destroy our own last snapshot (before the final destroy of the dataset)
|
||||||
@ -100,12 +102,12 @@ class TestZfsNode(unittest2.TestCase):
|
|||||||
|
|
||||||
shelltest("zfs destroy test_target1/clone1")
|
shelltest("zfs destroy test_target1/clone1")
|
||||||
|
|
||||||
|
|
||||||
with self.subTest("Should leave test_source1 parent"):
|
with self.subTest("Should leave test_source1 parent"):
|
||||||
|
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf), redirect_stderr(buf):
|
with redirect_stdout(buf), redirect_stderr(buf):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 0s".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 0s".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
# should have done the snapshot cleanup for destoy missing:
|
# should have done the snapshot cleanup for destoy missing:
|
||||||
@ -113,17 +115,16 @@ class TestZfsNode(unittest2.TestCase):
|
|||||||
|
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf), redirect_stderr(buf):
|
with redirect_stdout(buf), redirect_stderr(buf):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 0s".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --no-snapshot --destroy-missing 0s".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
# on second run it sees the dangling ex-parent but doesnt know what to do with it (since it has no own snapshot)
|
# on second run it sees the dangling ex-parent but doesnt know what to do with it (since it has no own snapshot)
|
||||||
self.assertIn("test_source1: Destroy missing: has no snapshots made by us", buf.getvalue())
|
self.assertIn("test_source1: Destroy missing: has no snapshots made by us", buf.getvalue())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# end result
|
# end result
|
||||||
r=shelltest("zfs list -H -o name -r -t all test_target1")
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_target1
|
test_target1
|
||||||
test_target1/test_source1
|
test_target1/test_source1
|
||||||
|
@ -301,7 +301,7 @@ test_target1/test_source2/fs2/sub encryptionroot -
|
|||||||
|
|
||||||
# NOTE: On some versions this leaves 2 weird sub-datasets that should'nt be there (its probably a zfs bug?)
|
# NOTE: On some versions this leaves 2 weird sub-datasets that should'nt be there (its probably a zfs bug?)
|
||||||
# so we ignore this, and just make sure the backup resumes correctly after reloading the key.
|
# so we ignore this, and just make sure the backup resumes correctly after reloading the key.
|
||||||
# r = shelltest("zfs get -r -t all encryptionroot test_target1")
|
# r = shelltest("zfs get -r -t snapshot,filesystem encryptionroot test_target1")
|
||||||
# self.assertEqual(r, """
|
# self.assertEqual(r, """
|
||||||
# NAME PROPERTY VALUE SOURCE
|
# NAME PROPERTY VALUE SOURCE
|
||||||
# test_target1 encryptionroot - -
|
# test_target1 encryptionroot - -
|
||||||
|
@ -51,7 +51,7 @@ class TestExternalFailures(unittest2.TestCase):
|
|||||||
|
|
||||||
self.assertIn(": resuming", buf.getvalue())
|
self.assertIn(": resuming", buf.getvalue())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all test_target1")
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_target1
|
test_target1
|
||||||
test_target1/test_source1
|
test_target1/test_source1
|
||||||
@ -94,7 +94,7 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
# did we really resume?
|
# did we really resume?
|
||||||
self.assertIn(": resuming", buf.getvalue())
|
self.assertIn(": resuming", buf.getvalue())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all test_target1")
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_target1
|
test_target1
|
||||||
test_target1/test_source1
|
test_target1/test_source1
|
||||||
@ -129,7 +129,7 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
with mocktime("20101111000001"):
|
with mocktime("20101111000001"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all test_target1")
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_target1
|
test_target1
|
||||||
test_target1/test_source1
|
test_target1/test_source1
|
||||||
@ -164,7 +164,7 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
with mocktime("20101111000002"):
|
with mocktime("20101111000002"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all test_target1")
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_target1
|
test_target1
|
||||||
test_target1/test_source1
|
test_target1/test_source1
|
||||||
@ -200,7 +200,7 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
|
|
||||||
self.assertIn("Aborting resume", buf.getvalue())
|
self.assertIn("Aborting resume", buf.getvalue())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all test_target1")
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_target1
|
test_target1
|
||||||
test_target1/test_source1
|
test_target1/test_source1
|
||||||
@ -259,7 +259,7 @@ test_target1/test_source2/fs2/sub@test-20101111000002
|
|||||||
# with mocktime("20101111000000"):
|
# with mocktime("20101111000000"):
|
||||||
# self.assertFalse(ZfsAutobackup("test test_target1 --verbose --allow-empty --no-progress".split(" ")).run())
|
# self.assertFalse(ZfsAutobackup("test test_target1 --verbose --allow-empty --no-progress".split(" ")).run())
|
||||||
#
|
#
|
||||||
# r = shelltest("zfs list -H -o name -r -t all test_target1")
|
# r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_target1")
|
||||||
#
|
#
|
||||||
# self.assertMultiLineEqual(r, """
|
# self.assertMultiLineEqual(r, """
|
||||||
# test_target1
|
# test_target1
|
||||||
|
@ -25,7 +25,7 @@ class TestZfsNode(unittest2.TestCase):
|
|||||||
"test test_target1 --no-progress --verbose --keep-source=0 --keep-target=10 --allow-empty".split(
|
"test test_target1 --no-progress --verbose --keep-source=0 --keep-target=10 --allow-empty".split(
|
||||||
" ")).run())
|
" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t bookmark,filesystem " + TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
|
@ -16,7 +16,8 @@ class TestSendRecvPipes(unittest2.TestCase):
|
|||||||
with self.subTest("local local pipe"):
|
with self.subTest("local local pipe"):
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup(
|
self.assertFalse(ZfsAutobackup(
|
||||||
["test", "test_target1", "--allow-empty", "--exclude-received", "--no-holds", "--no-progress", "--clear-mountpoint",
|
["test", "test_target1", "--allow-empty", "--exclude-received", "--no-holds", "--no-progress",
|
||||||
|
"--clear-mountpoint",
|
||||||
"--send-pipe=dd bs=1M", "--recv-pipe=dd bs=2M"]).run())
|
"--send-pipe=dd bs=1M", "--recv-pipe=dd bs=2M"]).run())
|
||||||
|
|
||||||
shelltest("zfs destroy -r test_target1/test_source1/fs1/sub")
|
shelltest("zfs destroy -r test_target1/test_source1/fs1/sub")
|
||||||
@ -44,7 +45,7 @@ class TestSendRecvPipes(unittest2.TestCase):
|
|||||||
"--ssh-source=localhost", "--ssh-target=localhost", "--send-pipe=dd bs=1M",
|
"--ssh-source=localhost", "--ssh-target=localhost", "--send-pipe=dd bs=1M",
|
||||||
"--recv-pipe=dd bs=2M"]).run())
|
"--recv-pipe=dd bs=2M"]).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all test_target1")
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_target1
|
test_target1
|
||||||
test_target1/test_source1
|
test_target1/test_source1
|
||||||
@ -85,7 +86,8 @@ test_target1/test_source2/fs2/sub@test-20101111000003
|
|||||||
with self.subTest("local local pipe"):
|
with self.subTest("local local pipe"):
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup(
|
self.assertFalse(ZfsAutobackup(
|
||||||
["test", "test_target1", "--allow-empty", "--exclude-received", "--no-holds", "--no-progress", "--clear-mountpoint", "--buffer=1M"]).run())
|
["test", "test_target1", "--allow-empty", "--exclude-received", "--no-holds", "--no-progress",
|
||||||
|
"--clear-mountpoint", "--buffer=1M"]).run())
|
||||||
|
|
||||||
shelltest("zfs destroy -r test_target1/test_source1/fs1/sub")
|
shelltest("zfs destroy -r test_target1/test_source1/fs1/sub")
|
||||||
|
|
||||||
@ -111,7 +113,7 @@ test_target1/test_source2/fs2/sub@test-20101111000003
|
|||||||
["test", "test_target1", "--allow-empty", "--exclude-received", "--no-holds", "--no-progress",
|
["test", "test_target1", "--allow-empty", "--exclude-received", "--no-holds", "--no-progress",
|
||||||
"--ssh-source=localhost", "--ssh-target=localhost", "--buffer=1M"]).run())
|
"--ssh-source=localhost", "--ssh-target=localhost", "--buffer=1M"]).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all test_target1")
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_target1
|
test_target1
|
||||||
test_target1/test_source1
|
test_target1/test_source1
|
||||||
|
@ -18,7 +18,9 @@ class TestZfsAutobackup(unittest2.TestCase):
|
|||||||
|
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
self.assertEqual(ZfsAutobackup("test test_target1 --no-progress --resume --verbose --no-snapshot".split(" ")).run(), 0)
|
self.assertEqual(
|
||||||
|
ZfsAutobackup("test test_target1 --no-progress --resume --verbose --no-snapshot".split(" ")).run(),
|
||||||
|
0)
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
self.assertIn("The --resume", buf.getvalue())
|
self.assertIn("The --resume", buf.getvalue())
|
||||||
@ -31,14 +33,13 @@ class TestZfsAutobackup(unittest2.TestCase):
|
|||||||
# correct message?
|
# correct message?
|
||||||
self.assertIn("Please create this dataset", buf.getvalue())
|
self.assertIn("Please create this dataset", buf.getvalue())
|
||||||
|
|
||||||
|
|
||||||
def test_snapshotmode(self):
|
def test_snapshotmode(self):
|
||||||
"""test snapshot tool mode"""
|
"""test snapshot tool mode"""
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test --no-progress --verbose".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test --no-progress --verbose".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -61,19 +62,18 @@ test_target1
|
|||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stderr(buf):
|
with redirect_stderr(buf):
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertTrue(ZfsAutobackup("nonexisting test_target1 --verbose --debug --no-progress".split(" ")).run())
|
self.assertTrue(
|
||||||
|
ZfsAutobackup("nonexisting test_target1 --verbose --debug --no-progress".split(" ")).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
# correct message?
|
# correct message?
|
||||||
self.assertIn("No source filesystems selected", buf.getvalue())
|
self.assertIn("No source filesystems selected", buf.getvalue())
|
||||||
|
|
||||||
|
|
||||||
with self.subTest("defaults with full verbose and debug"):
|
with self.subTest("defaults with full verbose and debug"):
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --debug --no-progress".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --debug --no-progress".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -102,8 +102,7 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
with mocktime("20101111000001"):
|
with mocktime("20101111000001"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --allow-empty --no-progress".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --allow-empty --no-progress".split(" ")).run())
|
||||||
|
|
||||||
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -135,7 +134,6 @@ test_target1/test_source2/fs2/sub@test-20101111000001
|
|||||||
""")
|
""")
|
||||||
|
|
||||||
with self.subTest("verify holds"):
|
with self.subTest("verify holds"):
|
||||||
|
|
||||||
r = shelltest("zfs get -r userrefs test_source1 test_source2 test_target1")
|
r = shelltest("zfs get -r userrefs test_source1 test_source2 test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
NAME PROPERTY VALUE SOURCE
|
NAME PROPERTY VALUE SOURCE
|
||||||
@ -172,12 +170,15 @@ test_target1/test_source2/fs2/sub@test-20101111000001 userrefs 1 -
|
|||||||
# So in this case we only want to see 2 snapshots of 2011, and none of the 2010's anymore.
|
# So in this case we only want to see 2 snapshots of 2011, and none of the 2010's anymore.
|
||||||
with self.subTest("test time checking"):
|
with self.subTest("test time checking"):
|
||||||
with mocktime("20111211000000"):
|
with mocktime("20111211000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --allow-empty --verbose --no-progress".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1 --allow-empty --verbose --no-progress".split(" ")).run())
|
||||||
|
|
||||||
with mocktime("20111211000001"):
|
with mocktime("20111211000001"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --allow-empty --verbose --keep-source 1y1y --keep-target 1d1y --no-progress".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --allow-empty --verbose --keep-source 1y1y --keep-target 1d1y --no-progress".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -216,7 +217,7 @@ test_target1/test_source2/fs2/sub@test-20111211000001
|
|||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -249,9 +250,10 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
r = shelltest("zfs snapshot test_source1/fs1@otherdate-20001111000000")
|
r = shelltest("zfs snapshot test_source1/fs1@otherdate-20001111000000")
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --other-snapshots".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1 --no-progress --verbose --other-snapshots".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -280,13 +282,12 @@ test_target1/test_source2/fs2/sub
|
|||||||
test_target1/test_source2/fs2/sub@test-20101111000000
|
test_target1/test_source2/fs2/sub@test-20101111000000
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_nosnapshot(self):
|
def test_nosnapshot(self):
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --no-snapshot --no-progress".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --no-snapshot --no-progress".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
# (only parents are created )
|
# (only parents are created )
|
||||||
# TODO: it probably shouldn't create these
|
# TODO: it probably shouldn't create these
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
@ -304,13 +305,12 @@ test_target1/test_source2
|
|||||||
test_target1/test_source2/fs2
|
test_target1/test_source2/fs2
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_nosend(self):
|
def test_nosend(self):
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --no-send --no-progress".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --no-send --no-progress".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -326,14 +326,14 @@ test_source2/fs3/sub
|
|||||||
test_target1
|
test_target1
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_ignorereplicated(self):
|
def test_ignorereplicated(self):
|
||||||
r = shelltest("zfs snapshot test_source1/fs1@otherreplication")
|
r = shelltest("zfs snapshot test_source1/fs1@otherreplication")
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --ignore-replicated".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1 --no-progress --verbose --ignore-replicated".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -388,13 +388,12 @@ test_target1/test_source2/fs2/sub userrefs - -
|
|||||||
test_target1/test_source2/fs2/sub@test-20101111000000 userrefs 0 -
|
test_target1/test_source2/fs2/sub@test-20101111000000 userrefs 0 -
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_strippath(self):
|
def test_strippath(self):
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --strip-path=1 --no-progress".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --verbose --strip-path=1 --no-progress".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -435,7 +434,8 @@ test_target1/fs2/sub@test-20101111000000
|
|||||||
r = shelltest("zfs set refreservation=1M test_source1/fs1")
|
r = shelltest("zfs set refreservation=1M test_source1/fs1")
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --clear-refreservation".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1 --no-progress --verbose --clear-refreservation".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs get -r refreservation test_source1 test_source2 test_target1")
|
r = shelltest("zfs get -r refreservation test_source1 test_source2 test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
@ -463,7 +463,6 @@ test_target1/test_source2/fs2/sub refreservation none
|
|||||||
test_target1/test_source2/fs2/sub@test-20101111000000 refreservation - -
|
test_target1/test_source2/fs2/sub@test-20101111000000 refreservation - -
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_clearmount(self):
|
def test_clearmount(self):
|
||||||
|
|
||||||
# on zfs utils 0.6.x -o isnt supported
|
# on zfs utils 0.6.x -o isnt supported
|
||||||
@ -471,9 +470,9 @@ test_target1/test_source2/fs2/sub@test-20101111000000 refreservation -
|
|||||||
if r == "\n2\n":
|
if r == "\n2\n":
|
||||||
self.skipTest("This zfs-userspace version doesnt support -o")
|
self.skipTest("This zfs-userspace version doesnt support -o")
|
||||||
|
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --clear-mountpoint --debug".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1 --no-progress --verbose --clear-mountpoint --debug".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs get -r canmount test_source1 test_source2 test_target1")
|
r = shelltest("zfs get -r canmount test_source1 test_source2 test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
@ -501,7 +500,6 @@ test_target1/test_source2/fs2/sub canmount noauto local
|
|||||||
test_target1/test_source2/fs2/sub@test-20101111000000 canmount - -
|
test_target1/test_source2/fs2/sub@test-20101111000000 canmount - -
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_rollback(self):
|
def test_rollback(self):
|
||||||
|
|
||||||
# initial backup
|
# initial backup
|
||||||
@ -517,8 +515,8 @@ test_target1/test_source2/fs2/sub@test-20101111000000 canmount - -
|
|||||||
|
|
||||||
with mocktime("20101111000002"):
|
with mocktime("20101111000002"):
|
||||||
# rollback, should succeed
|
# rollback, should succeed
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --rollback".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --rollback".split(" ")).run())
|
||||||
|
|
||||||
def test_destroyincompat(self):
|
def test_destroyincompat(self):
|
||||||
|
|
||||||
@ -538,10 +536,10 @@ 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 mocktime("20101111000002"):
|
with mocktime("20101111000002"):
|
||||||
# --test should fail, now incompatible
|
# --test should fail, now incompatible
|
||||||
self.assertTrue(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --test".split(" ")).run())
|
self.assertTrue(
|
||||||
|
ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --test".split(" ")).run())
|
||||||
|
|
||||||
with mocktime("20101111000002"):
|
with mocktime("20101111000002"):
|
||||||
# should fail, now incompatible
|
# should fail, now incompatible
|
||||||
@ -549,13 +547,16 @@ test_target1/test_source2/fs2/sub@test-20101111000000 canmount - -
|
|||||||
|
|
||||||
with mocktime("20101111000003"):
|
with mocktime("20101111000003"):
|
||||||
# --test should succeed by destroying incompatibles
|
# --test should succeed by destroying incompatibles
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --destroy-incompatible --test --debug".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --allow-empty --destroy-incompatible --test --debug".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
with mocktime("20101111000003"):
|
with mocktime("20101111000003"):
|
||||||
# should succeed by destroying incompatibles
|
# should succeed by destroying incompatibles
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --destroy-incompatible".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --allow-empty --destroy-incompatible".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all test_target1")
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_target1
|
test_target1
|
||||||
test_target1/test_source1
|
test_target1/test_source1
|
||||||
@ -580,26 +581,26 @@ test_target1/test_source2/fs2/sub@test-20101111000002
|
|||||||
test_target1/test_source2/fs2/sub@test-20101111000003
|
test_target1/test_source2/fs2/sub@test-20101111000003
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_ssh(self):
|
def test_ssh(self):
|
||||||
|
|
||||||
# test all ssh directions
|
# test all ssh directions
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --ssh-source localhost --exclude-received".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --allow-empty --ssh-source localhost --exclude-received".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
with mocktime("20101111000001"):
|
with mocktime("20101111000001"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --ssh-target localhost --exclude-received".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --allow-empty --ssh-target localhost --exclude-received".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
with mocktime("20101111000002"):
|
with mocktime("20101111000002"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --ssh-source localhost --ssh-target localhost".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --allow-empty --ssh-source localhost --ssh-target localhost".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -636,22 +637,22 @@ test_target1/test_source2/fs2/sub@test-20101111000001
|
|||||||
test_target1/test_source2/fs2/sub@test-20101111000002
|
test_target1/test_source2/fs2/sub@test-20101111000002
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_minchange(self):
|
def test_minchange(self):
|
||||||
|
|
||||||
# initial
|
# initial
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --min-change 100000".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1 --no-progress --verbose --min-change 100000".split(" ")).run())
|
||||||
|
|
||||||
# make small change, use umount to reflect the changes immediately
|
# make small change, use umount to reflect the changes immediately
|
||||||
r = shelltest("zfs set compress=off test_source1")
|
r = shelltest("zfs set compress=off test_source1")
|
||||||
r = shelltest("touch /test_source1/fs1/change.txt")
|
r = shelltest("touch /test_source1/fs1/change.txt")
|
||||||
r = shelltest("zfs umount test_source1/fs1; zfs mount test_source1/fs1")
|
r = shelltest("zfs umount test_source1/fs1; zfs mount test_source1/fs1")
|
||||||
|
|
||||||
|
|
||||||
# too small change, takes no snapshots
|
# too small change, takes no snapshots
|
||||||
with mocktime("20101111000001"):
|
with mocktime("20101111000001"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --min-change 100000".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1 --no-progress --verbose --min-change 100000".split(" ")).run())
|
||||||
|
|
||||||
# make big change
|
# make big change
|
||||||
r = shelltest("dd if=/dev/zero of=/test_source1/fs1/change.txt bs=200000 count=1")
|
r = shelltest("dd if=/dev/zero of=/test_source1/fs1/change.txt bs=200000 count=1")
|
||||||
@ -659,9 +660,10 @@ test_target1/test_source2/fs2/sub@test-20101111000002
|
|||||||
|
|
||||||
# bigger change, should take snapshot
|
# bigger change, should take snapshot
|
||||||
with mocktime("20101111000002"):
|
with mocktime("20101111000002"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --min-change 100000".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1 --no-progress --verbose --min-change 100000".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -694,7 +696,7 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --test".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --test".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -711,12 +713,12 @@ test_target1
|
|||||||
with mocktime("20101111000001"):
|
with mocktime("20101111000001"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose".split(" ")).run())
|
||||||
|
|
||||||
|
|
||||||
# test incremental
|
# test incremental
|
||||||
with mocktime("20101111000002"):
|
with mocktime("20101111000002"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --allow-empty --verbose --test".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1 --no-progress --allow-empty --verbose --test".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -741,7 +743,6 @@ test_target1/test_source2/fs2/sub
|
|||||||
test_target1/test_source2/fs2/sub@test-20101111000001
|
test_target1/test_source2/fs2/sub@test-20101111000001
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_migrate(self):
|
def test_migrate(self):
|
||||||
"""test migration from other snapshotting systems. zfs-autobackup should be able to continue from any common snapshot, not just its own."""
|
"""test migration from other snapshotting systems. zfs-autobackup should be able to continue from any common snapshot, not just its own."""
|
||||||
|
|
||||||
@ -752,7 +753,7 @@ test_target1/test_source2/fs2/sub@test-20101111000001
|
|||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -783,17 +784,20 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
"""test if keep-source=0 and keep-target=0 dont delete common snapshot and break backup"""
|
"""test if keep-source=0 and keep-target=0 dont delete common snapshot and break backup"""
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --keep-source=0 --keep-target=0".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --keep-source=0 --keep-target=0".split(" ")).run())
|
||||||
|
|
||||||
# make snapshot, shouldnt delete 0
|
# make snapshot, shouldnt delete 0
|
||||||
with mocktime("20101111000001"):
|
with mocktime("20101111000001"):
|
||||||
self.assertFalse(ZfsAutobackup("test --no-progress --verbose --keep-source=0 --keep-target=0 --allow-empty".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test --no-progress --verbose --keep-source=0 --keep-target=0 --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
# make snapshot 2, shouldnt delete 0 since it has holds, but will delete 1 since it has no holds
|
# make snapshot 2, shouldnt delete 0 since it has holds, but will delete 1 since it has no holds
|
||||||
with mocktime("20101111000002"):
|
with mocktime("20101111000002"):
|
||||||
self.assertFalse(ZfsAutobackup("test --no-progress --verbose --keep-source=0 --keep-target=0 --allow-empty".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test --no-progress --verbose --keep-source=0 --keep-target=0 --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all " + TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -823,9 +827,11 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
|
|
||||||
# make another backup but with no-holds. we should naturally endup with only number 3
|
# make another backup but with no-holds. we should naturally endup with only number 3
|
||||||
with mocktime("20101111000003"):
|
with mocktime("20101111000003"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --keep-source=0 --keep-target=0 --no-holds --allow-empty --debug".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --keep-source=0 --keep-target=0 --no-holds --allow-empty --debug".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all " + TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -850,12 +856,12 @@ test_target1/test_source2/fs2/sub
|
|||||||
test_target1/test_source2/fs2/sub@test-20101111000003
|
test_target1/test_source2/fs2/sub@test-20101111000003
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
# run with snapshot-only for 4, since we used no-holds, it will delete 3 on the source, breaking the backup
|
# run with snapshot-only for 4, since we used no-holds, it will delete 3 on the source, breaking the backup
|
||||||
with mocktime("20101111000004"):
|
with mocktime("20101111000004"):
|
||||||
self.assertFalse(ZfsAutobackup("test --no-progress --verbose --keep-source=0 --keep-target=0 --allow-empty".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test --no-progress --verbose --keep-source=0 --keep-target=0 --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all " + TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -880,7 +886,6 @@ test_target1/test_source2/fs2/sub
|
|||||||
test_target1/test_source2/fs2/sub@test-20101111000003
|
test_target1/test_source2/fs2/sub@test-20101111000003
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_progress(self):
|
def test_progress(self):
|
||||||
|
|
||||||
r = shelltest("dd if=/dev/urandom of=/test_source1/data.txt bs=5M count=1")
|
r = shelltest("dd if=/dev/urandom of=/test_source1/data.txt bs=5M count=1")
|
||||||
@ -890,10 +895,8 @@ test_target1/test_source2/fs2/sub@test-20101111000003
|
|||||||
n = ZfsNode(utc=False, snapshot_time_format="bla", hold_name="bla", logger=l)
|
n = ZfsNode(utc=False, snapshot_time_format="bla", hold_name="bla", logger=l)
|
||||||
d = ZfsDataset(n, "test_source1@test")
|
d = ZfsDataset(n, "test_source1@test")
|
||||||
|
|
||||||
sp=d.send_pipe([], prev_snapshot=None, resume_token=None, show_progress=True, raw=False, send_pipes=[], send_properties=True, write_embedded=True, zfs_compressed=True)
|
sp = d.send_pipe([], prev_snapshot=None, resume_token=None, show_progress=True, raw=False, send_pipes=[],
|
||||||
|
send_properties=True, write_embedded=True, zfs_compressed=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stderr(buf):
|
with redirect_stderr(buf):
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from basetest import *
|
from basetest import *
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
class TestZfsAutobackup31(unittest2.TestCase):
|
class TestZfsAutobackup31(unittest2.TestCase):
|
||||||
"""various new 3.1 features"""
|
"""various new 3.1 features"""
|
||||||
|
|
||||||
@ -9,14 +10,15 @@ class TestZfsAutobackup31(unittest2.TestCase):
|
|||||||
self.longMessage = True
|
self.longMessage = True
|
||||||
|
|
||||||
def test_no_thinning(self):
|
def test_no_thinning(self):
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
with mocktime("20101111000001"):
|
with mocktime("20101111000001"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --keep-target=0 --keep-source=0 --no-thinning".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --allow-empty --keep-target=0 --keep-source=0 --no-thinning".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -47,7 +49,6 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
test_target1/test_source2/fs2/sub@test-20101111000001
|
test_target1/test_source2/fs2/sub@test-20101111000001
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_re_replication(self):
|
def test_re_replication(self):
|
||||||
"""test re-replication of something thats already a backup (new in v3.1-beta5)"""
|
"""test re-replication of something thats already a backup (new in v3.1-beta5)"""
|
||||||
|
|
||||||
@ -55,13 +56,15 @@ test_target1/test_source2/fs2/sub@test-20101111000001
|
|||||||
shelltest("zfs create test_target1/b")
|
shelltest("zfs create test_target1/b")
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1/a --no-progress --verbose --debug --allow-empty".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1/a --no-progress --verbose --debug --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
# NOTE: since v3.4 this changed. autobackup: properties are filtered. So its up to the admin to reset this property on the other side:
|
# NOTE: since v3.4 this changed. autobackup: properties are filtered. So its up to the admin to reset this property on the other side:
|
||||||
shelltest("zfs set autobackup:test=true test_target1/a")
|
shelltest("zfs set autobackup:test=true test_target1/a")
|
||||||
|
|
||||||
with mocktime("20101111000001"):
|
with mocktime("20101111000001"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1/b --no-progress --verbose --allow-empty".split(" ")).run())
|
self.assertFalse(
|
||||||
|
ZfsAutobackup("test test_target1/b --no-progress --verbose --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t snapshot test_target1")
|
r = shelltest("zfs list -H -o name -r -t snapshot test_target1")
|
||||||
# NOTE: it wont backup test_target1/a/test_source2/fs2/sub to test_target1/b since it doesnt have the zfs_autobackup property anymore.
|
# NOTE: it wont backup test_target1/a/test_source2/fs2/sub to test_target1/b since it doesnt have the zfs_autobackup property anymore.
|
||||||
@ -95,7 +98,6 @@ test_target1/b/test_target1/a/test_source2/fs2/sub@test-20101111000001
|
|||||||
""", r)
|
""", r)
|
||||||
|
|
||||||
def test_zfs_compressed(self):
|
def test_zfs_compressed(self):
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
ZfsAutobackup("test test_target1 --no-progress --verbose --debug --zfs-compressed".split(" ")).run())
|
ZfsAutobackup("test test_target1 --no-progress --verbose --debug --zfs-compressed".split(" ")).run())
|
||||||
@ -107,7 +109,8 @@ test_target1/b/test_target1/a/test_source2/fs2/sub@test-20101111000001
|
|||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
ZfsAutobackup("test test_target1 --no-progress --verbose --debug --force --strip-path=1".split(" ")).run())
|
ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --debug --force --strip-path=1".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t snapshot test_target1")
|
r = shelltest("zfs list -H -o name -r -t snapshot test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
@ -117,9 +120,7 @@ test_target1/fs1/sub@test-20101111000000
|
|||||||
test_target1/fs2/sub@test-20101111000000
|
test_target1/fs2/sub@test-20101111000000
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_exclude_unchanged(self):
|
def test_exclude_unchanged(self):
|
||||||
|
|
||||||
shelltest("zfs snapshot -r test_source1@somesnapshot")
|
shelltest("zfs snapshot -r test_source1@somesnapshot")
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
@ -137,4 +138,3 @@ test_target1/fs2/sub@test-20101111000000
|
|||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_target1/test_source2/fs2/sub@test-20101111000000
|
test_target1/test_source2/fs2/sub@test-20101111000000
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from basetest import *
|
from basetest import *
|
||||||
|
|
||||||
|
|
||||||
class TestZfsAutobackup32(unittest2.TestCase):
|
class TestZfsAutobackup32(unittest2.TestCase):
|
||||||
"""various new 3.2 features"""
|
"""various new 3.2 features"""
|
||||||
|
|
||||||
@ -8,7 +9,6 @@ class TestZfsAutobackup32(unittest2.TestCase):
|
|||||||
self.longMessage = True
|
self.longMessage = True
|
||||||
|
|
||||||
def test_invalid_common_snapshot(self):
|
def test_invalid_common_snapshot(self):
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
@ -18,11 +18,12 @@ class TestZfsAutobackup32(unittest2.TestCase):
|
|||||||
|
|
||||||
with mocktime("20101111000001"):
|
with mocktime("20101111000001"):
|
||||||
# try the old way (without guid checking), and fail:
|
# try the old way (without guid checking), and fail:
|
||||||
self.assertEqual(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --no-guid-check".split(" ")).run(),1)
|
self.assertEqual(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --allow-empty --no-guid-check".split(" ")).run(), 1)
|
||||||
# new way should be ok:
|
# new way should be ok:
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-snapshot".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-snapshot".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -56,7 +57,6 @@ test_target1/test_source2/fs2/sub@test-20101111000001
|
|||||||
""")
|
""")
|
||||||
|
|
||||||
def test_invalid_common_snapshot_with_data(self):
|
def test_invalid_common_snapshot_with_data(self):
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
@ -67,11 +67,14 @@ test_target1/test_source2/fs2/sub@test-20101111000001
|
|||||||
|
|
||||||
with mocktime("20101111000001"):
|
with mocktime("20101111000001"):
|
||||||
# try the old way and fail:
|
# try the old way and fail:
|
||||||
self.assertEqual(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --destroy-incompatible --no-guid-check".split(" ")).run(),1)
|
self.assertEqual(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --allow-empty --destroy-incompatible --no-guid-check".split(
|
||||||
|
" ")).run(), 1)
|
||||||
# new way should be ok
|
# new way should be ok
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --no-snapshot --destroy-incompatible".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --no-snapshot --destroy-incompatible".split(" ")).run())
|
||||||
|
|
||||||
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -103,7 +106,6 @@ test_target1/test_source2/fs2/sub@test-20101111000000
|
|||||||
test_target1/test_source2/fs2/sub@test-20101111000001
|
test_target1/test_source2/fs2/sub@test-20101111000001
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
# check consistent mounting behaviour, see issue #112
|
# check consistent mounting behaviour, see issue #112
|
||||||
def test_mount_consitency_mounted(self):
|
def test_mount_consitency_mounted(self):
|
||||||
"""only filesystems that have canmount=on with a mountpoint should be mounted. """
|
"""only filesystems that have canmount=on with a mountpoint should be mounted. """
|
||||||
@ -121,23 +123,20 @@ test_target1/test_source2/fs2/sub@test-20101111000001
|
|||||||
/test_target1/test_source2/fs2/sub
|
/test_target1/test_source2/fs2/sub
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
def test_mount_consitency_unmounted(self):
|
def test_mount_consitency_unmounted(self):
|
||||||
"""only test_target1 should be mounted in this test"""
|
"""only test_target1 should be mounted in this test"""
|
||||||
|
|
||||||
shelltest("zfs create -V 10M test_source1/fs1/subvol")
|
shelltest("zfs create -V 10M test_source1/fs1/subvol")
|
||||||
|
|
||||||
with mocktime("20101111000000"):
|
with mocktime("20101111000000"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty --clear-mountpoint".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"test test_target1 --no-progress --verbose --allow-empty --clear-mountpoint".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs mount |grep -o /test_target1.*")
|
r = shelltest("zfs mount |grep -o /test_target1.*")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
/test_target1
|
/test_target1
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_transfer_thinning(self):
|
def test_transfer_thinning(self):
|
||||||
# test pre/post/during transfer thinning and efficient transfer (no transerring of stuff that gets deleted on target)
|
# test pre/post/during transfer thinning and efficient transfer (no transerring of stuff that gets deleted on target)
|
||||||
|
|
||||||
@ -167,8 +166,9 @@ test_target1/test_source2/fs2/sub@test-20101111000001
|
|||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
# now do thinning and transfer all at once
|
# now do thinning and transfer all at once
|
||||||
with mocktime("20010203000000"):
|
with mocktime("20010203000000"):
|
||||||
self.assertFalse(ZfsAutobackup("--keep-source=1d10d --keep-target=1m10m --allow-empty --verbose --clear-mountpoint --other-snapshots test2 test_target1".split(" ")).run())
|
self.assertFalse(ZfsAutobackup(
|
||||||
|
"--keep-source=1d10d --keep-target=1m10m --allow-empty --verbose --clear-mountpoint --other-snapshots test2 test_target1".split(
|
||||||
|
" ")).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
@ -182,7 +182,6 @@ test_target1/test_source2/fs2/sub@test-20101111000001
|
|||||||
[Source] test_source1/fs1/sub@test2-20010203000000: -> test_target1/test_source1/fs1/sub
|
[Source] test_source1/fs1/sub@test2-20010203000000: -> test_target1/test_source1/fs1/sub
|
||||||
""", buf.getvalue())
|
""", buf.getvalue())
|
||||||
|
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t snapshot test_source1 test_target1")
|
r = shelltest("zfs list -H -o name -r -t snapshot test_source1 test_target1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1/fs1/sub@other1
|
test_source1/fs1/sub@other1
|
||||||
@ -196,5 +195,3 @@ test_target1/test_source1/fs1/sub@test2-20010201000000
|
|||||||
test_target1/test_source1/fs1/sub@other2
|
test_target1/test_source1/fs1/sub@other2
|
||||||
test_target1/test_source1/fs1/sub@test2-20010203000000
|
test_target1/test_source1/fs1/sub@test2-20010203000000
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class TestZfsAutobackup34(unittest2.TestCase):
|
|||||||
with mocktime("20101111000002"):
|
with mocktime("20101111000002"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all " + TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -102,7 +102,7 @@ test_target1/test_source2/fs2/sub@test-20101111000002
|
|||||||
with mocktime("20101111000001"):
|
with mocktime("20101111000001"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all test_source1")
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_source1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -118,7 +118,7 @@ test_source1/fs1/sub#test-20101111000001
|
|||||||
self.assertFalse(ZfsAutobackup(
|
self.assertFalse(ZfsAutobackup(
|
||||||
"test test_target1 --no-progress --verbose --allow-empty --no-bookmarks".split(" ")).run())
|
"test test_target1 --no-progress --verbose --allow-empty --no-bookmarks".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all test_source1")
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_source1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -133,7 +133,7 @@ test_source1/fs1/sub@test-20101111000002
|
|||||||
with mocktime("20101111000003"):
|
with mocktime("20101111000003"):
|
||||||
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run())
|
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --allow-empty".split(" ")).run())
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all test_source1")
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem test_source1")
|
||||||
self.assertMultiLineEqual(r, """
|
self.assertMultiLineEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -207,7 +207,7 @@ test_target1/test_source2/fs2/sub@test-20101111000003
|
|||||||
|
|
||||||
# result:
|
# result:
|
||||||
# for target a the bookmarks should be at 20101111000002, for target b the bookmarks should be at 20101111000003
|
# for target a the bookmarks should be at 20101111000002, for target b the bookmarks should be at 20101111000003
|
||||||
r = shelltest("zfs list -H -r -t all -o name " + TEST_POOLS)
|
r = shelltest("zfs list -H -r -t snapshot,filesystem -o name " + TEST_POOLS)
|
||||||
|
|
||||||
self.assertRegexpMatches(r, """
|
self.assertRegexpMatches(r, """
|
||||||
test_source1
|
test_source1
|
||||||
|
@ -9,7 +9,6 @@ class TestZfsCheck(unittest2.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_volume(self):
|
def test_volume(self):
|
||||||
|
|
||||||
if exists("/.dockerenv"):
|
if exists("/.dockerenv"):
|
||||||
@ -37,9 +36,12 @@ class TestZfsCheck(unittest2.TestCase):
|
|||||||
with self.subTest("Compare"):
|
with self.subTest("Compare"):
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
self.assertEqual(1, ZfsCheck("test_source1/vol@test --check=/tmp/testhashes".split(" "),print_arguments=False).run())
|
self.assertEqual(1, ZfsCheck("test_source1/vol@test --check=/tmp/testhashes".split(" "),
|
||||||
|
print_arguments=False).run())
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
self.assertEqual("Chunk 1 failed: 2c2ceccb5ec5574f791d45b63c940cff20550f9X 2c2ceccb5ec5574f791d45b63c940cff20550f9a\n", buf.getvalue())
|
self.assertEqual(
|
||||||
|
"Chunk 1 failed: 2c2ceccb5ec5574f791d45b63c940cff20550f9X 2c2ceccb5ec5574f791d45b63c940cff20550f9a\n",
|
||||||
|
buf.getvalue())
|
||||||
|
|
||||||
def test_filesystem(self):
|
def test_filesystem(self):
|
||||||
prepare_zpools()
|
prepare_zpools()
|
||||||
@ -74,10 +76,13 @@ dir/testfile 0 2e863f1fcccd6642e4e28453eba10d2d3f74d798
|
|||||||
with self.subTest("Compare"):
|
with self.subTest("Compare"):
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
self.assertEqual(1, ZfsCheck("test_source1@test --check=/tmp/testhashes".split(" "),print_arguments=False).run())
|
self.assertEqual(1, ZfsCheck("test_source1@test --check=/tmp/testhashes".split(" "),
|
||||||
|
print_arguments=False).run())
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
self.assertEqual("dir/testfile: Chunk 0 failed: 2e863f1fcccd6642e4e28453eba10d2d3f74d79X 2e863f1fcccd6642e4e28453eba10d2d3f74d798\n", buf.getvalue())
|
self.assertEqual(
|
||||||
|
"dir/testfile: Chunk 0 failed: 2e863f1fcccd6642e4e28453eba10d2d3f74d79X 2e863f1fcccd6642e4e28453eba10d2d3f74d798\n",
|
||||||
|
buf.getvalue())
|
||||||
|
|
||||||
def test_file(self):
|
def test_file(self):
|
||||||
|
|
||||||
@ -97,9 +102,12 @@ dir/testfile 0 2e863f1fcccd6642e4e28453eba10d2d3f74d798
|
|||||||
with self.subTest("Compare"):
|
with self.subTest("Compare"):
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
self.assertEqual(1,ZfsCheck("tests/data/whole --check=/tmp/testhashes".split(" "), print_arguments=False).run())
|
self.assertEqual(1, ZfsCheck("tests/data/whole --check=/tmp/testhashes".split(" "),
|
||||||
|
print_arguments=False).run())
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
self.assertEqual("Chunk 0 failed: 3c0bf91170d873b8e327d3bafb6bc074580d11bX 3c0bf91170d873b8e327d3bafb6bc074580d11b7\n", buf.getvalue())
|
self.assertEqual(
|
||||||
|
"Chunk 0 failed: 3c0bf91170d873b8e327d3bafb6bc074580d11bX 3c0bf91170d873b8e327d3bafb6bc074580d11b7\n",
|
||||||
|
buf.getvalue())
|
||||||
|
|
||||||
def test_tree(self):
|
def test_tree(self):
|
||||||
shelltest("rm -rf /tmp/testtree; mkdir /tmp/testtree")
|
shelltest("rm -rf /tmp/testtree; mkdir /tmp/testtree")
|
||||||
@ -121,7 +129,6 @@ dir/testfile 0 2e863f1fcccd6642e4e28453eba10d2d3f74d798
|
|||||||
|
|
||||||
######################################
|
######################################
|
||||||
with self.subTest("Compare, all incorrect, skip 1"):
|
with self.subTest("Compare, all incorrect, skip 1"):
|
||||||
|
|
||||||
# store on disk for next step, add error
|
# store on disk for next step, add error
|
||||||
with open("/tmp/testhashes", "w") as fh:
|
with open("/tmp/testhashes", "w") as fh:
|
||||||
fh.write("""
|
fh.write("""
|
||||||
@ -134,7 +141,8 @@ whole_whole2_partial 0 309ffffba2e1977d12f3b7469971f30d28b94bdX
|
|||||||
|
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
self.assertEqual(ZfsCheck("/tmp/testtree --check=/tmp/testhashes --skip=1".split(" "), print_arguments=False).run(), 3)
|
self.assertEqual(ZfsCheck("/tmp/testtree --check=/tmp/testhashes --skip=1".split(" "),
|
||||||
|
print_arguments=False).run(), 3)
|
||||||
|
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
self.assertMultiLineEqual("""partial: Chunk 0 failed: 642027d63bb0afd7e0ba197f2c66ad03e3d70deX 642027d63bb0afd7e0ba197f2c66ad03e3d70de1
|
self.assertMultiLineEqual("""partial: Chunk 0 failed: 642027d63bb0afd7e0ba197f2c66ad03e3d70deX 642027d63bb0afd7e0ba197f2c66ad03e3d70de1
|
||||||
@ -204,7 +212,7 @@ whole_whole2_partial 0 309ffffba2e1977d12f3b7469971f30d28b94bd8
|
|||||||
shelltest("python -m zfs_autobackup.ZfsCheck test_source1/vol@test --debug| grep -m1 'Hashing file'")
|
shelltest("python -m zfs_autobackup.ZfsCheck test_source1/vol@test --debug| grep -m1 'Hashing file'")
|
||||||
# time.sleep(1)
|
# time.sleep(1)
|
||||||
|
|
||||||
r = shelltest("zfs list -H -o name -r -t all " + TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertMultiLineEqual("""
|
self.assertMultiLineEqual("""
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -218,6 +226,3 @@ test_source2/fs3
|
|||||||
test_source2/fs3/sub
|
test_source2/fs3/sub
|
||||||
test_target1
|
test_target1
|
||||||
""", r)
|
""", r)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,13 +12,15 @@ class TestZfsNode(unittest2.TestCase):
|
|||||||
def test_consistent_snapshot(self):
|
def test_consistent_snapshot(self):
|
||||||
logger = LogStub()
|
logger = LogStub()
|
||||||
description = "[Source]"
|
description = "[Source]"
|
||||||
node = ZfsNode(utc=False, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test", logger=logger, description=description)
|
node = ZfsNode(utc=False, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test",
|
||||||
|
logger=logger, description=description)
|
||||||
|
|
||||||
with self.subTest("first snapshot"):
|
with self.subTest("first snapshot"):
|
||||||
(selected_datasets, excluded_datasets)=node.selected_datasets(property_name="autobackup:test", exclude_paths=[], exclude_received=False,
|
(selected_datasets, excluded_datasets) = node.selected_datasets(property_name="autobackup:test",
|
||||||
|
exclude_paths=[], exclude_received=False,
|
||||||
exclude_unchanged=0)
|
exclude_unchanged=0)
|
||||||
node.consistent_snapshot(selected_datasets, "test-20101111000001", 100000)
|
node.consistent_snapshot(selected_datasets, "test-20101111000001", 100000)
|
||||||
r = shelltest("zfs list -H -o name -r -t all " + TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertEqual(r, """
|
self.assertEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -35,10 +37,11 @@ test_target1
|
|||||||
""")
|
""")
|
||||||
|
|
||||||
with self.subTest("second snapshot, no changes, no snapshot"):
|
with self.subTest("second snapshot, no changes, no snapshot"):
|
||||||
(selected_datasets, excluded_datasets)=node.selected_datasets(property_name="autobackup:test", exclude_paths=[], exclude_received=False,
|
(selected_datasets, excluded_datasets) = node.selected_datasets(property_name="autobackup:test",
|
||||||
|
exclude_paths=[], exclude_received=False,
|
||||||
exclude_unchanged=0)
|
exclude_unchanged=0)
|
||||||
node.consistent_snapshot(selected_datasets, "test-20101111000002", 1)
|
node.consistent_snapshot(selected_datasets, "test-20101111000002", 1)
|
||||||
r = shelltest("zfs list -H -o name -r -t all " + TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertEqual(r, """
|
self.assertEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -55,9 +58,11 @@ test_target1
|
|||||||
""")
|
""")
|
||||||
|
|
||||||
with self.subTest("second snapshot, no changes, empty snapshot"):
|
with self.subTest("second snapshot, no changes, empty snapshot"):
|
||||||
(selected_datasets, excluded_datasets) =node.selected_datasets(property_name="autobackup:test", exclude_paths=[], exclude_received=False, exclude_unchanged=0)
|
(selected_datasets, excluded_datasets) = node.selected_datasets(property_name="autobackup:test",
|
||||||
|
exclude_paths=[], exclude_received=False,
|
||||||
|
exclude_unchanged=0)
|
||||||
node.consistent_snapshot(selected_datasets, "test-20101111000002", 0)
|
node.consistent_snapshot(selected_datasets, "test-20101111000002", 0)
|
||||||
r = shelltest("zfs list -H -o name -r -t all " + TEST_POOLS)
|
r = shelltest("zfs list -H -o name -r -t snapshot,filesystem " + TEST_POOLS)
|
||||||
self.assertEqual(r, """
|
self.assertEqual(r, """
|
||||||
test_source1
|
test_source1
|
||||||
test_source1/fs1
|
test_source1/fs1
|
||||||
@ -79,12 +84,16 @@ test_target1
|
|||||||
def test_consistent_snapshot_prepostcmds(self):
|
def test_consistent_snapshot_prepostcmds(self):
|
||||||
logger = LogStub()
|
logger = LogStub()
|
||||||
description = "[Source]"
|
description = "[Source]"
|
||||||
node = ZfsNode(utc=False, snapshot_time_format="test", hold_name="test", logger=logger, description=description, debug_output=True)
|
node = ZfsNode(utc=False, snapshot_time_format="test", hold_name="test", logger=logger, description=description,
|
||||||
|
debug_output=True)
|
||||||
|
|
||||||
with self.subTest("Test if all cmds are executed correctly (no failures)"):
|
with self.subTest("Test if all cmds are executed correctly (no failures)"):
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
(selected_datasets, excluded_datasets) =node.selected_datasets(property_name="autobackup:test", exclude_paths=[], exclude_received=False, exclude_unchanged=0)
|
(selected_datasets, excluded_datasets) = node.selected_datasets(property_name="autobackup:test",
|
||||||
|
exclude_paths=[],
|
||||||
|
exclude_received=False,
|
||||||
|
exclude_unchanged=0)
|
||||||
node.consistent_snapshot(selected_datasets, "test-1",
|
node.consistent_snapshot(selected_datasets, "test-1",
|
||||||
0,
|
0,
|
||||||
pre_snapshot_cmds=["echo pre1", "echo pre2"],
|
pre_snapshot_cmds=["echo pre1", "echo pre2"],
|
||||||
@ -96,12 +105,15 @@ test_target1
|
|||||||
self.assertIn("STDOUT > post1", buf.getvalue())
|
self.assertIn("STDOUT > post1", buf.getvalue())
|
||||||
self.assertIn("STDOUT > post2", buf.getvalue())
|
self.assertIn("STDOUT > post2", buf.getvalue())
|
||||||
|
|
||||||
|
with self.subTest(
|
||||||
with self.subTest("Failure in the middle, only pre1 and both post1 and post2 should be executed, no snapshot should be attempted"):
|
"Failure in the middle, only pre1 and both post1 and post2 should be executed, no snapshot should be attempted"):
|
||||||
with OutputIO() as buf:
|
with OutputIO() as buf:
|
||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
with self.assertRaises(ExecuteError):
|
with self.assertRaises(ExecuteError):
|
||||||
(selected_datasets, excluded_datasets) =node.selected_datasets(property_name="autobackup:test", exclude_paths=[], exclude_received=False, exclude_unchanged=0)
|
(selected_datasets, excluded_datasets) = node.selected_datasets(property_name="autobackup:test",
|
||||||
|
exclude_paths=[],
|
||||||
|
exclude_received=False,
|
||||||
|
exclude_unchanged=0)
|
||||||
node.consistent_snapshot(selected_datasets, "test-1",
|
node.consistent_snapshot(selected_datasets, "test-1",
|
||||||
0,
|
0,
|
||||||
pre_snapshot_cmds=["echo pre1", "false", "echo pre2"],
|
pre_snapshot_cmds=["echo pre1", "false", "echo pre2"],
|
||||||
@ -119,7 +131,10 @@ test_target1
|
|||||||
with redirect_stdout(buf):
|
with redirect_stdout(buf):
|
||||||
with self.assertRaises(ExecuteError):
|
with self.assertRaises(ExecuteError):
|
||||||
# same snapshot name as before so it fails
|
# same snapshot name as before so it fails
|
||||||
(selected_datasets, excluded_datasets) =node.selected_datasets(property_name="autobackup:test", exclude_paths=[], exclude_received=False, exclude_unchanged=0)
|
(selected_datasets, excluded_datasets) = node.selected_datasets(property_name="autobackup:test",
|
||||||
|
exclude_paths=[],
|
||||||
|
exclude_received=False,
|
||||||
|
exclude_unchanged=0)
|
||||||
node.consistent_snapshot(selected_datasets, "test-1",
|
node.consistent_snapshot(selected_datasets, "test-1",
|
||||||
0,
|
0,
|
||||||
pre_snapshot_cmds=["echo pre1", "echo pre2"],
|
pre_snapshot_cmds=["echo pre1", "echo pre2"],
|
||||||
@ -136,8 +151,10 @@ test_target1
|
|||||||
# Assert that timestamps keep relative order both for utc and for localtime
|
# Assert that timestamps keep relative order both for utc and for localtime
|
||||||
logger = LogStub()
|
logger = LogStub()
|
||||||
description = "[Source]"
|
description = "[Source]"
|
||||||
node_local = ZfsNode(utc=False, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test", logger=logger, description=description)
|
node_local = ZfsNode(utc=False, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test",
|
||||||
node_utc = ZfsNode(utc=True, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test", logger=logger, description=description)
|
logger=logger, description=description)
|
||||||
|
node_utc = ZfsNode(utc=True, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test",
|
||||||
|
logger=logger, description=description)
|
||||||
|
|
||||||
for node in [node_local, node_utc]:
|
for node in [node_local, node_utc]:
|
||||||
with self.subTest("timestamp ordering " + ("utc" if node == node_utc else "localtime")):
|
with self.subTest("timestamp ordering " + ("utc" if node == node_utc else "localtime")):
|
||||||
@ -147,9 +164,7 @@ test_target1
|
|||||||
self.assertGreater(dataset_b.timestamp, dataset_a.timestamp)
|
self.assertGreater(dataset_b.timestamp, dataset_a.timestamp)
|
||||||
self.assertGreater(dataset_c.timestamp, dataset_b.timestamp)
|
self.assertGreater(dataset_c.timestamp, dataset_b.timestamp)
|
||||||
|
|
||||||
|
|
||||||
def test_getselected(self):
|
def test_getselected(self):
|
||||||
|
|
||||||
# should be excluded by property
|
# should be excluded by property
|
||||||
shelltest("zfs create test_source1/fs1/subexcluded")
|
shelltest("zfs create test_source1/fs1/subexcluded")
|
||||||
shelltest("zfs set autobackup:test=false test_source1/fs1/subexcluded")
|
shelltest("zfs set autobackup:test=false test_source1/fs1/subexcluded")
|
||||||
@ -165,8 +180,10 @@ test_target1
|
|||||||
|
|
||||||
logger = LogStub()
|
logger = LogStub()
|
||||||
description = "[Source]"
|
description = "[Source]"
|
||||||
node = ZfsNode(utc=False, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test", logger=logger, description=description)
|
node = ZfsNode(utc=False, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test",
|
||||||
(selected_datasets, excluded_datasets)=node.selected_datasets(property_name="autobackup:test", exclude_paths=[], exclude_received=False,
|
logger=logger, description=description)
|
||||||
|
(selected_datasets, excluded_datasets) = node.selected_datasets(property_name="autobackup:test",
|
||||||
|
exclude_paths=[], exclude_received=False,
|
||||||
exclude_unchanged=1)
|
exclude_unchanged=1)
|
||||||
s = pformat(selected_datasets)
|
s = pformat(selected_datasets)
|
||||||
print(s)
|
print(s)
|
||||||
@ -177,11 +194,11 @@ test_target1
|
|||||||
(local): test_source1/fs1/sub,
|
(local): test_source1/fs1/sub,
|
||||||
(local): test_source2/fs2/sub]""")
|
(local): test_source2/fs2/sub]""")
|
||||||
|
|
||||||
|
|
||||||
def test_validcommand(self):
|
def test_validcommand(self):
|
||||||
logger = LogStub()
|
logger = LogStub()
|
||||||
description = "[Source]"
|
description = "[Source]"
|
||||||
node = ZfsNode(utc=False, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test", logger=logger, description=description)
|
node = ZfsNode(utc=False, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test",
|
||||||
|
logger=logger, description=description)
|
||||||
|
|
||||||
with self.subTest("test invalid option"):
|
with self.subTest("test invalid option"):
|
||||||
self.assertFalse(node.valid_command(["zfs", "send", "--invalid-option", "nonexisting"]))
|
self.assertFalse(node.valid_command(["zfs", "send", "--invalid-option", "nonexisting"]))
|
||||||
@ -191,7 +208,8 @@ test_target1
|
|||||||
def test_supportedsendoptions(self):
|
def test_supportedsendoptions(self):
|
||||||
logger = LogStub()
|
logger = LogStub()
|
||||||
description = "[Source]"
|
description = "[Source]"
|
||||||
node = ZfsNode(utc=False, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test", logger=logger, description=description)
|
node = ZfsNode(utc=False, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test",
|
||||||
|
logger=logger, description=description)
|
||||||
# -D propably always supported
|
# -D propably always supported
|
||||||
self.assertGreater(len(node.supported_send_options), 0)
|
self.assertGreater(len(node.supported_send_options), 0)
|
||||||
|
|
||||||
@ -199,7 +217,8 @@ test_target1
|
|||||||
logger = LogStub()
|
logger = LogStub()
|
||||||
description = "[Source]"
|
description = "[Source]"
|
||||||
# NOTE: this could hang via ssh if we dont close filehandles properly. (which was a previous bug)
|
# NOTE: this could hang via ssh if we dont close filehandles properly. (which was a previous bug)
|
||||||
node = ZfsNode(utc=False, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test", logger=logger, description=description, ssh_to='localhost')
|
node = ZfsNode(utc=False, snapshot_time_format="test-%Y%m%d%H%M%S", hold_name="zfs_autobackup:test",
|
||||||
|
logger=logger, description=description, ssh_to='localhost')
|
||||||
self.assertIsInstance(node.supported_recv_options, list)
|
self.assertIsInstance(node.supported_recv_options, list)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user