Unistore Chore: Add OTEL testing harness (#94835)

* add testing harness

* fix mockery and linters

* fix data race in tests

* fix data race in tests

* reduce cardinality of data
This commit is contained in:
Diego Augusto Molina
2024-10-17 08:41:06 -03:00
committed by GitHub
parent 8b9bb2acf6
commit cf08f6762d
14 changed files with 757 additions and 42 deletions
@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"net/http"
"sync"
"testing"
"github.com/google/uuid"
@@ -111,8 +112,18 @@ func newTestInfraDB(t *testing.T, m cfgMap) infraDB.DB {
return sqlstoreDB
}
// globalUnprotectedMutableState controls access to global mutable state found
// in the `setting` package that is not appropriately protected. This would
// ideally be a part of some struct instead of being global, be protected if it
// needs to change, and be unmutable once it no longer needs to change. Example:
// `setting.AppUrl`. Nothing can run in parallel because of this.
// TODO: fix that.
var globalUnprotectedMutableState sync.Mutex
func newCfgFromIniMap(t *testing.T, m cfgMap) *setting.Cfg {
t.Helper()
globalUnprotectedMutableState.Lock()
defer globalUnprotectedMutableState.Unlock()
cfg, err := setting.NewCfgFromINIFile(newTestINIFile(t, m))
require.NoError(t, err)
return cfg