mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
K8s/OpenAPI: Move openapi snapshots out of the root (#99728)
This commit is contained in:
parent
c7f83b7311
commit
8415059290
4
.github/CODEOWNERS
vendored
4
.github/CODEOWNERS
vendored
@ -731,10 +731,6 @@ embed.go @grafana/grafana-as-code
|
||||
/public/app/plugins/*gen.go @grafana/grafana-as-code
|
||||
/cue.mod/ @grafana/grafana-as-code
|
||||
|
||||
# Rendered OpenAPI from app platform
|
||||
# Eventually each file owned by the right team, OR a structure with the rendered value under /apis/{group}/openapi
|
||||
/openapi/ @grafana/grafana-app-platform-squad
|
||||
|
||||
# GitHub Workflows and Templates
|
||||
/.github/CODEOWNERS @tolzhabayev
|
||||
/.github/ISSUE_TEMPLATE/ @torkelo @sympatheticmoose
|
||||
|
@ -1,4 +1,4 @@
|
||||
package core
|
||||
package apis
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -18,7 +18,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/tests/apis"
|
||||
"github.com/grafana/grafana/pkg/tests/testinfra"
|
||||
"github.com/grafana/grafana/pkg/tests/testsuite"
|
||||
)
|
||||
@ -32,18 +31,7 @@ func TestIntegrationOpenAPIs(t *testing.T) {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
|
||||
check := []schema.GroupVersion{{
|
||||
Group: "dashboard.grafana.app",
|
||||
Version: "v0alpha1",
|
||||
}, {
|
||||
Group: "folder.grafana.app",
|
||||
Version: "v0alpha1",
|
||||
}, {
|
||||
Group: "peakq.grafana.app",
|
||||
Version: "v0alpha1",
|
||||
}}
|
||||
|
||||
h := apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{
|
||||
h := NewK8sTestHelper(t, testinfra.GrafanaOpts{
|
||||
AppModeProduction: true,
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagKubernetesFoldersServiceV2, // Will be default on by G12
|
||||
@ -73,16 +61,34 @@ func TestIntegrationOpenAPIs(t *testing.T) {
|
||||
require.Equal(t, info.Minor, fmt.Sprintf("%d", v.Minor()))
|
||||
})
|
||||
|
||||
t.Run("build open", func(t *testing.T) {
|
||||
// Now write each OpenAPI spec to a static file
|
||||
dir := filepath.Join("..", "..", "..", "..", "openapi")
|
||||
for _, gv := range check {
|
||||
dir := "openapi_snapshots"
|
||||
|
||||
for _, gv := range []schema.GroupVersion{{
|
||||
Group: "dashboard.grafana.app",
|
||||
Version: "v0alpha1",
|
||||
}, {
|
||||
Group: "folder.grafana.app",
|
||||
Version: "v0alpha1",
|
||||
}, {
|
||||
Group: "peakq.grafana.app",
|
||||
Version: "v0alpha1",
|
||||
}} {
|
||||
VerifyOpenAPISnapshots(t, dir, gv, h)
|
||||
}
|
||||
}
|
||||
|
||||
// This function should be moved to oss (it is now a duplicate)
|
||||
func VerifyOpenAPISnapshots(t *testing.T, dir string, gv schema.GroupVersion, h *K8sTestHelper) {
|
||||
if gv.Group == "" {
|
||||
return // skip invalid groups
|
||||
}
|
||||
path := fmt.Sprintf("/openapi/v3/apis/%s/%s", gv.Group, gv.Version)
|
||||
rsp := apis.DoRequest(h, apis.RequestParams{
|
||||
t.Run(path, func(t *testing.T) {
|
||||
rsp := DoRequest(h, RequestParams{
|
||||
Method: http.MethodGet,
|
||||
Path: path,
|
||||
User: h.Org1.Admin,
|
||||
}, &apis.AnyResource{})
|
||||
}, &AnyResource{})
|
||||
|
||||
require.NotNil(t, rsp.Response)
|
||||
require.Equal(t, 200, rsp.Response.StatusCode, path)
|
||||
@ -115,6 +121,5 @@ func TestIntegrationOpenAPIs(t *testing.T) {
|
||||
t.Errorf("error writing file: %s", e2.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user