mirror of https://github.com/grafana/grafana.git
K8s: Add basic peakq test w/ resource (#90026)
This commit is contained in:
parent
274bd08afc
commit
de06762852
|
@ -42,7 +42,7 @@ func TestIntegrationTestDatasource(t *testing.T) {
|
||||||
|
|
||||||
t.Run("Check discovery client", func(t *testing.T) {
|
t.Run("Check discovery client", func(t *testing.T) {
|
||||||
disco := helper.GetGroupVersionInfoJSON("testdata.datasource.grafana.app")
|
disco := helper.GetGroupVersionInfoJSON("testdata.datasource.grafana.app")
|
||||||
// fmt.Printf("%s", string(disco))
|
// fmt.Printf("%s", disco)
|
||||||
|
|
||||||
require.JSONEq(t, `[
|
require.JSONEq(t, `[
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package playlist
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"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"
|
||||||
|
"github.com/grafana/grafana/pkg/tests/testsuite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
testsuite.Run(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIntegrationFoldersApp(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.Skip("skipping integration test")
|
||||||
|
}
|
||||||
|
helper := apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{
|
||||||
|
AppModeProduction: false, // required for experimental APIs
|
||||||
|
EnableFeatureToggles: []string{
|
||||||
|
featuremgmt.FlagGrafanaAPIServerWithExperimentalAPIs, // Required to start the example service
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Check discovery client", func(t *testing.T) {
|
||||||
|
disco := helper.NewDiscoveryClient()
|
||||||
|
resources, err := disco.ServerResourcesForGroupVersion("peakq.grafana.app/v0alpha1")
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
v1Disco, err := json.MarshalIndent(resources, "", " ")
|
||||||
|
require.NoError(t, err)
|
||||||
|
//fmt.Printf("%s", string(v1Disco))
|
||||||
|
require.JSONEq(t, `{
|
||||||
|
"kind": "APIResourceList",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"groupVersion": "peakq.grafana.app/v0alpha1",
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"name": "querytemplates",
|
||||||
|
"singularName": "querytemplate",
|
||||||
|
"namespaced": true,
|
||||||
|
"kind": "QueryTemplate",
|
||||||
|
"verbs": [
|
||||||
|
"create",
|
||||||
|
"delete",
|
||||||
|
"deletecollection",
|
||||||
|
"get",
|
||||||
|
"list",
|
||||||
|
"patch",
|
||||||
|
"update",
|
||||||
|
"watch"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "querytemplates/render",
|
||||||
|
"singularName": "",
|
||||||
|
"namespaced": true,
|
||||||
|
"kind": "RenderedQuery",
|
||||||
|
"verbs": [
|
||||||
|
"get"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`, string(v1Disco))
|
||||||
|
})
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
apiVersion: peakq.grafana.app/v0alpha1
|
||||||
|
kind: QueryTemplate
|
||||||
|
metadata:
|
||||||
|
generateName: x # anything is ok here... except yes or true -- they become boolean!
|
||||||
|
spec:
|
||||||
|
title: Generated query template
|
||||||
|
description: A description from here
|
|
@ -47,7 +47,7 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||||
|
|
||||||
// The accepted verbs will change when dual write is enabled
|
// The accepted verbs will change when dual write is enabled
|
||||||
disco := h.GetGroupVersionInfoJSON("playlist.grafana.app")
|
disco := h.GetGroupVersionInfoJSON("playlist.grafana.app")
|
||||||
// fmt.Printf("%s", string(disco))
|
// fmt.Printf("%s", disco)
|
||||||
require.JSONEq(t, `[
|
require.JSONEq(t, `[
|
||||||
{
|
{
|
||||||
"version": "v0alpha1",
|
"version": "v0alpha1",
|
||||||
|
|
Loading…
Reference in New Issue