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