1
0
mirror of https://github.com/rclone/rclone.git synced 2025-01-13 20:38:12 +02:00

mounttest: retry directory listings to account for slow updates on Windows

This commit is contained in:
Nick Craig-Wood 2017-11-17 10:30:35 +00:00
parent 992647b157
commit 981cfb1bec

View File

@ -10,6 +10,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path" "path"
"reflect"
"runtime" "runtime"
"strings" "strings"
"testing" "testing"
@ -257,14 +258,27 @@ func (r *Run) readRemote(t *testing.T, dir dirMap, filepath string) {
// checkDir checks the local and remote against the string passed in // checkDir checks the local and remote against the string passed in
func (r *Run) checkDir(t *testing.T, dirString string) { func (r *Run) checkDir(t *testing.T, dirString string) {
dm := newDirMap(dirString) var retries = *fstest.ListRetries
localDm := make(dirMap) sleep := time.Second / 2
r.readLocal(t, localDm, "") var remoteOK, fuseOK bool
remoteDm := make(dirMap) for i := 1; i <= retries; i++ {
r.readRemote(t, remoteDm, "") dm := newDirMap(dirString)
// Ignore directories for remote compare localDm := make(dirMap)
assert.Equal(t, dm.filesOnly(), remoteDm.filesOnly(), "expected vs remote") r.readLocal(t, localDm, "")
assert.Equal(t, dm, localDm, "expected vs fuse mount") remoteDm := make(dirMap)
r.readRemote(t, remoteDm, "")
// Ignore directories for remote compare
remoteOK = reflect.DeepEqual(dm.filesOnly(), remoteDm.filesOnly())
fuseOK = reflect.DeepEqual(dm, localDm)
if remoteOK && fuseOK {
return
}
sleep *= 2
t.Logf("Sleeping for %v for list eventual consistency: %d/%d", sleep, i, retries)
time.Sleep(sleep)
}
assert.True(t, remoteOK, "expected vs remote")
assert.True(t, fuseOK, "expected vs fuse mount")
} }
func (r *Run) createFile(t *testing.T, filepath string, contents string) { func (r *Run) createFile(t *testing.T, filepath string, contents string) {