From f28d5d1f96ea0194f39ce9d380f1342fa9c456af Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 3 Nov 2015 19:39:05 +0100 Subject: [PATCH] disk full test: some improvements - can create 0-byte files now - frees space early (avoids running out of disk space at repo init time) - creates multiple reserve files, so we do not only reserve some space, but also some inodes - only print output if there is an error RC - if make_files makes us run out of space, that is not interesting, just start a new iteration from scratch --- borg/testsuite/archiver.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/borg/testsuite/archiver.py b/borg/testsuite/archiver.py index fc6649d3f..61d954e67 100644 --- a/borg/testsuite/archiver.py +++ b/borg/testsuite/archiver.py @@ -136,7 +136,8 @@ def test_disk_full(cmd): os.mkdir(dir) if rnd: count = random.randint(1, count) - size = random.randint(1, size) + if size > 1: + size = random.randint(1, size) for i in range(count): fn = os.path.join(dir, "file%03d" % i) with open(fn, 'wb') as f: @@ -151,16 +152,24 @@ def test_disk_full(cmd): reserve = os.path.join(mount, 'reserve') for j in range(100): shutil.rmtree(repo, ignore_errors=True) + shutil.rmtree(input, ignore_errors=True) + # keep some space and some inodes in reserve that we can free up later: + make_files(reserve, 80, 100000, rnd=False) rc, out = cmd('init', repo) - print('init', rc, out) + if rc != EXIT_SUCCESS: + print('init', rc, out) assert rc == EXIT_SUCCESS - # keep some space in reserve that we can free up later: - make_files(reserve, 1, 8000000, rnd=False) try: success, i = True, 0 while success: i += 1 - make_files(input, 20, 200000) # random, ~1MB + try: + make_files(input, 20, 200000) + except OSError as err: + if err.errno == errno.ENOSPC: + # already out of space + break + raise try: rc, out = cmd('create', '%s::test%03d' % (repo, i), input) success = rc == EXIT_SUCCESS @@ -175,10 +184,11 @@ def test_disk_full(cmd): # free some space so we can expect borg to be able to work normally: shutil.rmtree(reserve, ignore_errors=True) rc, out = cmd('list', repo) - print('list', rc, out) - assert rc == EXIT_SUCCESS + if rc != EXIT_SUCCESS: + print('list', rc, out) rc, out = cmd('check', '--repair', repo) - print('check', rc, out) + if rc != EXIT_SUCCESS: + print('check', rc, out) assert rc == EXIT_SUCCESS