diff --git a/tests/test_sendrecvpipes.py b/tests/test_sendrecvpipes.py new file mode 100644 index 0000000..3becf83 --- /dev/null +++ b/tests/test_sendrecvpipes.py @@ -0,0 +1,33 @@ +from basetest import * +import time + +class TestSendRecvPipes(unittest2.TestCase): + """test input/output pipes for zfs send and recv""" + + def setUp(self): + prepare_zpools() + self.longMessage=True + + + + 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", "--send-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", "--send-pipe=dd bs=2M"]).run()) + +# 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. +# self.assertMultiLineEqual(r,""" +# test_target1/a/test_source1/fs1@test-20101111000000 +# test_target1/a/test_source1/fs1/sub@test-20101111000000 +# test_target1/a/test_source2/fs2/sub@test-20101111000000 +# test_target1/b/test_source1/fs1@test-20101111000000 +# test_target1/b/test_source1/fs1/sub@test-20101111000000 +# test_target1/b/test_source2/fs2/sub@test-20101111000000 +# test_target1/b/test_target1/a/test_source1/fs1@test-20101111000000 +# test_target1/b/test_target1/a/test_source1/fs1/sub@test-20101111000000 +# """) \ No newline at end of file diff --git a/tests/test_zfsautobackup31.py b/tests/test_zfsautobackup31.py index 11b6437..c66301e 100644 --- a/tests/test_zfsautobackup31.py +++ b/tests/test_zfsautobackup31.py @@ -2,6 +2,7 @@ from basetest import * import time class TestZfsAutobackup31(unittest2.TestCase): + """various new 3.1 features""" def setUp(self): prepare_zpools() diff --git a/zfs_autobackup/ZfsDataset.py b/zfs_autobackup/ZfsDataset.py index 91b7e8b..0c4f4b7 100644 --- a/zfs_autobackup/ZfsDataset.py +++ b/zfs_autobackup/ZfsDataset.py @@ -557,20 +557,19 @@ class ZfsDataset: cmd.append(self.name) # #add custom output pipes? - # if output_pipes: - # #local so do our own piping - # if self.zfs_node.is_local(): - # output_pipe = self.zfs_node.run(cmd) - # for pipe_cmd in output_pipes: - # output_pipe=self.zfs_node.run(pipe_cmd, inp=output_pipe, ) - # return output_pipe - # #remote, so add with actual | and let remote shell handle it - # else: - # for pipe_cmd in output_pipes: - # cmd.append("|") - # cmd.extend(pipe_cmd) + #local so do our own piping + if self.zfs_node.is_local(): + output_pipe = self.zfs_node.run(cmd, pipe=True, readonly=True) + for pipe_cmd in output_pipes: + output_pipe=self.zfs_node.run(pipe_cmd.split(" "), inp=output_pipe, pipe=True, readonly=False) + #remote, so add with actual | and let remote shell handle it + else: + for pipe_cmd in output_pipes: + cmd.append("|") + cmd.extend(pipe_cmd.split(" ")) + output_pipe = self.zfs_node.run(cmd, pipe=True, readonly=True) - return self.zfs_node.run(cmd, pipe=True, readonly=True) + return output_pipe def recv_pipe(self, pipe, features, filter_properties=None, set_properties=None, ignore_exit_code=False): """starts a zfs recv for this snapshot and uses pipe as input