[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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 4 deletions

View File

@ -316,7 +316,7 @@ jobs:
NETBIRD_STORE_ENGINE=${{ matrix.store }} \ NETBIRD_STORE_ENGINE=${{ matrix.store }} \
go test -tags=devcert \ go test -tags=devcert \
-exec "sudo --preserve-env=CI,NETBIRD_STORE_ENGINE" \ -exec "sudo --preserve-env=CI,NETBIRD_STORE_ENGINE" \
-timeout 10m ./management/... -timeout 20m ./management/...
benchmark: benchmark:
name: "Management / Benchmark" name: "Management / Benchmark"
@ -508,7 +508,7 @@ jobs:
NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true \ NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true \
go test -tags=integration \ go test -tags=integration \
-exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' \ -exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' \
-timeout 10m ./management/... -timeout 20m ./management/...
test_client_on_docker: test_client_on_docker:
name: "Client (Docker) / Unit" name: "Client (Docker) / Unit"

View File

@ -358,7 +358,18 @@ func NewTestStoreFromSQL(ctx context.Context, filename string, dataDir string) (
return nil, nil, fmt.Errorf("failed to add all group to account: %v", err) 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 { func addAllGroupToAccount(ctx context.Context, store Store) error {