Revert "Chore: Use proper database type from env in testinfra integration tests" (#109081)

Revert "Chore: Use proper database type from env in testinfra integration tes…"

This reverts commit 772f647210.
This commit is contained in:
Stephanie Hingtgen
2025-08-01 20:49:54 +00:00
committed by GitHub
parent 8b5b9b68c2
commit bd5c83bc11
9 changed files with 30 additions and 60 deletions
-15
View File
@@ -22,11 +22,6 @@ type TestDB struct {
DriverName string
ConnStr string
Path string
Host string
Port string
User string
Password string
Database string
Cleanup func()
}
@@ -137,11 +132,6 @@ func mySQLTestDB() (*TestDB, error) {
return &TestDB{
DriverName: "mysql",
ConnStr: conn_str,
Host: host,
Port: port,
User: "grafana",
Password: "password",
Database: "grafana_tests",
Cleanup: func() {},
}, nil
}
@@ -159,11 +149,6 @@ func postgresTestDB() (*TestDB, error) {
return &TestDB{
DriverName: "postgres",
ConnStr: connStr,
Host: host,
Port: port,
User: "grafanatest",
Password: "grafanatest",
Database: "grafanatest",
Cleanup: func() {},
}, nil
}
@@ -161,21 +161,14 @@ func TestIntegrationProvisioning_CreatingAndGetting(t *testing.T) {
// Viewer can see settings listing
t.Run("viewer has access to list", func(t *testing.T) {
settings := &provisioning.RepositoryViewList{}
// Wait for unified storage to make the data available
require.Eventually(t, func() bool {
rsp := helper.ViewerREST.Get().
Namespace("default").
Suffix("settings").
Do(context.Background())
if rsp.Error() != nil {
return false
}
err := rsp.Into(settings)
if err != nil {
return false
}
return len(settings.Items) == len(inputFiles)
}, time.Second*10, time.Millisecond*100, "Expected settings to have len(inputFiles) items")
rsp := helper.ViewerREST.Get().
Namespace("default").
Suffix("settings").
Do(context.Background())
require.NoError(t, rsp.Error())
err := rsp.Into(settings)
require.NoError(t, err)
require.Len(t, settings.Items, len(inputFiles))
// FIXME: this should be an enterprise integration test
if extensions.IsEnterprise {
@@ -1832,10 +1825,8 @@ func TestIntegrationProvisioning_MoveResources(t *testing.T) {
// Verify dashboard still exists in Grafana with same content but may have updated path references
helper.SyncAndWait(t, repo, nil)
require.Eventually(t, func() bool {
_, err = helper.DashboardsV1.Resource.Get(ctx, allPanelsUID, metav1.GetOptions{})
return err == nil
}, 10*time.Second, 100*time.Millisecond, "dashboard should still exist in Grafana after move") // Using Eventually to account for potential delays in dashboards APIs.
_, err = helper.DashboardsV1.Resource.Get(ctx, allPanelsUID, metav1.GetOptions{})
require.NoError(t, err, "dashboard should still exist in Grafana after move")
})
t.Run("move file to nested path without ref", func(t *testing.T) {
-15
View File
@@ -13,7 +13,6 @@ import (
"time"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/sqlstore/sqlutil"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -86,20 +85,6 @@ func StartGrafanaEnv(t *testing.T, grafDir, cfgPath string) (string, *server.Tes
err = featuremgmt.InitOpenFeatureWithCfg(cfg)
require.NoError(t, err)
// Use proper database type based on the environment variable GRAFANA_TEST_DB in tests
testDB, err := sqlutil.GetTestDB(sqlutil.GetTestDBType())
require.NoError(t, err)
t.Cleanup(testDB.Cleanup)
dbCfg := cfg.Raw.Section("database")
dbCfg.Key("type").SetValue(testDB.DriverName)
dbCfg.Key("host").SetValue(testDB.Host)
dbCfg.Key("port").SetValue(testDB.Port)
dbCfg.Key("user").SetValue(testDB.User)
dbCfg.Key("password").SetValue(testDB.Password)
dbCfg.Key("name").SetValue(testDB.Database)
env, err := server.InitializeForTest(t, t, cfg, serverOpts, apiServerOpts)
require.NoError(t, err)