K8s/Playlist: Test dual write path (#77604)

This commit is contained in:
Ryan McKinley
2023-11-15 00:07:32 +02:00
committed by GitHub
parent 19a7cd88b0
commit 2b1e731c15
5 changed files with 112 additions and 15 deletions
-1
View File
@@ -74,7 +74,6 @@ func NewK8sTestHelper(t *testing.T, opts testinfra.GrafanaOpts) *K8sTestHelper {
}
func (c *K8sTestHelper) Shutdown() {
fmt.Printf("calling shutdown on: %s\n", c.env.Server.HTTPServer.Listener.Addr())
err := c.env.Server.Shutdown(context.Background(), "done")
require.NoError(c.t, err)
}
+12
View File
@@ -75,6 +75,18 @@ func TestPlaylist(t *testing.T) {
},
}))
})
t.Run("with dual write", func(t *testing.T) {
doPlaylistTests(t, apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{
AppModeProduction: true,
DisableAnonymous: true,
APIServerStorageType: "file", // write the files to disk
EnableFeatureToggles: []string{
featuremgmt.FlagGrafanaAPIServer,
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
},
}))
})
}
func doPlaylistTests(t *testing.T, helper *apis.K8sTestHelper) *apis.K8sTestHelper {
+8
View File
@@ -342,6 +342,13 @@ func CreateGrafDir(t *testing.T, opts ...GrafanaOpts) (string, string) {
require.NoError(t, err)
}
if o.APIServerStorageType != "" {
section, err := getOrCreateSection("grafana-apiserver")
require.NoError(t, err)
_, err = section.NewKey("storage_type", o.APIServerStorageType)
require.NoError(t, err)
}
if o.GRPCServerAddress != "" {
logSection, err := getOrCreateSection("grpc_server")
require.NoError(t, err)
@@ -397,6 +404,7 @@ type GrafanaOpts struct {
EnableLog bool
GRPCServerAddress string
QueryRetries int64
APIServerStorageType string
}
func CreateUser(t *testing.T, store *sqlstore.SQLStore, cmd user.CreateUserCommand) *user.User {