mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 22:22:38 +08:00

* 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
26 lines
452 B
Go
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()
|
|
}
|