mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
K8s: Add dashboard service (requires dev mode) (#78565)
This commit is contained in:
114
pkg/tests/apis/dashboard/dashboards_test.go
Normal file
114
pkg/tests/apis/dashboard/dashboards_test.go
Normal file
@@ -0,0 +1,114 @@
|
||||
package dashboards
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
func TestRequiresDevMode(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
helper := apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{
|
||||
AppModeProduction: true, // should fail
|
||||
DisableAnonymous: true,
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagGrafanaAPIServer,
|
||||
featuremgmt.FlagGrafanaAPIServerWithExperimentalAPIs, // Required to start the example service
|
||||
},
|
||||
})
|
||||
|
||||
_, err := helper.NewDiscoveryClient().ServerResourcesForGroupVersion("dashboard.grafana.app/v0alpha1")
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestDashboardsApp(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
helper := apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{
|
||||
AppModeProduction: false, // required for experimental APIs
|
||||
DisableAnonymous: true,
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagGrafanaAPIServer,
|
||||
featuremgmt.FlagGrafanaAPIServerWithExperimentalAPIs, // Required to start the example service
|
||||
},
|
||||
})
|
||||
_, err := helper.NewDiscoveryClient().ServerResourcesForGroupVersion("dashboard.grafana.app/v0alpha1")
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("Check discovery client", func(t *testing.T) {
|
||||
disco := helper.GetGroupVersionInfoJSON("dashboard.grafana.app")
|
||||
// fmt.Printf("%s", string(disco))
|
||||
|
||||
require.JSONEq(t, `[
|
||||
{
|
||||
"freshness": "Current",
|
||||
"resources": [
|
||||
{
|
||||
"resource": "dashboards",
|
||||
"responseKind": {
|
||||
"group": "",
|
||||
"kind": "Dashboard",
|
||||
"version": ""
|
||||
},
|
||||
"scope": "Namespaced",
|
||||
"singularResource": "dashboard",
|
||||
"subresources": [
|
||||
{
|
||||
"responseKind": {
|
||||
"group": "",
|
||||
"kind": "DashboardAccessInfo",
|
||||
"version": ""
|
||||
},
|
||||
"subresource": "access",
|
||||
"verbs": [
|
||||
"get"
|
||||
]
|
||||
},
|
||||
{
|
||||
"responseKind": {
|
||||
"group": "",
|
||||
"kind": "DashboardVersionsInfo",
|
||||
"version": ""
|
||||
},
|
||||
"subresource": "versions",
|
||||
"verbs": [
|
||||
"get"
|
||||
]
|
||||
}
|
||||
],
|
||||
"verbs": [
|
||||
"create",
|
||||
"delete",
|
||||
"get",
|
||||
"list",
|
||||
"patch",
|
||||
"update"
|
||||
]
|
||||
},
|
||||
{
|
||||
"resource": "summary",
|
||||
"responseKind": {
|
||||
"group": "",
|
||||
"kind": "DashboardSummary",
|
||||
"version": ""
|
||||
},
|
||||
"scope": "Namespaced",
|
||||
"singularResource": "summary",
|
||||
"verbs": [
|
||||
"get",
|
||||
"list"
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": "v0alpha1"
|
||||
}
|
||||
]`, disco)
|
||||
})
|
||||
}
|
||||
6
pkg/tests/apis/dashboard/testdata/dashboard-generate.yaml
vendored
Normal file
6
pkg/tests/apis/dashboard/testdata/dashboard-generate.yaml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
apiVersion: dashboard.grafana.app/v0alpha1
|
||||
kind: Dashboard
|
||||
metadata:
|
||||
generateName: x # anything is ok here... except yes or true -- they become boolean!
|
||||
spec:
|
||||
title: Dashboard with auto generated UID ${NOW}
|
||||
6
pkg/tests/apis/dashboard/testdata/dashboard-test-apply.yaml
vendored
Normal file
6
pkg/tests/apis/dashboard/testdata/dashboard-test-apply.yaml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
apiVersion: dashboard.grafana.app/v0alpha1
|
||||
kind: Dashboard
|
||||
metadata:
|
||||
name: test
|
||||
spec:
|
||||
title: Test dashboard (apply from k8s; PATCH) X
|
||||
6
pkg/tests/apis/dashboard/testdata/dashboard-test-create.yaml
vendored
Normal file
6
pkg/tests/apis/dashboard/testdata/dashboard-test-create.yaml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
apiVersion: dashboard.grafana.app/v0alpha1
|
||||
kind: Dashboard
|
||||
metadata:
|
||||
name: test
|
||||
spec:
|
||||
title: Test dashboard (created from k8s; POST)
|
||||
6
pkg/tests/apis/dashboard/testdata/dashboard-test-replace.yaml
vendored
Normal file
6
pkg/tests/apis/dashboard/testdata/dashboard-test-replace.yaml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
apiVersion: dashboard.grafana.app/v0alpha1
|
||||
kind: Dashboard
|
||||
metadata:
|
||||
name: test
|
||||
spec:
|
||||
title: Test dashboard (replaced from k8s; PUT)
|
||||
Reference in New Issue
Block a user