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

Function TestFileList_Add_Many

internal/caches/list_file_sqlite_test.go:80–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func TestFileList_Add_Many(t *testing.T) {
81 if !testutils.IsSingleTesting() {
82 return
83 }
84
85 var list = caches.NewSQLiteFileList(Tea.Root + "/data/cache-index/p1")
86
87 defer func() {
88 _ = list.Close()
89 }()
90
91 err := list.Init()
92 if err != nil {
93 t.Fatal(err)
94 }
95
96 var before = time.Now()
97 const offset = 0
98 const count = 1_000_000
99 for i := offset; i < offset+count; i++ {
100 u := "https://edge.teaos.cn/123456" + strconv.Itoa(i)
101 _ = list.Add(stringutil.Md5(u), &caches.Item{
102 Key: u,
103 ExpiresAt: time.Now().Unix() + 3600,
104 HeaderSize: 1,
105 MetaSize: 2,
106 BodySize: 3,
107 })
108 if err != nil {
109 t.Fatal(err)
110 }
111 if i > 0 && i%10_000 == 0 {
112 t.Log(i, int(10000/time.Since(before).Seconds()), "qps")
113 before = time.Now()
114 }
115 }
116 t.Log("ok")
117}
118
119func TestFileList_Exist(t *testing.T) {
120 if !testutils.IsSingleTesting() {

Callers

nothing calls this directly

Calls 7

IsSingleTestingFunction · 0.92
NewSQLiteFileListFunction · 0.92
UnixMethod · 0.80
LogMethod · 0.80
CloseMethod · 0.65
InitMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected