Browse Source

Increase the retry limit to 20 times and the interval to 200ms (#5134)

The original settings has less tolerance and would fail on some
environments.
tags/v1.7.0-dev
Mura Li 5 years ago
parent
commit
9458880c06
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      models/test_fixtures.go

+ 9
- 2
models/test_fixtures.go View File

@@ -5,6 +5,9 @@
package models

import (
"fmt"
"time"

"gopkg.in/testfixtures.v2"
)

@@ -21,12 +24,16 @@ func InitFixtures(helper testfixtures.Helper, dir string) (err error) {
func LoadFixtures() error {
var err error
// Database transaction conflicts could occur and result in ROLLBACK
// As a simple workaround, we just retry 5 times.
for i := 0; i < 5; i++ {
// As a simple workaround, we just retry 20 times.
for i := 0; i < 20; i++ {
err = fixtures.Load()
if err == nil {
break
}
time.Sleep(200 * time.Millisecond)
}
if err != nil {
fmt.Printf("LoadFixtures failed after retries: %v\n", err)
}
return err
}

Loading…
Cancel
Save