Unified Storage Indexer: Add integration tests (#95687)

* indexer integration tests WIP

* make protobuf

* Adds a few more integration test cases to cover the basics. Use Limit instead of Size param from SearchRequest.

* skip if testing.Short()

* adds test comments
This commit is contained in:
owensmallwood
2024-11-01 07:58:10 -06:00
committed by GitHub
parent c548a2357b
commit 0eb7b755e2
10 changed files with 425 additions and 638 deletions
@@ -29,11 +29,13 @@ func TestMain(m *testing.M) {
testsuite.Run(m)
}
func newServer(t *testing.T) (sql.Backend, resource.ResourceServer) {
func newServer(t *testing.T, cfg *setting.Cfg) (sql.Backend, resource.ResourceServer) {
t.Helper()
if cfg == nil {
cfg = setting.NewCfg()
}
dbstore := infraDB.InitTestDB(t)
cfg := setting.NewCfg()
eDB, err := dbimpl.ProvideResourceDB(dbstore, cfg, nil)
require.NoError(t, err)
@@ -52,6 +54,7 @@ func newServer(t *testing.T) (sql.Backend, resource.ResourceServer) {
Backend: ret,
Diagnostics: ret,
Lifecycle: ret,
Index: resource.NewResourceIndexServer(cfg, tracing.NewNoopTracerService()),
})
require.NoError(t, err)
require.NotNil(t, server)
@@ -76,7 +79,7 @@ func TestIntegrationBackendHappyPath(t *testing.T) {
IsGrafanaAdmin: true, // can do anything
}
ctx := identity.WithRequester(context.Background(), testUserA)
backend, server := newServer(t)
backend, server := newServer(t, nil)
stream, err := backend.WatchWriteEvents(context.Background()) // Using a different context to avoid canceling the stream after the DefaultContextTimeout
require.NoError(t, err)
@@ -179,7 +182,7 @@ func TestIntegrationBackendWatchWriteEventsFromLastest(t *testing.T) {
}
ctx := testutil.NewTestContext(t, time.Now().Add(5*time.Second))
backend, _ := newServer(t)
backend, _ := newServer(t, nil)
// Create a few resources before initing the watch
_, err := writeEvent(ctx, backend, "item1", resource.WatchEvent_ADDED)
@@ -204,7 +207,7 @@ func TestIntegrationBackendList(t *testing.T) {
}
ctx := testutil.NewTestContext(t, time.Now().Add(5*time.Second))
backend, server := newServer(t)
backend, server := newServer(t, nil)
// Create a few resources before starting the watch
rv1, _ := writeEvent(ctx, backend, "item1", resource.WatchEvent_ADDED)