The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/util/shortid_generator_race_test.go

25 lines
452 B

//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()
}