Revert read replica POC (#93551)

* Revert "chore: add replDB to team service (#91799)"

This reverts commit c6ae2d7999.

* Revert "experiment: use read replica for Get and Find Dashboards (#91706)"

This reverts commit 54177ca619.

* Revert "QuotaService: refactor to use ReplDB for Get queries (#91333)"

This reverts commit 299c142f6a.

* Revert "refactor replCfg to look more like plugins/plugin config (#91142)"

This reverts commit ac0b4bb34d.

* Revert "chore (replstore): fix registration with multiple sql drivers, again (#90990)"

This reverts commit daedb358dd.

* Revert "Chore (sqlstore): add validation and testing for repl config (#90683)"

This reverts commit af19f039b6.

* Revert "ReplStore: Add support for round robin load balancing between multiple read replicas (#90530)"

This reverts commit 27b52b1507.

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

This reverts commit 8a6107cd35.

* Revert "accesscontrol service read replica (#89963)"

This reverts commit 77a4869fca.

* Revert "Fix: add mapping for the new mysqlRepl driver (#89551)"

This reverts commit ab5a079bcc.

* Revert "fix: sql instrumentation dual registration error (#89508)"

This reverts commit d988f5c3b0.

* Revert "Experimental Feature Toggle: databaseReadReplica (#89232)"

This reverts commit 50244ed4a1.
This commit is contained in:
Jeff Levin
2024-09-25 15:21:39 -08:00
committed by GitHub
parent 25ca760ee1
commit a21a232a8e
88 changed files with 416 additions and 1010 deletions
@@ -39,17 +39,17 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
t.Skip("skipping integration test")
}
t.Run("Testing DB", func(t *testing.T) {
var sqlStore db.ReplDB
var sqlStore db.DB
var cfg *setting.Cfg
var flder, dashInRoot, childDash *dashboards.Dashboard
var currentUser *user.SignedInUser
var dashboardStore dashboards.Store
setup := func() {
sqlStore, cfg = db.InitTestReplDBWithCfg(t)
sqlStore, cfg = db.InitTestDBWithCfg(t)
quotaService := quotatest.New(false, nil)
var err error
dashboardStore, err = ProvideDashboardStore(sqlStore, cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore.DB()), quotaService)
dashboardStore, err = ProvideDashboardStore(sqlStore, cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore), quotaService)
require.NoError(t, err)
flder = insertTestDashboard(t, dashboardStore, "1 test dash folder", 1, 0, "", true, "prod", "webapp")
dashInRoot = insertTestDashboard(t, dashboardStore, "test dash 67", 1, 0, "", false, "prod", "webapp")
@@ -68,7 +68,7 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
t.Run("and user can read folders and dashboards", func(t *testing.T) {
currentUser.Permissions = map[int64]map[string][]string{1: {dashboards.ActionDashboardsRead: []string{dashboards.ScopeDashboardsAll},
dashboards.ActionFoldersRead: []string{dashboards.ScopeFoldersAll}}}
actest.AddUserPermissionToDB(t, sqlStore.DB(), currentUser)
actest.AddUserPermissionToDB(t, sqlStore, currentUser)
t.Run("should return all dashboards and folders", func(t *testing.T) {
query := &dashboards.FindPersistedDashboardsQuery{
@@ -86,7 +86,7 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
t.Run("and user can only read dashboards", func(t *testing.T) {
currentUser.Permissions = map[int64]map[string][]string{1: {dashboards.ActionDashboardsRead: []string{dashboards.ScopeDashboardsAll}}}
actest.AddUserPermissionToDB(t, sqlStore.DB(), currentUser)
actest.AddUserPermissionToDB(t, sqlStore, currentUser)
t.Run("should not return folder", func(t *testing.T) {
query := &dashboards.FindPersistedDashboardsQuery{
@@ -104,7 +104,7 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
t.Run("and permissions are set for dashboard child and folder has all permissions removed", func(t *testing.T) {
currentUser.Permissions = map[int64]map[string][]string{1: {dashboards.ActionDashboardsRead: {dashboards.ScopeDashboardsProvider.GetResourceScopeUID(dashInRoot.UID)}}}
actest.AddUserPermissionToDB(t, sqlStore.DB(), currentUser)
actest.AddUserPermissionToDB(t, sqlStore, currentUser)
t.Run("should not return folder or child", func(t *testing.T) {
query := &dashboards.FindPersistedDashboardsQuery{
@@ -119,7 +119,7 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
t.Run("when the user is given permission to child", func(t *testing.T) {
currentUser.Permissions = map[int64]map[string][]string{1: {dashboards.ActionDashboardsRead: {dashboards.ScopeDashboardsAll}}}
actest.AddUserPermissionToDB(t, sqlStore.DB(), currentUser)
actest.AddUserPermissionToDB(t, sqlStore, currentUser)
t.Run("should be able to search for child dashboard but not folder", func(t *testing.T) {
query := &dashboards.FindPersistedDashboardsQuery{
@@ -138,17 +138,17 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
})
t.Run("Given two dashboard folders with one dashboard each and one dashboard in the root folder", func(t *testing.T) {
var sqlStore db.ReplDB
var sqlStore db.DB
var cfg *setting.Cfg
var folder1, folder2, dashInRoot, childDash1, childDash2 *dashboards.Dashboard
var rootFolderId int64 = 0
var currentUser *user.SignedInUser
setup2 := func() {
sqlStore, cfg = db.InitTestReplDBWithCfg(t)
sqlStore, cfg = db.InitTestDBWithCfg(t)
quotaService := quotatest.New(false, nil)
var err error
dashboardStore, err = ProvideDashboardStore(sqlStore, cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore.DB()), quotaService)
dashboardStore, err = ProvideDashboardStore(sqlStore, cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore), quotaService)
require.NoError(t, err)
folder1 = insertTestDashboard(t, dashboardStore, "1 test dash folder", 1, 0, "", true, "prod")
folder2 = insertTestDashboard(t, dashboardStore, "2 test dash folder", 1, 0, "", true, "prod")
@@ -166,7 +166,7 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
setup2()
t.Run("and one folder is expanded, the other collapsed", func(t *testing.T) {
currentUser.Permissions = map[int64]map[string][]string{1: {dashboards.ActionDashboardsRead: {dashboards.ScopeDashboardsAll}, dashboards.ActionFoldersRead: []string{dashboards.ScopeFoldersAll}}}
actest.AddUserPermissionToDB(t, sqlStore.DB(), currentUser)
actest.AddUserPermissionToDB(t, sqlStore, currentUser)
t.Run("should return dashboards in root and expanded folder", func(t *testing.T) {
query := &dashboards.FindPersistedDashboardsQuery{
@@ -191,7 +191,7 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
t.Run("and a dashboard is moved from folder without acl to the folder with an acl", func(t *testing.T) {
moveDashboard(t, dashboardStore, 1, childDash2.Data, folder1.ID, folder1.UID)
currentUser.Permissions = map[int64]map[string][]string{1: {dashboards.ActionDashboardsRead: {dashboards.ScopeFoldersProvider.GetResourceScopeUID(folder2.UID), dashboards.ScopeDashboardsProvider.GetResourceScopeUID(dashInRoot.UID)}}}
actest.AddUserPermissionToDB(t, sqlStore.DB(), currentUser)
actest.AddUserPermissionToDB(t, sqlStore, currentUser)
t.Run("should not return folder with acl or its children", func(t *testing.T) {
query := &dashboards.FindPersistedDashboardsQuery{
@@ -210,7 +210,7 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
setup2()
moveDashboard(t, dashboardStore, 1, childDash1.Data, folder2.ID, childDash2.FolderUID)
currentUser.Permissions = map[int64]map[string][]string{1: {dashboards.ActionDashboardsRead: {dashboards.ScopeDashboardsProvider.GetResourceScopeUID(dashInRoot.UID), dashboards.ScopeFoldersProvider.GetResourceScopeUID(folder2.UID)}, dashboards.ActionFoldersRead: {dashboards.ScopeFoldersProvider.GetResourceScopeUID(folder2.UID)}}}
actest.AddUserPermissionToDB(t, sqlStore.DB(), currentUser)
actest.AddUserPermissionToDB(t, sqlStore, currentUser)
t.Run("should return folder without acl and its children", func(t *testing.T) {
query := &dashboards.FindPersistedDashboardsQuery{
@@ -240,7 +240,7 @@ func TestIntegrationDashboardInheritedFolderRBAC(t *testing.T) {
// the maximux nested folder hierarchy starting from parent down to subfolders
nestedFolders := make([]*folder.Folder, 0, folder.MaxNestedFolderDepth+1)
var sqlStore db.ReplDB
var sqlStore db.DB
var cfg *setting.Cfg
const (
dashInRootTitle = "dashboard in root"
@@ -250,7 +250,7 @@ func TestIntegrationDashboardInheritedFolderRBAC(t *testing.T) {
var viewer *user.SignedInUser
setup := func() {
sqlStore, cfg = db.InitTestReplDBWithCfg(t)
sqlStore, cfg = db.InitTestDBWithCfg(t)
cfg.AutoAssignOrg = true
cfg.AutoAssignOrgId = 1
cfg.AutoAssignOrgRole = string(org.RoleViewer)
@@ -262,13 +262,13 @@ func TestIntegrationDashboardInheritedFolderRBAC(t *testing.T) {
features := featuremgmt.WithFeatures(featuremgmt.FlagNestedFolders)
var err error
dashboardWriteStore, err := ProvideDashboardStore(sqlStore, cfg, features, tagimpl.ProvideService(sqlStore.DB()), quotaService)
dashboardWriteStore, err := ProvideDashboardStore(sqlStore, cfg, features, tagimpl.ProvideService(sqlStore), quotaService)
require.NoError(t, err)
orgService, err := orgimpl.ProvideService(sqlStore.DB(), cfg, quotaService)
orgService, err := orgimpl.ProvideService(sqlStore, cfg, quotaService)
require.NoError(t, err)
usrSvc, err := userimpl.ProvideService(
sqlStore.DB(), orgService, cfg, nil, nil, tracer,
sqlStore, orgService, cfg, nil, nil, tracer,
quotaService, supportbundlestest.NewFakeBundleService(),
)
require.NoError(t, err)
@@ -303,7 +303,7 @@ func TestIntegrationDashboardInheritedFolderRBAC(t *testing.T) {
guardian.New = origNewGuardian
})
folderSvc := folderimpl.ProvideService(mock.New(), bus.ProvideBus(tracer), dashboardWriteStore, folderimpl.ProvideDashboardFolderStore(sqlStore.DB()), sqlStore.DB(), features, supportbundlestest.NewFakeBundleService(), nil, tracing.InitializeTracerForTest())
folderSvc := folderimpl.ProvideService(mock.New(), bus.ProvideBus(tracer), dashboardWriteStore, folderimpl.ProvideDashboardFolderStore(sqlStore), sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, tracing.InitializeTracerForTest())
parentUID := ""
for i := 0; ; i++ {
@@ -405,11 +405,11 @@ func TestIntegrationDashboardInheritedFolderRBAC(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
dashboardReadStore, err := ProvideDashboardStore(sqlStore, cfg, tc.features, tagimpl.ProvideService(sqlStore.DB()), quotatest.New(false, nil))
dashboardReadStore, err := ProvideDashboardStore(sqlStore, cfg, tc.features, tagimpl.ProvideService(sqlStore), quotatest.New(false, nil))
require.NoError(t, err)
viewer.Permissions = map[int64]map[string][]string{viewer.OrgID: tc.permissions}
actest.AddUserPermissionToDB(t, sqlStore.DB(), viewer)
actest.AddUserPermissionToDB(t, sqlStore, viewer)
query := &dashboards.FindPersistedDashboardsQuery{
SignedInUser: viewer,