From 11fd6afb0fea28105d72c974e57dd7000ac4e8cc Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 13 Feb 2023 01:35:26 +0100 Subject: [PATCH] use "fail" chunker to test erroneous input file skipping if a file can't be read (like here: there is a simulated I/O error in the 2nd chunk of file2), it should be logged with "E" status, skipped and backup shall proceed with next file(s). also, check that the repo has no orphan chunks (exception handling code needs to deal with 1st chunk of file2 which already has been written / incref'd in the repo). --- src/borg/testsuite/archiver/create_cmd.py | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/borg/testsuite/archiver/create_cmd.py b/src/borg/testsuite/archiver/create_cmd.py index 82cf8a35b..63310b6b6 100644 --- a/src/borg/testsuite/archiver/create_cmd.py +++ b/src/borg/testsuite/archiver/create_cmd.py @@ -191,6 +191,32 @@ class ArchiverTestCase(ArchiverTestCaseBase): out = self.cmd(f"--repo={self.repository_location}", "extract", "test", "stdin", "--stdout", binary_output=True) assert out == input_data + def test_create_erroneous_file(self): + chunk_size = 1000 # fixed chunker with this size, also volume based checkpointing after that volume + self.create_regular_file(os.path.join(self.input_path, "file1"), size=chunk_size * 2) + self.create_regular_file(os.path.join(self.input_path, "file2"), size=chunk_size * 2) + self.create_regular_file(os.path.join(self.input_path, "file3"), size=chunk_size * 2) + self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION) + flist = "".join(f"input/file{n}\n" for n in range(1, 4)) + out = self.cmd( + f"--repo={self.repository_location}", + "create", + f"--chunker-params=fail,{chunk_size},RRRERRR", + "--paths-from-stdin", + "--list", + "test", + input=flist.encode(), + exit_code=1, + ) + assert "E input/file2" in out + # repo looking good overall? checks for rc == 0. + self.cmd(f"--repo={self.repository_location}", "check", "--debug") + # check files in created archive + out = self.cmd(f"--repo={self.repository_location}", "list", "test") + assert "input/file1" in out + assert "input/file2" not in out + assert "input/file3" in out + def test_create_content_from_command(self): self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION) input_data = "some test content"