Skip to content

Commit dc7d876

Browse files
Merge pull request #8862 from ThomasWaldmann/tests-save-temp-space
Tests: save temp space
2 parents 7760ebb + 36e9cd4 commit dc7d876

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

src/borg/testsuite/archiver/extract_cmd_test.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ def is_sparse(fn, total_size, hole_size):
204204
sparse = False
205205
return sparse
206206

207-
filename = os.path.join(archiver.input_path, "sparse")
207+
filename_in = os.path.join(archiver.input_path, "sparse")
208208
content = b"foobar"
209209
hole_size = 5 * (1 << CHUNK_MAX_EXP) # 5 full chunker buffers
210210
total_size = hole_size + len(content) + hole_size
211-
with open(filename, "wb") as fd:
211+
with open(filename_in, "wb") as fd:
212212
# create a file that has a hole at the beginning and end (if the
213213
# OS and filesystem supports sparse files)
214214
fd.seek(hole_size, 1)
@@ -217,7 +217,7 @@ def is_sparse(fn, total_size, hole_size):
217217
pos = fd.tell()
218218
fd.truncate(pos)
219219
# we first check if we could create a sparse input file:
220-
sparse_support = is_sparse(filename, total_size, hole_size)
220+
sparse_support = is_sparse(filename_in, total_size, hole_size)
221221
if sparse_support:
222222
# we could create a sparse input file, so creating a backup of it and
223223
# extracting it again (as sparse) should also work:
@@ -226,13 +226,15 @@ def is_sparse(fn, total_size, hole_size):
226226
with changedir(archiver.output_path):
227227
cmd(archiver, "extract", "test", "--sparse")
228228
assert_dirs_equal("input", "output/input")
229-
filename = os.path.join(archiver.output_path, "input", "sparse")
230-
with open(filename, "rb") as fd:
229+
filename_out = os.path.join(archiver.output_path, "input", "sparse")
230+
with open(filename_out, "rb") as fd:
231231
# check if file contents are as expected
232232
assert fd.read(hole_size) == b"\0" * hole_size
233233
assert fd.read(len(content)) == content
234234
assert fd.read(hole_size) == b"\0" * hole_size
235-
assert is_sparse(filename, total_size, hole_size)
235+
assert is_sparse(filename_out, total_size, hole_size)
236+
os.unlink(filename_out) # save space on TMPDIR
237+
os.unlink(filename_in) # save space on TMPDIR
236238

237239

238240
def test_unusual_filenames(archivers, request):

src/borg/testsuite/archiver/list_cmd_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ def test_list_chunk_counts(archivers, request):
3535
archiver = request.getfixturevalue(archivers)
3636
create_regular_file(archiver.input_path, "empty_file", size=0)
3737
create_regular_file(archiver.input_path, "two_chunks")
38-
with open(os.path.join(archiver.input_path, "two_chunks"), "wb") as fd:
38+
filename = os.path.join(archiver.input_path, "two_chunks")
39+
with open(filename, "wb") as fd:
3940
fd.write(b"abba" * 2000000)
4041
fd.write(b"baab" * 2000000)
4142
cmd(archiver, "repo-create", RK_ENCRYPTION)
4243
cmd(archiver, "create", "test", "input")
44+
os.unlink(filename) # save space on TMPDIR
4345
output = cmd(archiver, "list", "test", "--format", "{num_chunks} {path}{NL}")
4446
assert "0 input/empty_file" in output
4547
assert "2 input/two_chunks" in output

src/borg/testsuite/archiver/repo_space_cmd_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ def test_repo_space_modify_reservation(archivers, request):
5454

5555
# note: --reserve can only INCREASE the amount of reserved space.
5656

57+
cmd(archiver, "repo-space", "--free") # save space on TMPDIR
58+
5759

5860
def test_repo_space_edge_cases(archivers, request):
5961
archiver = request.getfixturevalue(archivers)
@@ -78,3 +80,5 @@ def test_repo_space_edge_cases(archivers, request):
7880
# Check that space is reserved (should be 64MiB).
7981
output = cmd(archiver, "repo-space")
8082
assert "There is 67.11 MB reserved space in this repository." in output
83+
84+
cmd(archiver, "repo-space", "--free") # save space on TMPDIR

src/borg/testsuite/archiver/transfer_cmd_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def test_transfer_rechunk(archivers, request, monkeypatch):
412412
"""Test transfer with re-chunking"""
413413
archiver = request.getfixturevalue(archivers)
414414

415-
BLKSIZE = 4096
415+
BLKSIZE = 512
416416
source_chunker_params = "buzhash,19,23,21,4095" # default buzhash chunks
417417
dest_chunker_params = f"fixed,{BLKSIZE}" # fixed chunk size
418418

src/borg/testsuite/legacyrepository_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ def test_max_data_size(repo_fixtures, request):
229229
assert pdchunk(repository.get(H(0))) == max_data
230230
with pytest.raises(IntegrityError):
231231
repository.put(H(1), fchunk(max_data + b"x"))
232+
repository.delete(H(0))
232233

233234

234235
def _assert_sparse(repository):

src/borg/testsuite/repository_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def test_max_data_size(repo_fixtures, request):
143143
assert pdchunk(repository.get(H(0))) == max_data
144144
with pytest.raises(IntegrityError):
145145
repository.put(H(1), fchunk(max_data + b"x"))
146+
repository.delete(H(0))
146147

147148

148149
def check(repository, repo_path, repair=False, status=True):

0 commit comments

Comments
 (0)