[tests] Retry mysql store creation on reused containers (#3370)

This commit is contained in:
Pascal Fischer
2025-02-24 13:40:11 +01:00
committed by GitHub
parent dabdef4d67
commit c8a558f797
2 changed files with 15 additions and 4 deletions

View File

@@ -353,12 +353,23 @@ func NewTestStoreFromSQL(ctx context.Context, filename string, dataDir string) (
return nil, nil, fmt.Errorf("failed to create test store: %v", err)
}
err = addAllGroupToAccount(ctx, store)
err = addAllGroupToAccount(ctx, store)
if err != nil {
return nil, nil, fmt.Errorf("failed to add all group to account: %v", err)
}
return getSqlStoreEngine(ctx, store, kind)
maxRetries := 2
for i := 0; i < maxRetries; i++ {
sqlStore, cleanUp, err := getSqlStoreEngine(ctx, store, kind)
if err == nil {
return sqlStore, cleanUp, nil
}
if i < maxRetries-1 {
time.Sleep(100 * time.Millisecond)
}
}
return nil, nil, fmt.Errorf("failed to create test store after %d attempts: %v", maxRetries, err)
}
func addAllGroupToAccount(ctx context.Context, store Store) error {