Folders: Add in mode3 tests (#111276)

This commit is contained in:
Stephanie Hingtgen 2025-09-17 19:33:52 -06:00 committed by GitHub
parent 60fbead3ac
commit 90371c16c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 27 additions and 19 deletions

View File

@ -45,13 +45,13 @@ func TestIntegrationFolderTree(t *testing.T) {
modes := []grafanarest.DualWriterMode{
// grafanarest.Mode1, (nothing new tested)
grafanarest.Mode2, // write both, read legacy
// grafanarest.Mode3, // write both, read unified
// grafanarest.Mode4,
// grafanarest.Mode5,
grafanarest.Mode3, // write both, read unified
grafanarest.Mode4,
grafanarest.Mode5,
}
for _, mode := range modes {
t.Run(fmt.Sprintf("mode %d", mode), func(t *testing.T) {
flags := []string{}
flags := []string{featuremgmt.FlagManagedDualWriter}
if mode >= grafanarest.Mode3 { // make sure modes 0-3 work without it
flags = append(flags, featuremgmt.FlagUnifiedStorageSearch)
}
@ -387,13 +387,15 @@ func getFoldersFromAPIServerList(t *testing.T, who apis.User) *FolderView {
require.NoError(t, err)
client := dyn.Resource(gvr).Namespace(ns)
result, err := client.List(context.Background(), v1.ListOptions{Limit: 1000})
lookup := map[string]*FolderView{}
continueToken := ""
for {
result, err := client.List(context.Background(), v1.ListOptions{Limit: 1000, Continue: continueToken})
if apierrors.IsForbidden(err) {
return &FolderView{} // empty list
}
require.NoError(t, err)
lookup := make(map[string]*FolderView, len(result.Items))
for _, hit := range result.Items {
obj, err := utils.MetaAccessor(&hit)
require.NoError(t, err)
@ -408,6 +410,12 @@ func getFoldersFromAPIServerList(t *testing.T, who apis.User) *FolderView {
}
}
continueToken = result.GetContinue()
if continueToken == "" {
break
}
}
return makeRoot(t, lookup, "folders/list")
}