mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 14:42:16 +08:00

* add basic search backend integration tests * add search backend benchmark * add benchmark indexServer * fix * lint * add more tests * lint * do not use the poller * batch write * refactor and add tests * improvements * improvements * cleanup * only observe index success * add monitorIndexEvents method * nit use switch instead of if * make newIndexQueueProcessor private * simplify runProcessor * go lint
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package search
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
|
"github.com/grafana/grafana/pkg/storage/unified/resource"
|
|
unitest "github.com/grafana/grafana/pkg/storage/unified/testing"
|
|
)
|
|
|
|
func TestBleveSearchBackend(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping integration test")
|
|
}
|
|
|
|
// Run the search backend test suite
|
|
unitest.RunSearchBackendTest(t, func(ctx context.Context) resource.SearchBackend {
|
|
tempDir := t.TempDir()
|
|
|
|
// Create a new bleve backend
|
|
backend, err := NewBleveBackend(BleveOptions{
|
|
Root: tempDir,
|
|
FileThreshold: 5,
|
|
}, tracing.NewNoopTracerService(), featuremgmt.WithFeatures(featuremgmt.FlagUnifiedStorageSearchPermissionFiltering), nil)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, backend)
|
|
|
|
return backend
|
|
}, &unitest.TestOptions{
|
|
NSPrefix: "bleve-test",
|
|
})
|
|
}
|
|
|
|
func TestSearchBackendBenchmark(t *testing.T) {
|
|
opts := &unitest.BenchmarkOptions{
|
|
NumResources: 10000,
|
|
Concurrency: 1, // For now we only want to test the write throughput
|
|
NumNamespaces: 1,
|
|
NumGroups: 1,
|
|
NumResourceTypes: 1,
|
|
}
|
|
tempDir := t.TempDir()
|
|
|
|
// Create a new bleve backend
|
|
backend, err := NewBleveBackend(BleveOptions{
|
|
Root: tempDir,
|
|
}, tracing.NewNoopTracerService(), featuremgmt.WithFeatures(featuremgmt.FlagUnifiedStorageSearchPermissionFiltering), nil)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, backend)
|
|
|
|
unitest.BenchmarkSearchBackend(t, backend, opts)
|
|
}
|