MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestIPList_GC

Function TestIPList_GC

internal/iplibrary/ip_list_test.go:368–395  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

366}
367
368func TestIPList_GC(t *testing.T) {
369 var a = assert.NewAssertion(t)
370
371 var list = iplibrary.NewIPList()
372 list.Add(&iplibrary.IPItem{
373 Id: 1,
374 IPFrom: iputils.ToBytes("192.168.1.100"),
375 IPTo: iputils.ToBytes("192.168.1.101"),
376 ExpiredAt: time.Now().Unix() + 1,
377 })
378 list.Add(&iplibrary.IPItem{
379 Id: 2,
380 IPFrom: iputils.ToBytes("192.168.1.102"),
381 IPTo: iputils.ToBytes("192.168.1.103"),
382 ExpiredAt: 0,
383 })
384 logs.PrintAsJSON(list.ItemsMap(), t)
385 logs.PrintAsJSON(list.AllItemsMap(), t)
386
387 time.Sleep(3 * time.Second)
388
389 t.Log("===AFTER GC===")
390 logs.PrintAsJSON(list.ItemsMap(), t)
391 logs.PrintAsJSON(list.SortedRangeItems(), t)
392
393 a.IsTrue(len(list.ItemsMap()) == 1)
394 a.IsTrue(len(list.SortedRangeItems()) == 1)
395}
396
397func TestManyLists(t *testing.T) {
398 debug.SetMaxThreads(20)

Callers

nothing calls this directly

Calls 7

NewIPListFunction · 0.92
UnixMethod · 0.80
AllItemsMapMethod · 0.80
LogMethod · 0.80
SortedRangeItemsMethod · 0.80
AddMethod · 0.65
ItemsMapMethod · 0.45

Tested by

no test coverage detected