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

Function TestKVTask_Add_Many

internal/metrics/task_kv_test.go:89–124  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

87}
88
89func TestKVTask_Add_Many(t *testing.T) {
90 if !testutils.IsSingleTesting() {
91 return
92 }
93
94 var task = metrics.NewKVTask(&serverconfigs.MetricItemConfig{
95 Id: 1,
96 IsOn: false,
97 Category: "",
98 Period: 1,
99 PeriodUnit: serverconfigs.MetricItemPeriodUnitDay,
100 Keys: []string{"${remoteAddr}"},
101 Value: "${countRequest}",
102 Version: 1,
103 })
104 err := task.Init()
105 if err != nil {
106 t.Fatal(err)
107 }
108 err = task.Start()
109 if err != nil {
110 t.Fatal(err)
111 }
112 defer func() {
113 _ = task.Stop()
114 }()
115
116 for i := 0; i < 4_000_000; i++ {
117 task.Add(&testObj{
118 ip: fmt.Sprintf("%d.%d.%d.%d", rands.Int(0, 255), rands.Int(0, 255), rands.Int(0, 255), rands.Int(0, 255)),
119 })
120 if i%10000 == 0 {
121 time.Sleep(1 * time.Second)
122 }
123 }
124}
125
126func TestKVTask_InsertStat(t *testing.T) {
127 var item = &serverconfigs.MetricItemConfig{

Callers

nothing calls this directly

Calls 6

IsSingleTestingFunction · 0.92
NewKVTaskFunction · 0.92
InitMethod · 0.65
StartMethod · 0.65
StopMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected