Files
grafana/pkg/storage/unified/testing/storage_backend_test.go
T
Will Assis 873d35b494 unified-storage: sqlkv enable more tests (#116150)
* unified-storage: sqlkv enable more tests
2026-01-14 16:28:14 -05:00

69 lines
1.8 KiB
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"
"github.com/grafana/grafana/pkg/util/testutil"
)
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()
})
kvOpts := resource.KVBackendOptions{
KvStore: resource.NewBadgerKV(db),
}
backend, err := resource.NewKVStorageBackend(kvOpts)
require.NoError(t, err)
return backend
}, &TestOptions{
NSPrefix: "badgerkvstorage-test",
SkipTests: map[string]bool{
// TODO: fix these tests and remove this skip
TestBlobSupport: true,
TestListModifiedSince: true,
// Badger does not support bulk import yet.
TestGetResourceLastImportTime: true,
},
})
}
func TestIntegrationSQLKVStorageBackend(t *testing.T) {
testutil.SkipIntegrationTestInShortMode(t)
skipTests := map[string]bool{
TestBlobSupport: true,
TestListModifiedSince: true,
TestGetResourceLastImportTime: true,
}
t.Run("Without RvManager", func(t *testing.T) {
RunStorageBackendTest(t, func(ctx context.Context) resource.StorageBackend {
backend, _ := NewTestSqlKvBackend(t, ctx, false)
return backend
}, &TestOptions{
NSPrefix: "sqlkvstoragetest",
SkipTests: skipTests,
})
})
t.Run("With RvManager", func(t *testing.T) {
RunStorageBackendTest(t, func(ctx context.Context) resource.StorageBackend {
backend, _ := NewTestSqlKvBackend(t, ctx, true)
return backend
}, &TestOptions{
NSPrefix: "sqlkvstoragetest-rvmanager",
SkipTests: skipTests,
})
})
}