Dashboard Restore: Remove experimental functionality under feature flag dashboardRestore for now - this will be reworked (#103204)

This commit is contained in:
Stephanie Hingtgen
2025-04-03 02:52:54 -05:00
committed by GitHub
parent db1f1c5df9
commit 4918d8720c
40 changed files with 61 additions and 1252 deletions
@@ -432,32 +432,6 @@ func Test_OnlyQueriesStatusFromGMSWhenRequired(t *testing.T) {
assert.Never(t, func() bool { return gmsClientMock.GetSnapshotStatusCallCount() > 2 }, time.Second, 10*time.Millisecond)
}
func Test_DeletedDashboardsNotMigrated(t *testing.T) {
t.Parallel()
s := setUpServiceTest(t, false).(*Service)
// modify what the mock returns for just this test case
dashMock := s.dashboardService.(*dashboards.FakeDashboardService)
dashMock.On("GetAllDashboardsByOrgId", mock.Anything, int64(1)).Return(
[]*dashboards.Dashboard{
{UID: "1", OrgID: 1, Data: simplejson.New()},
{UID: "2", OrgID: 1, Data: simplejson.New(), Deleted: time.Now()},
},
nil,
)
data, err := s.getMigrationDataJSON(context.TODO(), &user.SignedInUser{OrgID: 1})
assert.NoError(t, err)
dashCount := 0
for _, it := range data.Items {
if it.Type == cloudmigration.DashboardDataType {
dashCount++
}
}
assert.Equal(t, 1, dashCount)
}
// Implementation inspired by ChatGPT, OpenAI's language model.
func Test_SortFolders(t *testing.T) {
folders := []folder.CreateFolderCommand{
@@ -932,14 +906,12 @@ func setUpServiceTest(t *testing.T, withDashboardMock bool, cfgOverrides ...conf
featureToggles := featuremgmt.WithFeatures(
featuremgmt.FlagOnPremToCloudMigrations,
featuremgmt.FlagDashboardRestore, // needed for skipping creating soft-deleted dashboards in the snapshot.
)
sqlStore := sqlstore.NewTestStore(t,
sqlstore.WithCfg(cfg),
sqlstore.WithFeatureFlags(
featuremgmt.FlagOnPremToCloudMigrations,
featuremgmt.FlagDashboardRestore, // needed for skipping creating soft-deleted dashboards in the snapshot.
),
)
@@ -24,7 +24,6 @@ import (
"github.com/grafana/grafana/pkg/services/cloudmigration"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/folder"
libraryelements "github.com/grafana/grafana/pkg/services/libraryelements/model"
"github.com/grafana/grafana/pkg/services/org"
@@ -318,15 +317,10 @@ func (s *Service) getDashboardAndFolderCommands(ctx context.Context, signedInUse
dashboardCmds := make([]dashboards.Dashboard, 0)
folderUids := make([]string, 0)
softDeleteEnabled := s.features.IsEnabledGlobally(featuremgmt.FlagDashboardRestore)
// Folders need to be fetched by UID in a separate step, separate dashboards from folders
// If any result is in the trash bin, don't migrate it
for _, d := range dashs {
if softDeleteEnabled && !d.Deleted.IsZero() {
continue
}
if d.IsFolder {
folderUids = append(folderUids, d.UID)
} else {