DashboardStore: Use ReplDB and get dashboard quotas from the ReadReplica (#90235)

* Use ReplDB in dashboard store and update all fixtures - no other changes

* just moving dashboard counts for now

* find the missing test fixture
This commit is contained in:
Kristin Laemmert
2024-07-12 10:47:49 -04:00
committed by GitHub
parent e64ef2245c
commit 8a6107cd35
35 changed files with 256 additions and 244 deletions
@@ -44,16 +44,16 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
var sqlStore db.DB
var sqlStore db.ReplDB
var cfg *setting.Cfg
var savedFolder, savedDash, savedDash2 *dashboards.Dashboard
var dashboardStore dashboards.Store
setup := func() {
sqlStore, cfg = db.InitTestDBWithCfg(t)
sqlStore, cfg = db.InitTestReplDBWithCfg(t)
quotaService := quotatest.New(false, nil)
var err error
dashboardStore, err = ProvideDashboardStore(sqlStore, cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore), quotaService)
dashboardStore, err = ProvideDashboardStore(sqlStore, cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore.DB()), quotaService)
require.NoError(t, err)
// insertTestDashboard creates the following hierarchy:
// 1 test dash folder
@@ -539,16 +539,16 @@ func TestIntegrationGetSoftDeletedDashboard(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
var sqlStore *sqlstore.SQLStore
var sqlStore db.ReplDB
var cfg *setting.Cfg
var savedFolder, savedDash *dashboards.Dashboard
var dashboardStore dashboards.Store
setup := func() {
sqlStore, cfg = db.InitTestDBWithCfg(t)
sqlStore, cfg = db.InitTestReplDBWithCfg(t)
quotaService := quotatest.New(false, nil)
var err error
dashboardStore, err = ProvideDashboardStore(sqlStore, cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore), quotaService)
dashboardStore, err = ProvideDashboardStore(sqlStore, cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore.DB()), quotaService)
require.NoError(t, err)
savedFolder = insertTestDashboard(t, dashboardStore, "1 test dash folder", 1, 0, "", true, "prod", "webapp")
savedDash = insertTestDashboard(t, dashboardStore, "test dash 23", 1, savedFolder.ID, savedFolder.UID, false, "prod", "webapp")
@@ -660,7 +660,7 @@ func TestIntegrationDashboardDataAccessGivenPluginWithImportedDashboards(t *test
if testing.Short() {
t.Skip("skipping integration test")
}
sqlStore := db.InitTestDB(t)
sqlStore := db.InitTestReplDB(t)
quotaService := quotatest.New(false, nil)
dashboardStore, err := ProvideDashboardStore(sqlStore, &setting.Cfg{}, testFeatureToggles, tagimpl.ProvideService(sqlStore), quotaService)
require.NoError(t, err)
@@ -685,7 +685,7 @@ func TestIntegrationDashboard_SortingOptions(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
sqlStore := db.InitTestDB(t)
sqlStore := db.InitTestReplDB(t)
quotaService := quotatest.New(false, nil)
dashboardStore, err := ProvideDashboardStore(sqlStore, &setting.Cfg{}, testFeatureToggles, tagimpl.ProvideService(sqlStore), quotaService)
require.NoError(t, err)
@@ -736,7 +736,7 @@ func TestIntegrationDashboard_Filter(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
sqlStore := db.InitTestDB(t)
sqlStore := db.InitTestReplDB(t)
cfg := setting.NewCfg()
quotaService := quotatest.New(false, nil)
dashboardStore, err := ProvideDashboardStore(sqlStore, cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore), quotaService)
@@ -780,7 +780,7 @@ func TestIntegrationDashboard_Filter(t *testing.T) {
}
func TestGetExistingDashboardByTitleAndFolder(t *testing.T) {
sqlStore := db.InitTestDB(t)
sqlStore := db.InitTestReplDB(t)
cfg := setting.NewCfg()
quotaService := quotatest.New(false, nil)
dashboardStore, err := ProvideDashboardStore(sqlStore, cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore), quotaService)
@@ -818,7 +818,7 @@ func TestIntegrationFindDashboardsByTitle(t *testing.T) {
t.Skip("skipping integration test")
}
sqlStore := db.InitTestDB(t)
sqlStore := db.InitTestReplDB(t)
cfg := setting.NewCfg()
quotaService := quotatest.New(false, nil)
features := featuremgmt.WithFeatures(featuremgmt.FlagNestedFolders, featuremgmt.FlagPanelTitleSearch)
@@ -935,7 +935,7 @@ func TestIntegrationFindDashboardsByFolder(t *testing.T) {
t.Skip("skipping integration test")
}
sqlStore := db.InitTestDB(t)
sqlStore := db.InitTestReplDB(t)
cfg := setting.NewCfg()
quotaService := quotatest.New(false, nil)
features := featuremgmt.WithFeatures(featuremgmt.FlagNestedFolders, featuremgmt.FlagPanelTitleSearch)
@@ -1116,8 +1116,8 @@ func TestIntegrationFindDashboardsByFolder(t *testing.T) {
}
}
func insertTestRule(t *testing.T, sqlStore db.DB, foderOrgID int64, folderUID string) {
err := sqlStore.WithDbSession(context.Background(), func(sess *db.Session) error {
func insertTestRule(t *testing.T, sqlStore db.ReplDB, foderOrgID int64, folderUID string) {
err := sqlStore.DB().WithDbSession(context.Background(), func(sess *db.Session) error {
type alertQuery struct {
RefID string
DatasourceUID string