@@ -20,7 +20,6 @@ import (
20
20
"google.golang.org/grpc"
21
21
22
22
"github.com/rudderlabs/keydb/client"
23
- "github.com/rudderlabs/keydb/internal/cache/badger"
24
23
"github.com/rudderlabs/keydb/internal/cloudstorage"
25
24
pb "github.com/rudderlabs/keydb/proto"
26
25
"github.com/rudderlabs/rudder-go-kit/config"
@@ -43,7 +42,7 @@ func TestSimple(t *testing.T) {
43
42
require .NoError (t , err )
44
43
pool .MaxWait = 1 * time .Minute
45
44
46
- run := func (t * testing.T , conf * config.Config , cf cacheFactory ) {
45
+ run := func (t * testing.T , conf * config.Config ) {
47
46
t .Parallel ()
48
47
49
48
_ , cloudStorage := getCloudStorage (t , pool , conf )
@@ -58,7 +57,7 @@ func TestSimple(t *testing.T) {
58
57
ClusterSize : 1 ,
59
58
TotalHashRanges : totalHashRanges ,
60
59
SnapshotInterval : 60 * time .Second ,
61
- }, cf )
60
+ }, conf )
62
61
c := getClient (t , totalHashRanges , node0Address )
63
62
64
63
// Test Put
@@ -82,7 +81,7 @@ func TestSimple(t *testing.T) {
82
81
ClusterSize : 1 ,
83
82
TotalHashRanges : totalHashRanges ,
84
83
SnapshotInterval : 60 * time .Second ,
85
- }, cf )
84
+ }, conf )
86
85
c = getClient (t , totalHashRanges , node0Address )
87
86
88
87
exists , err = c .Get (ctx , []string {"key1" , "key2" , "key3" , "key4" })
@@ -94,14 +93,13 @@ func TestSimple(t *testing.T) {
94
93
}
95
94
96
95
t .Run ("badger" , func (t * testing.T ) {
97
- conf := config .New ()
98
- run (t , conf , getBadgerCache (t , conf ))
96
+ run (t , config .New ())
99
97
})
100
98
101
99
t .Run ("badger compressed" , func (t * testing.T ) {
102
100
conf := config .New ()
103
101
conf .Set ("BadgerDB.Dedup.Compress" , true )
104
- run (t , conf , getBadgerCache ( t , conf ) )
102
+ run (t , conf )
105
103
})
106
104
}
107
105
@@ -110,7 +108,7 @@ func TestScaleUpAndDown(t *testing.T) {
110
108
require .NoError (t , err )
111
109
pool .MaxWait = 1 * time .Minute
112
110
113
- run := func (t * testing.T , conf * config.Config , cf cacheFactory ) {
111
+ run := func (t * testing.T , conf * config.Config ) {
114
112
minioClient , cloudStorage := getCloudStorage (t , pool , conf )
115
113
116
114
ctx , cancel := context .WithCancel (context .Background ())
@@ -123,7 +121,7 @@ func TestScaleUpAndDown(t *testing.T) {
123
121
ClusterSize : 1 ,
124
122
TotalHashRanges : totalHashRanges ,
125
123
SnapshotInterval : 60 * time .Second ,
126
- }, cf )
124
+ }, conf )
127
125
c := getClient (t , totalHashRanges , node0Address )
128
126
129
127
// Test Put
@@ -150,7 +148,7 @@ func TestScaleUpAndDown(t *testing.T) {
150
148
TotalHashRanges : totalHashRanges ,
151
149
SnapshotInterval : 60 * time .Second ,
152
150
Addresses : []string {node0Address },
153
- }, cf )
151
+ }, conf )
154
152
require .NoError (t , operator .Scale (ctx , node0Address , node1Address ))
155
153
require .NoError (t , operator .ScaleComplete (ctx ))
156
154
@@ -186,8 +184,7 @@ func TestScaleUpAndDown(t *testing.T) {
186
184
}
187
185
188
186
t .Run ("badger" , func (t * testing.T ) {
189
- conf := config .New ()
190
- run (t , conf , getBadgerCache (t , conf ))
187
+ run (t , config .New ())
191
188
})
192
189
}
193
190
@@ -196,7 +193,7 @@ func TestGetPutAddressBroadcast(t *testing.T) {
196
193
require .NoError (t , err )
197
194
pool .MaxWait = 1 * time .Minute
198
195
199
- run := func (t * testing.T , conf * config.Config , cf cacheFactory ) {
196
+ run := func (t * testing.T , conf * config.Config ) {
200
197
minioClient , cloudStorage := getCloudStorage (t , pool , conf )
201
198
202
199
ctx , cancel := context .WithCancel (context .Background ())
@@ -209,7 +206,7 @@ func TestGetPutAddressBroadcast(t *testing.T) {
209
206
ClusterSize : 1 ,
210
207
TotalHashRanges : totalHashRanges ,
211
208
SnapshotInterval : 60 * time .Second ,
212
- }, cf )
209
+ }, conf )
213
210
c := getClient (t , totalHashRanges , node0Address )
214
211
215
212
// Test Put
@@ -236,7 +233,7 @@ func TestGetPutAddressBroadcast(t *testing.T) {
236
233
TotalHashRanges : totalHashRanges ,
237
234
SnapshotInterval : 60 * time .Second ,
238
235
Addresses : []string {node0Address },
239
- }, cf )
236
+ }, conf )
240
237
require .NoError (t , operator .Scale (ctx , node0Address , node1Address ))
241
238
require .NoError (t , operator .ScaleComplete (ctx ))
242
239
@@ -253,7 +250,7 @@ func TestGetPutAddressBroadcast(t *testing.T) {
253
250
TotalHashRanges : totalHashRanges ,
254
251
SnapshotInterval : 60 * time .Second ,
255
252
Addresses : []string {node0Address , node1Address },
256
- }, cf )
253
+ }, conf )
257
254
require .NoError (t , operator .Scale (ctx , node0Address , node1Address , node2Address ))
258
255
require .NoError (t , operator .ScaleComplete (ctx ))
259
256
@@ -290,8 +287,7 @@ func TestGetPutAddressBroadcast(t *testing.T) {
290
287
}
291
288
292
289
t .Run ("badger" , func (t * testing.T ) {
293
- conf := config .New ()
294
- run (t , conf , getBadgerCache (t , conf ))
290
+ run (t , config .New ())
295
291
})
296
292
}
297
293
@@ -314,15 +310,8 @@ func getCloudStorage(t testing.TB, pool *dockertest.Pool, conf *config.Config) (
314
310
return minioClient , cloudStorage
315
311
}
316
312
317
- func getBadgerCache (t testing.TB , conf * config.Config ) cacheFactory {
318
- return func (_ uint32 ) (Cache , error ) {
319
- t .Helper ()
320
- return badger .New (t .TempDir (), conf , logger .NOP )
321
- }
322
- }
323
-
324
313
func getService (
325
- ctx context.Context , t testing.TB , cs cloudStorage , nodeConfig Config , cf cacheFactory ,
314
+ ctx context.Context , t testing.TB , cs cloudStorage , nodeConfig Config , conf * config. Config ,
326
315
) (* Service , string ) {
327
316
t .Helper ()
328
317
@@ -331,7 +320,7 @@ func getService(
331
320
address := "localhost:" + strconv .Itoa (freePort )
332
321
nodeConfig .Addresses = append (nodeConfig .Addresses , address )
333
322
334
- service , err := NewService (ctx , nodeConfig , cf , cs , stats .NOP , logger .NOP )
323
+ service , err := NewService (ctx , nodeConfig , cs , conf , stats .NOP , logger .NOP )
335
324
require .NoError (t , err )
336
325
337
326
// Create a gRPC server
0 commit comments