K8s/Folders: Fix tests for creating folders (#94192)
* Add feature toggle grafanaAPIServerTestingWithExperimentalAPIs * Customise registration of FolderAPIBuilder for tests and fix tests
This commit is contained in:
@@ -47,8 +47,8 @@ func RegisterAPIService(cfg *setting.Cfg,
|
||||
accessControl accesscontrol.AccessControl,
|
||||
registerer prometheus.Registerer,
|
||||
) *FolderAPIBuilder {
|
||||
if !features.IsEnabledGlobally(featuremgmt.FlagKubernetesFolders) {
|
||||
return nil // skip registration unless opting into Kubernetes folders
|
||||
if !features.IsEnabledGlobally(featuremgmt.FlagKubernetesFolders) && !features.IsEnabledGlobally(featuremgmt.FlagGrafanaAPIServerTestingWithExperimentalAPIs) {
|
||||
return nil // skip registration unless opting into Kubernetes folders or unless we want to customise registration when testing
|
||||
}
|
||||
|
||||
builder := &FolderAPIBuilder{
|
||||
|
||||
@@ -750,6 +750,12 @@ var (
|
||||
Stage: FeatureStageExperimental,
|
||||
Owner: grafanaSearchAndStorageSquad,
|
||||
},
|
||||
{
|
||||
Name: "grafanaAPIServerTestingWithExperimentalAPIs",
|
||||
Description: "Facilitate integration testing of experimental APIs",
|
||||
Stage: FeatureStageExperimental,
|
||||
Owner: grafanaSearchAndStorageSquad,
|
||||
},
|
||||
{
|
||||
Name: "datasourceQueryTypes",
|
||||
Description: "Show query type endpoints in datasource API servers (currently hardcoded for testdata, expressions, and prometheus)",
|
||||
|
||||
@@ -98,6 +98,7 @@ kubernetesPlaylists,GA,@grafana/grafana-app-platform-squad,false,true,false
|
||||
kubernetesSnapshots,experimental,@grafana/grafana-app-platform-squad,false,true,false
|
||||
kubernetesDashboards,experimental,@grafana/grafana-app-platform-squad,false,false,true
|
||||
kubernetesFolders,experimental,@grafana/search-and-storage,false,false,false
|
||||
grafanaAPIServerTestingWithExperimentalAPIs,experimental,@grafana/search-and-storage,false,false,false
|
||||
datasourceQueryTypes,experimental,@grafana/grafana-app-platform-squad,false,true,false
|
||||
queryService,experimental,@grafana/grafana-app-platform-squad,false,true,false
|
||||
queryServiceRewrite,experimental,@grafana/grafana-app-platform-squad,false,true,false
|
||||
|
||||
|
@@ -403,6 +403,10 @@ const (
|
||||
// Use the kubernetes API in the frontend for folders, and route /api/folders requests to k8s
|
||||
FlagKubernetesFolders = "kubernetesFolders"
|
||||
|
||||
// FlagGrafanaAPIServerTestingWithExperimentalAPIs
|
||||
// Facilitate integration testing of experimental APIs
|
||||
FlagGrafanaAPIServerTestingWithExperimentalAPIs = "grafanaAPIServerTestingWithExperimentalAPIs"
|
||||
|
||||
// FlagDatasourceQueryTypes
|
||||
// Show query type endpoints in datasource API servers (currently hardcoded for testdata, expressions, and prometheus)
|
||||
FlagDatasourceQueryTypes = "datasourceQueryTypes"
|
||||
|
||||
@@ -1384,6 +1384,18 @@
|
||||
"requiresRestart": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"name": "grafanaAPIServerTestingWithExperimentalAPIs",
|
||||
"resourceVersion": "1727945615419",
|
||||
"creationTimestamp": "2024-10-03T08:53:35Z"
|
||||
},
|
||||
"spec": {
|
||||
"description": "Facilitate integration testing of experimental APIs",
|
||||
"stage": "experimental",
|
||||
"codeowner": "@grafana/search-and-storage"
|
||||
}
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"name": "grafanaAPIServerWithExperimentalAPIs",
|
||||
|
||||
@@ -40,8 +40,10 @@ func TestIntegrationFoldersApp(t *testing.T) {
|
||||
helper := apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{
|
||||
AppModeProduction: true,
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesFolders,
|
||||
featuremgmt.FlagGrafanaAPIServerTestingWithExperimentalAPIs,
|
||||
},
|
||||
// Not including featuremgmt.FlagKubernetesFolders because we refer to the k8s client directly in doFolderTests().
|
||||
// This allows us to access the legacy api (which gets bypassed by featuremgmt.FlagKubernetesFolders).
|
||||
})
|
||||
|
||||
t.Run("Check discovery client", func(t *testing.T) {
|
||||
@@ -108,8 +110,10 @@ func TestIntegrationFoldersApp(t *testing.T) {
|
||||
AppModeProduction: true,
|
||||
DisableAnonymous: true,
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesFolders,
|
||||
featuremgmt.FlagGrafanaAPIServerTestingWithExperimentalAPIs,
|
||||
},
|
||||
// Not including featuremgmt.FlagKubernetesFolders because we refer to the k8s client directly in doFolderTests().
|
||||
// This allows us to access the legacy api (which gets bypassed by featuremgmt.FlagKubernetesFolders).
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -124,8 +128,10 @@ func TestIntegrationFoldersApp(t *testing.T) {
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesFolders,
|
||||
featuremgmt.FlagGrafanaAPIServerTestingWithExperimentalAPIs,
|
||||
},
|
||||
// Not including featuremgmt.FlagKubernetesFolders because we refer to the k8s client directly in doFolderTests().
|
||||
// This allows us to access the legacy api (which gets bypassed by featuremgmt.FlagKubernetesFolders).
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -140,8 +146,10 @@ func TestIntegrationFoldersApp(t *testing.T) {
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesFolders,
|
||||
featuremgmt.FlagGrafanaAPIServerTestingWithExperimentalAPIs,
|
||||
},
|
||||
// Not including featuremgmt.FlagKubernetesFolders because we refer to the k8s client directly in doFolderTests().
|
||||
// This allows us to access the legacy api (which gets bypassed by featuremgmt.FlagKubernetesFolders).
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -156,8 +164,10 @@ func TestIntegrationFoldersApp(t *testing.T) {
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesFolders,
|
||||
featuremgmt.FlagGrafanaAPIServerTestingWithExperimentalAPIs,
|
||||
},
|
||||
// Not including featuremgmt.FlagKubernetesFolders because we refer to the k8s client directly in doFolderTests().
|
||||
// This allows us to access the legacy api (which gets bypassed by featuremgmt.FlagKubernetesFolders).
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -172,8 +182,10 @@ func TestIntegrationFoldersApp(t *testing.T) {
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesFolders,
|
||||
featuremgmt.FlagGrafanaAPIServerTestingWithExperimentalAPIs,
|
||||
},
|
||||
// Not including featuremgmt.FlagKubernetesFolders because we refer to the k8s client directly in doFolderTests().
|
||||
// This allows us to access the legacy api (which gets bypassed by featuremgmt.FlagKubernetesFolders).
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -188,8 +200,10 @@ func TestIntegrationFoldersApp(t *testing.T) {
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesFolders,
|
||||
featuremgmt.FlagGrafanaAPIServerTestingWithExperimentalAPIs,
|
||||
},
|
||||
// Not including featuremgmt.FlagKubernetesFolders because we refer to the k8s client directly in doFolderTests().
|
||||
// This allows us to access the legacy api (which gets bypassed by featuremgmt.FlagKubernetesFolders).
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -204,8 +218,10 @@ func TestIntegrationFoldersApp(t *testing.T) {
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesFolders,
|
||||
featuremgmt.FlagGrafanaAPIServerTestingWithExperimentalAPIs,
|
||||
},
|
||||
// Not including featuremgmt.FlagKubernetesFolders because we refer to the k8s client directly in doFolderTests().
|
||||
// This allows us to access the legacy api (which gets bypassed by featuremgmt.FlagKubernetesFolders).
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -223,8 +239,10 @@ func TestIntegrationFoldersApp(t *testing.T) {
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesFolders,
|
||||
featuremgmt.FlagGrafanaAPIServerTestingWithExperimentalAPIs,
|
||||
},
|
||||
// Not including featuremgmt.FlagKubernetesFolders because we refer to the k8s client directly in doFolderTests().
|
||||
// This allows us to access the legacy api (which gets bypassed by featuremgmt.FlagKubernetesFolders).
|
||||
})
|
||||
|
||||
// Clear the collection before starting (etcd)
|
||||
@@ -252,8 +270,10 @@ func TestIntegrationFoldersApp(t *testing.T) {
|
||||
},
|
||||
},
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesFolders,
|
||||
featuremgmt.FlagGrafanaAPIServerTestingWithExperimentalAPIs,
|
||||
},
|
||||
// Not including featuremgmt.FlagKubernetesFolders because we refer to the k8s client directly in doFolderTests().
|
||||
// This allows us to access the legacy api (which gets bypassed by featuremgmt.FlagKubernetesFolders).
|
||||
})
|
||||
|
||||
// Clear the collection before starting (etcd)
|
||||
|
||||
Reference in New Issue
Block a user