mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 23:32:30 +08:00

* Provisioning: Jobs: Define repository name field * Provisioning: Jobs: Separate options per job type * Provisioning: Define a sanitised settings resource * Provisioning: Jobs: Define a job summary * Provisioning: Remove linting * Provisioning: Update docs for a few fields * Provisioning: Remove HelloWorld * Provisioning: Replace Repository with Message in job info * Provisioning: Remove YAML support * Provisioning: Remove custom folder specification * Provisioning: Support read-only repositories * Provisioning: Remove edit options * Provisioning: Add sync options for repositories * Provisioning: Add resource statistics * Provisioning: Make slices atomic lists * Provisioning: Message list needs to exist even if empty If we don't do this, we can't clear the messages field, leading to buggy UX. * Provisioning: Support incremental syncing * Provisioning: Remove the 'items' subresource workaround * Provisioning: Add resource list * Provisioning: Reformat * Provisioning: Declare new types * OpenAPI: Generate openapi JSON spec from generated code * Codegen: Generate OpenAPI spec * Provisioning: Support generating frontend API * Codegen: Generate Go code * Provisioning: Define the base API * Codegen: Generate frontend endpoints for provisioning * Refactor: yarn prettier:write * Provisioning: Tiger team takes ownership * Chore: Remove dir we haven't added yet * Provisioning: Remove frontend * Test: Update example repositories
81 lines
1.9 KiB
Go
81 lines
1.9 KiB
Go
package apis
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
"k8s.io/apimachinery/pkg/util/version"
|
|
apimachineryversion "k8s.io/apimachinery/pkg/version"
|
|
|
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
|
"github.com/grafana/grafana/pkg/tests/testinfra"
|
|
"github.com/grafana/grafana/pkg/tests/testsuite"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
testsuite.Run(m)
|
|
}
|
|
|
|
func TestIntegrationOpenAPIs(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping integration test")
|
|
}
|
|
|
|
h := NewK8sTestHelper(t, testinfra.GrafanaOpts{
|
|
AppModeProduction: true,
|
|
EnableFeatureToggles: []string{
|
|
featuremgmt.FlagKubernetesFoldersServiceV2, // Will be default on by G12
|
|
featuremgmt.FlagQueryService, // Query Library
|
|
featuremgmt.FlagProvisioning,
|
|
},
|
|
})
|
|
|
|
t.Run("check valid version response", func(t *testing.T) {
|
|
disco := h.NewDiscoveryClient()
|
|
req := disco.RESTClient().Get().
|
|
Prefix("version").
|
|
SetHeader("Accept", "application/json")
|
|
|
|
result := req.Do(context.Background())
|
|
require.NoError(t, result.Error())
|
|
|
|
raw, err := result.Raw()
|
|
require.NoError(t, err)
|
|
info := apimachineryversion.Info{}
|
|
err = json.Unmarshal(raw, &info)
|
|
require.NoError(t, err)
|
|
|
|
// Make sure the gitVersion is parsable
|
|
v, err := version.Parse(info.GitVersion)
|
|
require.NoError(t, err)
|
|
require.Equal(t, info.Major, fmt.Sprintf("%d", v.Major()))
|
|
require.Equal(t, info.Minor, fmt.Sprintf("%d", v.Minor()))
|
|
})
|
|
|
|
dir := "openapi_snapshots"
|
|
|
|
var groups = []schema.GroupVersion{{
|
|
Group: "dashboard.grafana.app",
|
|
Version: "v0alpha1",
|
|
}, {
|
|
Group: "folder.grafana.app",
|
|
Version: "v0alpha1",
|
|
}, {
|
|
Group: "peakq.grafana.app",
|
|
Version: "v0alpha1",
|
|
}, {
|
|
Group: "iam.grafana.app",
|
|
Version: "v0alpha1",
|
|
}, {
|
|
Group: "provisioning.grafana.app",
|
|
Version: "v0alpha1",
|
|
}}
|
|
for _, gv := range groups {
|
|
VerifyOpenAPISnapshots(t, dir, gv, h)
|
|
}
|
|
}
|