MCPcopy
hub / github.com/olric-data/olric / TestIntegration_DMap_Cache_Eviction_LRU_MaxInuse

Function TestIntegration_DMap_Cache_Eviction_LRU_MaxInuse

integration_test.go:308–356  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

306}
307
308func TestIntegration_DMap_Cache_Eviction_LRU_MaxInuse(t *testing.T) {
309 maxKeys := 100000
310 newConfig := func() *config.Config {
311 c := config.New("local")
312 c.PartitionCount = config.DefaultPartitionCount
313 c.ReplicaCount = 1
314 c.WriteQuorum = 1
315 c.ReadQuorum = 1
316 c.LogOutput = io.Discard
317 c.DMaps.MaxInuse = 100 // bytes
318 c.DMaps.EvictionPolicy = "LRU"
319 require.NoError(t, c.Sanitize())
320 require.NoError(t, c.Validate())
321 return c
322 }
323
324 cluster := newTestOlricCluster(t)
325
326 db := cluster.addMemberWithConfig(t, newConfig())
327
328 ctx := context.Background()
329 c, err := NewClusterClient([]string{db.name})
330 require.NoError(t, err)
331 defer func() {
332 require.NoError(t, c.Close(ctx))
333 }()
334
335 dm, err := c.NewDMap("mydmap")
336 require.NoError(t, err)
337
338 for i := 0; i < maxKeys; i++ {
339 err = dm.Put(ctx, fmt.Sprintf("mykey-%d", i), "myvalue")
340 require.NoError(t, err)
341 }
342
343 <-time.After(250 * time.Millisecond)
344
345 var total int
346
347 for i := 0; i < maxKeys; i++ {
348 _, err = dm.Get(ctx, fmt.Sprintf("mykey-%d", i))
349 if err == ErrKeyNotFound {
350 err = nil
351 total++
352 }
353 require.NoError(t, err)
354 }
355 require.Greater(t, total, 0)
356}
357
358func TestIntegration_Kill_Nodes_During_Operation(t *testing.T) {
359 newConfig := func() *config.Config {

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
NewDMapMethod · 0.95
PutMethod · 0.95
GetMethod · 0.95
NewFunction · 0.92
newTestOlricClusterFunction · 0.85
NewClusterClientFunction · 0.85
addMemberWithConfigMethod · 0.80
SanitizeMethod · 0.65
ValidateMethod · 0.65

Tested by

no test coverage detected