Files
grafana/pkg/util/shortid_generator_race_test.go
Matheus Macabu 5917ed8227 Hackaton: Add more unit tests, take 4 (#101704)
* cloudmigration/cloudmigrationimpl: run integration tests in parallel

* tsdb/mysql: run tests with actual service and instance manager

* pluginsintegration/angulardetectorsprovider: reduce job interval in test

* util: extract test that should only be ran with -race enabled and unskip it
2025-03-07 14:06:47 +01:00

26 lines
452 B
Go

//go:build race
// +build race
package util
import (
"sync"
"testing"
)
// Run with "go test -race -run ^TestThreadSafe$ github.com/grafana/grafana/pkg/util"
func TestThreadSafe(t *testing.T) {
// Use 1000 go routines to create 100 UIDs each at roughly the same time.
var wg sync.WaitGroup
for i := 0; i < 1000; i++ {
go func() {
for ii := 0; ii < 100; ii++ {
_ = GenerateShortUID()
}
wg.Done()
}()
wg.Add(1)
}
wg.Wait()
}