Sync when doing disk accountant testing

Depending on your filesystem and kernel you may not actually sync things
to disk quickly enough in the tests to cause the disk accountant tests
to pass reliably. Update the tests to sync to disk explicitly so that
the tests are reliable.

This was noticed as being a problem on btrfs /tmp on suse tumbleweed.

Change-Id: I38fce053ee878751540b4c9d4b05863dc5588de8
This commit is contained in:
Clark Boylan 2018-02-06 15:02:16 -08:00
parent c65f4014a1
commit d688a62053
2 changed files with 3 additions and 0 deletions

View File

@ -1,6 +1,7 @@
- hosts: localhost
tasks:
- command: dd if=/dev/zero of=toobig bs=1M count=2
- command: sync
- wait_for:
delay: 10
path: /

View File

@ -47,6 +47,8 @@ class TestDiskAccountant(BaseTestCase):
testfile = os.path.join(jobdir, 'tfile')
with open(testfile, 'w') as tf:
tf.write(2 * 1024 * 1024 * '.')
tf.flush()
os.fsync(tf.fileno())
# da should catch over-limit dir within 5 seconds
for i in range(0, 50):