diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 5669d22..0022c6e 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -17,7 +17,7 @@ jobs: - name: Prepare - run: sudo apt update && sudo apt install zfsutils-linux && sudo -H pip3 install coverage unittest2 mock==3.0.5 coveralls + run: sudo apt update && sudo apt install zfsutils-linux lzop pigz zstd gzip xz-utils && sudo -H pip3 install coverage unittest2 mock==3.0.5 coveralls - name: Regression test @@ -39,7 +39,7 @@ jobs: - name: Prepare - run: sudo apt update && sudo apt install zfsutils-linux python3-setuptools && sudo -H pip3 install coverage unittest2 mock==3.0.5 coveralls + run: sudo apt update && sudo apt install zfsutils-linux python3-setuptools lzop pigz zstd gzip xz-utils && sudo -H pip3 install coverage unittest2 mock==3.0.5 coveralls - name: Regression test @@ -64,7 +64,7 @@ jobs: python-version: '2.x' - name: Prepare - run: sudo apt update && sudo apt install zfsutils-linux python-setuptools && sudo -H pip install coverage unittest2 mock==3.0.5 coveralls colorama + run: sudo apt update && sudo apt install zfsutils-linux python-setuptools lzop pigz zstd gzip xz-utils && sudo -H pip install coverage unittest2 mock==3.0.5 coveralls colorama - name: Regression test run: sudo -E ./tests/run_tests diff --git a/tests/test_sendrecvpipes.py b/tests/test_sendrecvpipes.py index 34bdccf..00d6aab 100644 --- a/tests/test_sendrecvpipes.py +++ b/tests/test_sendrecvpipes.py @@ -1,3 +1,4 @@ +import zfs_autobackup.compressors from basetest import * import time @@ -13,14 +14,36 @@ class TestSendRecvPipes(unittest2.TestCase): def test_send_basics(self): """send basics (remote/local send pipe)""" - with patch('time.strftime', return_value="20101111000000"): - self.assertFalse(ZfsAutobackup(["test", "test_target1", "--no-progress", "--send-pipe=dd bs=1M", "--recv-pipe=dd bs=2M"]).run()) - with patch('time.strftime', return_value="20101111000001"): - self.assertFalse(ZfsAutobackup(["test", "test_target1", "--no-progress", "--ssh-source=localhost", "--send-pipe=dd bs=1M", "--recv-pipe=dd bs=2M"]).run()) + with self.subTest("local local pipe"): + with patch('time.strftime', return_value="20101111000000"): + self.assertFalse(ZfsAutobackup(["test", "test_target1", "--exclude-received", "--no-holds", "--no-progress", "--send-pipe=dd bs=1M", "--recv-pipe=dd bs=2M"]).run()) - with patch('time.strftime', return_value="20101111000001"): - self.assertFalse(ZfsAutobackup(["test", "test_target1", "--no-progress", "--ssh-target=localhost", "--send-pipe=dd bs=1M", "--recv-pipe=dd bs=2M"]).run()) + shelltest("zfs destroy -r test_target1/test_source1/fs1/sub") - with patch('time.strftime', return_value="20101111000001"): - self.assertFalse(ZfsAutobackup(["test", "test_target1", "--no-progress", "--ssh-source=localhost", "--ssh-target=localhost", "--send-pipe=dd bs=1M", "--recv-pipe=dd bs=2M"]).run()) + with self.subTest("remote local pipe"): + with patch('time.strftime', return_value="20101111000000"): + self.assertFalse(ZfsAutobackup(["test", "test_target1", "--exclude-received", "--no-holds", "--no-progress", "--ssh-source=localhost", "--send-pipe=dd bs=1M", "--recv-pipe=dd bs=2M"]).run()) + + shelltest("zfs destroy -r test_target1/test_source1/fs1/sub") + + with self.subTest("local remote pipe"): + with patch('time.strftime', return_value="20101111000000"): + self.assertFalse(ZfsAutobackup(["test", "test_target1", "--exclude-received", "--no-holds", "--no-progress", "--ssh-target=localhost", "--send-pipe=dd bs=1M", "--recv-pipe=dd bs=2M"]).run()) + + shelltest("zfs destroy -r test_target1/test_source1/fs1/sub") + + with self.subTest("remote remote pipe"): + with patch('time.strftime', return_value="20101111000000"): + self.assertFalse(ZfsAutobackup(["test", "test_target1", "--exclude-received", "--no-holds", "--no-progress", "--ssh-source=localhost", "--ssh-target=localhost", "--send-pipe=dd bs=1M", "--recv-pipe=dd bs=2M"]).run()) + + def test_compress(self): + """send basics (remote/local send pipe)""" + + for compress in zfs_autobackup.compressors.COMPRESS_CMDS.keys(): + + with self.subTest("compress "+compress): + with patch('time.strftime', return_value="20101111000000"): + self.assertFalse(ZfsAutobackup(["test", "test_target1", "--exclude-received", "--no-holds", "--no-progress", "--compress="+compress]).run()) + + shelltest("zfs destroy -r test_target1/test_source1/fs1/sub") diff --git a/zfs_autobackup/ZfsAutobackup.py b/zfs_autobackup/ZfsAutobackup.py index 9217677..b5476a3 100644 --- a/zfs_autobackup/ZfsAutobackup.py +++ b/zfs_autobackup/ZfsAutobackup.py @@ -123,7 +123,7 @@ class ZfsAutobackup: parser.add_argument('--exclude-received', action='store_true', help=argparse.SUPPRESS) # probably never needed anymore - parser.add_argument('--compress', metavar='TYPE', default=None, choices=compressors.choices(), help='Use compression during transfer ({})'.format(", ".join(compressors.choices()))) + parser.add_argument('--compress', metavar='TYPE', default=None, choices=compressors.choices(), help='Use compression during transfer, zstd-fast recommended ({})'.format(", ".join(compressors.choices()))) # note args is the only global variable we use, since its a global readonly setting anyway