Skip to content

Commit

Permalink
Add mode 0 dual writing to playlist integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
suntala committed May 31, 2024
1 parent e30e3a4 commit d5d74e3
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions pkg/tests/apis/playlist/playlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ func TestIntegrationPlaylist(t *testing.T) {
}))
})

t.Run("with dual write (file, mode 0)", 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.FlagKubernetesPlaylists, // Required so that legacy calls are also written
},
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
"playlist": grafanarest.Mode0,
},
}))
})

// #TODO Enable this test once we have fixed dual writing mode 1 behavior
// Do_CRUD_via_k8s_(and_check_that_legacy_api_still_works) breaks
// t.Run("with dual write (file, mode 1)", func(t *testing.T) {
Expand Down Expand Up @@ -116,6 +130,21 @@ func TestIntegrationPlaylist(t *testing.T) {
}))
})

t.Run("with dual write (unified storage, mode 0)", func(t *testing.T) {
doPlaylistTests(t, apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{
AppModeProduction: false, // required for unified storage
DisableAnonymous: true,
APIServerStorageType: "unified", // use the entity api tables
EnableFeatureToggles: []string{
featuremgmt.FlagUnifiedStorage,
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
},
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
"playlist": grafanarest.Mode0,
},
}))
})

// #TODO Enable this test once we have fixed dual writing mode 1 behavior
// Do_CRUD_via_k8s_(and_check_that_legacy_api_still_works) breaks
// t.Run("with dual write (unified storage, mode 1)", func(t *testing.T) {
Expand Down Expand Up @@ -148,6 +177,33 @@ func TestIntegrationPlaylist(t *testing.T) {
}))
})

t.Run("with dual write (etcd, mode 0)", func(t *testing.T) {
// NOTE: running local etcd, that will be wiped clean!
t.Skip("local etcd testing")

helper := apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{
AppModeProduction: true,
DisableAnonymous: true,
APIServerStorageType: "etcd", // requires etcd running on localhost:2379
EnableFeatureToggles: []string{
featuremgmt.FlagKubernetesPlaylists, // Required so that legacy calls are also written
},
DualWriterDesiredModes: map[string]grafanarest.DualWriterMode{
"playlist": grafanarest.Mode0,
},
})

// Clear the collection before starting (etcd)
client := helper.GetResourceClient(apis.ResourceClientArgs{
User: helper.Org1.Admin,
GVR: gvr,
})
err := client.Resource.DeleteCollection(context.Background(), metav1.DeleteOptions{}, metav1.ListOptions{})
require.NoError(t, err)

doPlaylistTests(t, helper)
})

t.Run("with dual write (etcd, mode 1)", func(t *testing.T) {
// NOTE: running local etcd, that will be wiped clean!
t.Skip("local etcd testing")
Expand Down

0 comments on commit d5d74e3

Please sign in to comment.