mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-14 07:30:25 +08:00
增加服务带宽统计
This commit is contained in:
33
internal/stats/bandwidth_stat_manager_test.go
Normal file
33
internal/stats/bandwidth_stat_manager_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package stats_test
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/stats"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestBandwidthStatManager_Add(t *testing.T) {
|
||||
var manager = stats.NewBandwidthStatManager()
|
||||
manager.Add(1, 10)
|
||||
manager.Add(1, 10)
|
||||
manager.Add(1, 10)
|
||||
time.Sleep(1 * time.Second)
|
||||
manager.Add(1, 15)
|
||||
time.Sleep(1 * time.Second)
|
||||
manager.Add(1, 25)
|
||||
manager.Add(1, 75)
|
||||
manager.Inspect()
|
||||
}
|
||||
|
||||
func TestBandwidthStatManager_Loop(t *testing.T) {
|
||||
var manager = stats.NewBandwidthStatManager()
|
||||
manager.Add(1, 10)
|
||||
manager.Add(1, 10)
|
||||
manager.Add(1, 10)
|
||||
err := manager.Loop()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user