Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Increase the retry limit to 20 times and the interval to 200ms
The original settings has less tolerance and would fail on some
environments.
  • Loading branch information
Mura Li committed Oct 21, 2018
commit addb5b8f250d1b320f278eda87edf641cd7f8921
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
}