]> source.dussan.org Git - gitea.git/commitdiff
Retry test-fixtures loading in case of transaction rollback (#5125)
authorMura Li <typeless@users.noreply.github.com>
Sat, 20 Oct 2018 20:48:33 +0000 (04:48 +0800)
committertechknowlogick <hello@techknowlogick.com>
Sat, 20 Oct 2018 20:48:33 +0000 (16:48 -0400)
models/test_fixtures.go

index d7f59ec3b58876c4fd37e498480d3bc19f911f9a..2a70bc98160be2cbed10aed4c93d5e01138dbf94 100644 (file)
@@ -19,5 +19,14 @@ func InitFixtures(helper testfixtures.Helper, dir string) (err error) {
 
 // LoadFixtures load fixtures for a test database
 func LoadFixtures() error {
-       return fixtures.Load()
+       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++ {
+               err = fixtures.Load()
+               if err == nil {
+                       break
+               }
+       }
+       return err
 }