unistore: replace CDK backend with KV store backend (again) (#113184)

* Reapply "unistore: replace CDK backend with KV store backend"" (#113132)

This reverts commit 7127b2538c.

* enable cluster scope
This commit is contained in:
Georges Chaudy
2025-11-04 00:33:36 +00:00
committed by GitHub
parent a06905e2d3
commit ddeb970b4d
9 changed files with 176 additions and 471 deletions
+12 -16
View File
@@ -4,20 +4,17 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"log/slog"
"net/http"
"os"
"strings"
"sync"
"testing"
"time"
badger "github.com/dgraph-io/badger/v4"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gocloud.dev/blob/fileblob"
"gocloud.dev/blob/memblob"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
authlib "github.com/grafana/authlib/types"
@@ -41,20 +38,19 @@ func TestSimpleServer(t *testing.T) {
}
ctx := authlib.WithAuthInfo(context.Background(), testUserA)
bucket := memblob.OpenBucket(nil)
if false {
tmp, err := os.MkdirTemp("", "xxx-*")
// Create in-memory BadgerDB for testing
db, err := badger.Open(badger.DefaultOptions("").
WithInMemory(true).
WithLogger(nil))
require.NoError(t, err)
defer func() {
err := db.Close()
require.NoError(t, err)
}()
bucket, err = fileblob.OpenBucket(tmp, &fileblob.Options{
CreateDir: true,
Metadata: fileblob.MetadataDontWrite, // skip
})
require.NoError(t, err)
fmt.Printf("ROOT: %s\n\n", tmp)
}
store, err := NewCDKBackend(ctx, CDKBackendOptions{
Bucket: bucket,
kv := NewBadgerKV(db)
store, err := NewKVStorageBackend(KVBackendOptions{
KvStore: kv,
})
require.NoError(t, err)