OFREP: Enable with standard aggregation (#107349)

This commit is contained in:
Ryan McKinley
2025-07-01 09:17:36 -07:00
committed by GitHub
parent 73e2ead04b
commit 8b9e57f2f6
3 changed files with 250 additions and 25 deletions
+53
View File
@@ -0,0 +1,53 @@
package features
import (
"net/http"
"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 TestIntegrationFeatures(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
// Enable a random flag -- check that it is reported as enabled
flag := featuremgmt.FlagGrafanaAPIServerWithExperimentalAPIs
helper := apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{
AppModeProduction: true,
DisableAnonymous: false, // allow anon user
EnableFeatureToggles: []string{
flag, // used in test below
},
})
t.Run("Test evaluate flags", func(t *testing.T) {
rsp := apis.DoRequest(helper, apis.RequestParams{
Method: http.MethodPost,
Path: "/apis/features.grafana.app/v0alpha1/namespaces/default/ofrep/v1/evaluate/flags/" + flag,
User: helper.Org1.Admin,
}, &map[string]any{})
require.Equal(t, 200, rsp.Response.StatusCode)
require.JSONEq(t, `{
"Value": true,
"FlagKey": "`+flag+`",
"FlagType": 0,
"Variant": "enabled",
"Reason": "STATIC",
"ErrorCode": "",
"ErrorMessage": "",
"FlagMetadata": {}
}`, string(rsp.Body))
})
}