Skip to content

Commit

Permalink
Increase the retry limit to 20 times and the interval to 200ms (#5134)
Browse files Browse the repository at this point in the history
The original settings has less tolerance and would fail on some
environments.
  • Loading branch information
typeless authored and jonasfranz committed Oct 21, 2018
1 parent 43f9233 commit 9458880
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions models/test_fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
package models

import (
"fmt"
"time"

"gopkg.in/testfixtures.v2"
)

Expand All @@ -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
}

0 comments on commit 9458880

Please sign in to comment.