spanner: Disable running alerting integration tests when using spanner. (#102730)
* Disable running alerting integration tests when using spanner. * Disable tests for templategroup.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
|
||||
"xorm.io/core"
|
||||
|
||||
"xorm.io/xorm"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
@@ -53,6 +54,7 @@ type InitTestDBOpt = sqlstore.InitTestDBOpt
|
||||
var SetupTestDB = sqlstore.SetupTestDB
|
||||
var CleanupTestDB = sqlstore.CleanupTestDB
|
||||
var ProvideService = sqlstore.ProvideService
|
||||
var SkipTestsOnSpanner = sqlstore.SkipTestsOnSpanner
|
||||
|
||||
func InitTestDB(t sqlutil.ITestDB, opts ...InitTestDBOpt) *sqlstore.SQLStore {
|
||||
db, _ := InitTestDBWithCfg(t, opts...)
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testsuite.Run(m)
|
||||
testsuite.RunButSkipOnSpanner(m)
|
||||
}
|
||||
|
||||
func TestIntegrationAlertmanagerStore(t *testing.T) {
|
||||
|
||||
@@ -414,6 +414,7 @@ var testSQLStoreSetup = false
|
||||
var testSQLStore *SQLStore
|
||||
var testSQLStoreMutex sync.Mutex
|
||||
var testSQLStoreCleanup []func()
|
||||
var testSQLStoreSkipTestsOnBackend string // When not empty and matches DB type, test is skipped.
|
||||
|
||||
// InitTestDBOpt contains options for InitTestDB.
|
||||
type InitTestDBOpt struct {
|
||||
@@ -458,6 +459,12 @@ func SetupTestDB() {
|
||||
testSQLStoreSetup = true
|
||||
}
|
||||
|
||||
func SkipTestsOnSpanner() {
|
||||
testSQLStoreMutex.Lock()
|
||||
defer testSQLStoreMutex.Unlock()
|
||||
testSQLStoreSkipTestsOnBackend = "spanner"
|
||||
}
|
||||
|
||||
func CleanupTestDB() {
|
||||
testSQLStoreMutex.Lock()
|
||||
defer testSQLStoreMutex.Unlock()
|
||||
@@ -542,6 +549,10 @@ func TestMain(m *testing.M) {
|
||||
if testSQLStore == nil {
|
||||
dbType := sqlutil.GetTestDBType()
|
||||
|
||||
if testSQLStoreSkipTestsOnBackend != "" && testSQLStoreSkipTestsOnBackend == dbType {
|
||||
t.Skipf("test skipped when using DB type %s", testSQLStoreSkipTestsOnBackend)
|
||||
}
|
||||
|
||||
// set test db config
|
||||
cfg := setting.NewCfg()
|
||||
// nolint:staticcheck
|
||||
|
||||
@@ -17,6 +17,7 @@ type ITestDB interface {
|
||||
Logf(format string, args ...any)
|
||||
Log(args ...any)
|
||||
Cleanup(func())
|
||||
Skipf(format string, args ...any)
|
||||
}
|
||||
|
||||
type TestDB struct {
|
||||
|
||||
@@ -33,7 +33,7 @@ const (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testsuite.Run(m)
|
||||
testsuite.RunButSkipOnSpanner(m)
|
||||
}
|
||||
|
||||
func TestGrafanaRuleConfig(t *testing.T) {
|
||||
|
||||
@@ -53,7 +53,7 @@ import (
|
||||
var testData embed.FS
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testsuite.Run(m)
|
||||
testsuite.RunButSkipOnSpanner(m)
|
||||
}
|
||||
|
||||
func getTestHelper(t *testing.T) *apis.K8sTestHelper {
|
||||
|
||||
@@ -38,7 +38,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testsuite.Run(m)
|
||||
testsuite.RunButSkipOnSpanner(m)
|
||||
}
|
||||
|
||||
func getTestHelper(t *testing.T) *apis.K8sTestHelper {
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testsuite.Run(m)
|
||||
testsuite.RunButSkipOnSpanner(m)
|
||||
}
|
||||
|
||||
func getTestHelper(t *testing.T) *apis.K8sTestHelper {
|
||||
|
||||
@@ -43,7 +43,7 @@ import (
|
||||
var testData embed.FS
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testsuite.Run(m)
|
||||
testsuite.RunButSkipOnSpanner(m)
|
||||
}
|
||||
|
||||
func getTestHelper(t *testing.T) *apis.K8sTestHelper {
|
||||
|
||||
@@ -13,3 +13,8 @@ func Run(m *testing.M) {
|
||||
db.CleanupTestDB()
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
func RunButSkipOnSpanner(m *testing.M) {
|
||||
db.SkipTestsOnSpanner()
|
||||
Run(m)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user