mounttest: wait for all background Close/Release after writing a file

The filesystem does a certain amount of things asynchronously waiting
for the file to be released after writing it means everything should
be in a consistent state.
This commit is contained in:
Nick Craig-Wood 2017-11-18 15:50:38 +00:00
parent 60945d0a37
commit e98e550021
4 changed files with 16 additions and 3 deletions

View file

@ -2,7 +2,6 @@ package mounttest
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -18,8 +17,7 @@ func TestWriteFileNoWrite(t *testing.T) {
err = fd.Close()
assert.NoError(t, err)
// FIXME - wait for the Release on the file
time.Sleep(10 * time.Millisecond)
run.waitForWriters()
run.checkDir(t, "testnowrite 0")
@ -38,6 +36,8 @@ func FIXMETestWriteOpenFileInDirListing(t *testing.T) {
err = fd.Close()
assert.NoError(t, err)
run.waitForWriters()
run.rm(t, "testnowrite")
}
@ -68,6 +68,8 @@ func TestWriteFileOverwrite(t *testing.T) {
//
// NB the code for this is in file.go rather than write.go
func TestWriteFileFsync(t *testing.T) {
run.skipIfNoFUSE(t)
filepath := run.path("to be synced")
fd, err := osCreate(filepath)
require.NoError(t, err)
@ -77,4 +79,6 @@ func TestWriteFileFsync(t *testing.T) {
require.NoError(t, err)
err = fd.Close()
require.NoError(t, err)
run.waitForWriters()
run.rm(t, "to be synced")
}