mirror of
https://github.com/grafana/grafana.git
synced 2025-09-16 16:13:00 +08:00

* WIP added ListSinceModified to StorageBackend interface * fix compile time check * Fix method name * Fix naming * fix the rest of the ListSinceModified names * Uses resource key without name field * get latest rv from resource_version. Update test. * adds moar tests * adds method stub for ListModifiedSince to other StorageBackend implementations * adds dummy impl to noop storage backend for ListModifiedSince * skip tests for badger kv backend for now * fixes tests and adds badgerkv impl for ListModifiedSince * add badger kv impl * adds test for new query * adds test data for new query * adds ListModifiedSince stub to mockStorageBackend * uncomment tests * refactors ListModifiedSince to return an iter.seq2 and handles deduplication. Updates tests. Updates query result sorting. * remove comments * remove folder from query (dont need it, yet?) * regen test queries * updates test * updates function comment * use resourcepb.ResourceKey instead of ModifiedResourceKey * wrap seq in single transaction. Rollback transaction after 30s if iterator never used. Only track last seen event. Formatting. * skip TestListModifiedSince for kv backend * use WatchEvent_Type for action type * remove redundant fields from order by clause and regen test data for query * remove redundant fields from order by clause and regen test data for query
31 lines
753 B
Go
31 lines
753 B
Go
package test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
badger "github.com/dgraph-io/badger/v4"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/grafana/grafana/pkg/storage/unified/resource"
|
|
)
|
|
|
|
func TestBadgerKVStorageBackend(t *testing.T) {
|
|
RunStorageBackendTest(t, func(ctx context.Context) resource.StorageBackend {
|
|
opts := badger.DefaultOptions("").WithInMemory(true).WithLogger(nil)
|
|
db, err := badger.Open(opts)
|
|
require.NoError(t, err)
|
|
t.Cleanup(func() {
|
|
_ = db.Close()
|
|
})
|
|
return resource.NewKvStorageBackend(resource.NewBadgerKV(db))
|
|
}, &TestOptions{
|
|
NSPrefix: "kvstorage-test",
|
|
SkipTests: map[string]bool{
|
|
// TODO: fix these tests and remove this skip
|
|
TestBlobSupport: true,
|
|
TestListModifiedSince: true,
|
|
},
|
|
})
|
|
}
|