mirror of https://github.com/borgbackup/borg.git
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
This commit is contained in:
parent
1f271821b8
commit
f28d5d1f96
|
@ -136,7 +136,8 @@ def test_disk_full(cmd):
|
||||||
os.mkdir(dir)
|
os.mkdir(dir)
|
||||||
if rnd:
|
if rnd:
|
||||||
count = random.randint(1, count)
|
count = random.randint(1, count)
|
||||||
size = random.randint(1, size)
|
if size > 1:
|
||||||
|
size = random.randint(1, size)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
fn = os.path.join(dir, "file%03d" % i)
|
fn = os.path.join(dir, "file%03d" % i)
|
||||||
with open(fn, 'wb') as f:
|
with open(fn, 'wb') as f:
|
||||||
|
@ -151,16 +152,24 @@ def test_disk_full(cmd):
|
||||||
reserve = os.path.join(mount, 'reserve')
|
reserve = os.path.join(mount, 'reserve')
|
||||||
for j in range(100):
|
for j in range(100):
|
||||||
shutil.rmtree(repo, ignore_errors=True)
|
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)
|
rc, out = cmd('init', repo)
|
||||||
print('init', rc, out)
|
if rc != EXIT_SUCCESS:
|
||||||
|
print('init', rc, out)
|
||||||
assert rc == EXIT_SUCCESS
|
assert rc == EXIT_SUCCESS
|
||||||
# keep some space in reserve that we can free up later:
|
|
||||||
make_files(reserve, 1, 8000000, rnd=False)
|
|
||||||
try:
|
try:
|
||||||
success, i = True, 0
|
success, i = True, 0
|
||||||
while success:
|
while success:
|
||||||
i += 1
|
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:
|
try:
|
||||||
rc, out = cmd('create', '%s::test%03d' % (repo, i), input)
|
rc, out = cmd('create', '%s::test%03d' % (repo, i), input)
|
||||||
success = rc == EXIT_SUCCESS
|
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:
|
# free some space so we can expect borg to be able to work normally:
|
||||||
shutil.rmtree(reserve, ignore_errors=True)
|
shutil.rmtree(reserve, ignore_errors=True)
|
||||||
rc, out = cmd('list', repo)
|
rc, out = cmd('list', repo)
|
||||||
print('list', rc, out)
|
if rc != EXIT_SUCCESS:
|
||||||
assert rc == EXIT_SUCCESS
|
print('list', rc, out)
|
||||||
rc, out = cmd('check', '--repair', repo)
|
rc, out = cmd('check', '--repair', repo)
|
||||||
print('check', rc, out)
|
if rc != EXIT_SUCCESS:
|
||||||
|
print('check', rc, out)
|
||||||
assert rc == EXIT_SUCCESS
|
assert rc == EXIT_SUCCESS
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue