mirror of
https://github.com/rclone/rclone.git
synced 2025-08-16 00:28:09 +02:00
Fix integration tests so they can be run independently and out of order - fixes #291
* Make all integration tests start with an empty remote * Add an -individual flag so this can be a different bucket/container/directory * Fix up tests after changing the hashers * Add sha1sum test * Make directory checking in tests sleep more to fix acd inconsistencies * Factor integration tests to make more maintainable * Ensure remote writes have a fstest.CheckItems() before use * this fixes eventual consistency on the directory listings later * Call fs.Stats.ResetCounters() before every fs.Sync() Note that the tests shouldn't be run concurrently as fs.Config is global state.
This commit is contained in:
@ -555,6 +555,7 @@ func MoveDir(fdst, fsrc Fs) error {
|
||||
|
||||
// Check the files in fsrc and fdst according to Size and hash
|
||||
func Check(fdst, fsrc Fs) error {
|
||||
differences := int32(0)
|
||||
var (
|
||||
wg sync.WaitGroup
|
||||
dstFiles, srcFiles map[string]Object
|
||||
@ -597,12 +598,14 @@ func Check(fdst, fsrc Fs) error {
|
||||
for _, dst := range dstFiles {
|
||||
Stats.Error()
|
||||
ErrorLog(dst, "File not in %v", fsrc)
|
||||
atomic.AddInt32(&differences, 1)
|
||||
}
|
||||
|
||||
Log(fsrc, "%d files not in %s", len(srcFiles), fdst)
|
||||
for _, src := range srcFiles {
|
||||
Stats.Error()
|
||||
ErrorLog(src, "File not in %v", fdst)
|
||||
atomic.AddInt32(&differences, 1)
|
||||
}
|
||||
|
||||
checks := make(chan []Object, Config.Transfers)
|
||||
@ -625,6 +628,7 @@ func Check(fdst, fsrc Fs) error {
|
||||
Stats.DoneChecking(src)
|
||||
Stats.Error()
|
||||
ErrorLog(src, "Sizes differ")
|
||||
atomic.AddInt32(&differences, 1)
|
||||
continue
|
||||
}
|
||||
same, _, err := CheckHashes(src, dst)
|
||||
@ -634,6 +638,7 @@ func Check(fdst, fsrc Fs) error {
|
||||
}
|
||||
if !same {
|
||||
Stats.Error()
|
||||
atomic.AddInt32(&differences, 1)
|
||||
ErrorLog(src, "Md5sums differ")
|
||||
}
|
||||
Debug(src, "OK")
|
||||
@ -644,8 +649,8 @@ func Check(fdst, fsrc Fs) error {
|
||||
Log(fdst, "Waiting for checks to finish")
|
||||
checkerWg.Wait()
|
||||
Log(fdst, "%d differences found", Stats.GetErrors())
|
||||
if Stats.GetErrors() > 0 {
|
||||
return fmt.Errorf("%d differences found", Stats.GetErrors())
|
||||
if differences > 0 {
|
||||
return fmt.Errorf("%d differences found", differences)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user