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:
@@ -48,6 +48,7 @@ func TestIntegrationListPublicDashboard(t *testing.T) {
|
||||
}
|
||||
|
||||
var sqlStore db.DB
|
||||
var replStore db.ReplDB
|
||||
var cfg *setting.Cfg
|
||||
|
||||
var aDash *dashboards.Dashboard
|
||||
@@ -63,9 +64,10 @@ func TestIntegrationListPublicDashboard(t *testing.T) {
|
||||
var publicdashboardStore *PublicDashboardStoreImpl
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t, db.InitTestDBOpt{})
|
||||
replStore, cfg = db.InitTestReplDBWithCfg(t, db.InitTestDBOpt{})
|
||||
sqlStore = replStore.DB()
|
||||
quotaService := quotatest.New(false, nil)
|
||||
dashboardStore, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
dashboardStore, err := dashboardsDB.ProvideDashboardStore(replStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
require.NoError(t, err)
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
|
||||
@@ -171,19 +173,19 @@ func TestIntegrationExistsEnabledByAccessToken(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
var sqlStore db.DB
|
||||
var sqlStore db.ReplDB
|
||||
var cfg *setting.Cfg
|
||||
var dashboardStore dashboards.Store
|
||||
var publicdashboardStore *PublicDashboardStoreImpl
|
||||
var savedDashboard *dashboards.Dashboard
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t)
|
||||
sqlStore, cfg = db.InitTestReplDBWithCfg(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore.DB()), quotaService)
|
||||
require.NoError(t, err)
|
||||
dashboardStore = store
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
publicdashboardStore = ProvideStore(sqlStore.DB(), cfg, featuremgmt.WithFeatures())
|
||||
savedDashboard = insertTestDashboard(t, dashboardStore, "testDashie", 1, "", true)
|
||||
}
|
||||
t.Run("ExistsEnabledByAccessToken will return true when at least one public dashboard has a matching access token", func(t *testing.T) {
|
||||
@@ -244,19 +246,19 @@ func TestIntegrationExistsEnabledByDashboardUid(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
var sqlStore db.DB
|
||||
var sqlStore db.ReplDB
|
||||
var cfg *setting.Cfg
|
||||
var dashboardStore dashboards.Store
|
||||
var publicdashboardStore *PublicDashboardStoreImpl
|
||||
var savedDashboard *dashboards.Dashboard
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t)
|
||||
sqlStore, cfg = db.InitTestReplDBWithCfg(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore.DB()), quotaService)
|
||||
require.NoError(t, err)
|
||||
dashboardStore = store
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
publicdashboardStore = ProvideStore(sqlStore.DB(), cfg, featuremgmt.WithFeatures())
|
||||
savedDashboard = insertTestDashboard(t, dashboardStore, "testDashie", 1, "", true)
|
||||
}
|
||||
|
||||
@@ -309,19 +311,19 @@ func TestIntegrationFindByDashboardUid(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
var sqlStore db.DB
|
||||
var sqlStore db.ReplDB
|
||||
var cfg *setting.Cfg
|
||||
var dashboardStore dashboards.Store
|
||||
var publicdashboardStore *PublicDashboardStoreImpl
|
||||
var savedDashboard *dashboards.Dashboard
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t)
|
||||
sqlStore, cfg = db.InitTestReplDBWithCfg(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore.DB()), quotaService)
|
||||
require.NoError(t, err)
|
||||
dashboardStore = store
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
publicdashboardStore = ProvideStore(sqlStore.DB(), cfg, featuremgmt.WithFeatures())
|
||||
savedDashboard = insertTestDashboard(t, dashboardStore, "testDashie", 1, "", true)
|
||||
}
|
||||
|
||||
@@ -377,7 +379,7 @@ func TestIntegrationFindByAccessToken(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
var sqlStore db.DB
|
||||
var sqlStore db.ReplDB
|
||||
var cfg *setting.Cfg
|
||||
var dashboardStore dashboards.Store
|
||||
var publicdashboardStore *PublicDashboardStoreImpl
|
||||
@@ -385,10 +387,10 @@ func TestIntegrationFindByAccessToken(t *testing.T) {
|
||||
var err error
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t)
|
||||
dashboardStore, err = dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotatest.New(false, nil))
|
||||
sqlStore, cfg = db.InitTestReplDBWithCfg(t)
|
||||
dashboardStore, err = dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore.DB()), quotatest.New(false, nil))
|
||||
require.NoError(t, err)
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
publicdashboardStore = ProvideStore(sqlStore.DB(), cfg, featuremgmt.WithFeatures())
|
||||
savedDashboard = insertTestDashboard(t, dashboardStore, "testDashie", 1, "", true)
|
||||
}
|
||||
|
||||
@@ -445,7 +447,7 @@ func TestIntegrationCreatePublicDashboard(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
var sqlStore db.DB
|
||||
var sqlStore db.ReplDB
|
||||
var cfg *setting.Cfg
|
||||
var dashboardStore dashboards.Store
|
||||
var publicdashboardStore *PublicDashboardStoreImpl
|
||||
@@ -453,12 +455,12 @@ func TestIntegrationCreatePublicDashboard(t *testing.T) {
|
||||
var savedDashboard2 *dashboards.Dashboard
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t, db.InitTestDBOpt{})
|
||||
sqlStore, cfg = db.InitTestReplDBWithCfg(t, db.InitTestDBOpt{})
|
||||
quotaService := quotatest.New(false, nil)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore.DB()), quotaService)
|
||||
require.NoError(t, err)
|
||||
dashboardStore = store
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
publicdashboardStore = ProvideStore(sqlStore.DB(), cfg, featuremgmt.WithFeatures())
|
||||
savedDashboard = insertTestDashboard(t, dashboardStore, "testDashie", 1, "", true)
|
||||
savedDashboard2 = insertTestDashboard(t, dashboardStore, "testDashie2", 1, "", true)
|
||||
insertPublicDashboard(t, publicdashboardStore, savedDashboard2.UID, savedDashboard2.OrgID, false, PublicShareType)
|
||||
@@ -524,7 +526,7 @@ func TestIntegrationUpdatePublicDashboard(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
var sqlStore db.DB
|
||||
var sqlStore db.ReplDB
|
||||
var cfg *setting.Cfg
|
||||
var dashboardStore dashboards.Store
|
||||
var publicdashboardStore *PublicDashboardStoreImpl
|
||||
@@ -533,11 +535,11 @@ func TestIntegrationUpdatePublicDashboard(t *testing.T) {
|
||||
var err error
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t, db.InitTestDBOpt{})
|
||||
sqlStore, cfg = db.InitTestReplDBWithCfg(t, db.InitTestDBOpt{})
|
||||
quotaService := quotatest.New(false, nil)
|
||||
dashboardStore, err = dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
dashboardStore, err = dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore.DB()), quotaService)
|
||||
require.NoError(t, err)
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
publicdashboardStore = ProvideStore(sqlStore.DB(), cfg, featuremgmt.WithFeatures())
|
||||
savedDashboard = insertTestDashboard(t, dashboardStore, "testDashie", 1, "", true)
|
||||
anotherSavedDashboard = insertTestDashboard(t, dashboardStore, "test another Dashie", 1, "", true)
|
||||
}
|
||||
@@ -629,7 +631,7 @@ func TestIntegrationGetOrgIdByAccessToken(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
var sqlStore db.DB
|
||||
var sqlStore db.ReplDB
|
||||
var cfg *setting.Cfg
|
||||
var dashboardStore dashboards.Store
|
||||
var publicdashboardStore *PublicDashboardStoreImpl
|
||||
@@ -637,11 +639,11 @@ func TestIntegrationGetOrgIdByAccessToken(t *testing.T) {
|
||||
var err error
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t)
|
||||
sqlStore, cfg = db.InitTestReplDBWithCfg(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
dashboardStore, err = dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
dashboardStore, err = dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore.DB()), quotaService)
|
||||
require.NoError(t, err)
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
publicdashboardStore = ProvideStore(sqlStore.DB(), cfg, featuremgmt.WithFeatures())
|
||||
savedDashboard = insertTestDashboard(t, dashboardStore, "testDashie", 1, "", true)
|
||||
}
|
||||
t.Run("GetOrgIdByAccessToken will OrgId when enabled", func(t *testing.T) {
|
||||
@@ -701,7 +703,7 @@ func TestIntegrationDelete(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
var sqlStore db.DB
|
||||
var sqlStore db.ReplDB
|
||||
var cfg *setting.Cfg
|
||||
var dashboardStore dashboards.Store
|
||||
var publicdashboardStore *PublicDashboardStoreImpl
|
||||
@@ -710,10 +712,10 @@ func TestIntegrationDelete(t *testing.T) {
|
||||
var err error
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t)
|
||||
dashboardStore, err = dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotatest.New(false, nil))
|
||||
sqlStore, cfg = db.InitTestReplDBWithCfg(t)
|
||||
dashboardStore, err = dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore.DB()), quotatest.New(false, nil))
|
||||
require.NoError(t, err)
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
publicdashboardStore = ProvideStore(sqlStore.DB(), cfg, featuremgmt.WithFeatures())
|
||||
savedDashboard = insertTestDashboard(t, dashboardStore, "testDashie", 1, "", true)
|
||||
savedPublicDashboard = insertPublicDashboard(t, publicdashboardStore, savedDashboard.UID, savedDashboard.OrgID, true, PublicShareType)
|
||||
}
|
||||
@@ -761,7 +763,7 @@ func TestFindByFolder(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("can get all pubdashes for dashboard folder and org", func(t *testing.T) {
|
||||
sqlStore, cfg := db.InitTestDBWithCfg(t)
|
||||
sqlStore, cfg := db.InitTestReplDBWithCfg(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
dashboardStore, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
require.NoError(t, err)
|
||||
@@ -790,7 +792,7 @@ func TestGetMetrics(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
var sqlStore db.DB
|
||||
var sqlStore db.ReplDB
|
||||
var cfg *setting.Cfg
|
||||
var dashboardStore dashboards.Store
|
||||
var publicdashboardStore *PublicDashboardStoreImpl
|
||||
@@ -800,12 +802,12 @@ func TestGetMetrics(t *testing.T) {
|
||||
var savedDashboard4 *dashboards.Dashboard
|
||||
|
||||
setup := func() {
|
||||
sqlStore, cfg = db.InitTestDBWithCfg(t, db.InitTestDBOpt{})
|
||||
sqlStore, cfg = db.InitTestReplDBWithCfg(t, db.InitTestDBOpt{})
|
||||
quotaService := quotatest.New(false, nil)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore), quotaService)
|
||||
store, err := dashboardsDB.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore.DB()), quotaService)
|
||||
require.NoError(t, err)
|
||||
dashboardStore = store
|
||||
publicdashboardStore = ProvideStore(sqlStore, cfg, featuremgmt.WithFeatures())
|
||||
publicdashboardStore = ProvideStore(sqlStore.DB(), cfg, featuremgmt.WithFeatures())
|
||||
savedDashboard = insertTestDashboard(t, dashboardStore, "testDashie", 1, "", false)
|
||||
savedDashboard2 = insertTestDashboard(t, dashboardStore, "testDashie2", 1, "", false)
|
||||
savedDashboard3 = insertTestDashboard(t, dashboardStore, "testDashie3", 2, "", false)
|
||||
|
||||
Reference in New Issue
Block a user