From eb4bb630e9d40a4b5fe4ae1396ce85ed37c6b413 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sun, 3 Dec 2023 14:55:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=93=E5=AD=98=E5=91=BD?= =?UTF-8?q?=E4=B8=AD=E7=8E=87=E7=BB=9F=E8=AE=A1=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/utils/cachehits/stat.go | 3 ++- internal/utils/cachehits/stat_test.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/utils/cachehits/stat.go b/internal/utils/cachehits/stat.go index ca37908..c15b06a 100644 --- a/internal/utils/cachehits/stat.go +++ b/internal/utils/cachehits/stat.go @@ -6,6 +6,7 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/goman" "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + "github.com/iwind/TeaGo/Tea" "sync" "sync/atomic" "time" @@ -138,7 +139,7 @@ func (this *Stat) IsGood(category string) bool { return true } - if item.countCached > countSamples && item.timestamp < fasttime.Now().Unix()-600 /** 10 minutes ago **/ { + if item.countCached > countSamples && (Tea.IsTesting() || item.timestamp < fasttime.Now().Unix()-600) /** 10 minutes ago **/ { var isGood = item.countHits*100/item.countCached >= this.goodRatio if isGood { item.isGood = true diff --git a/internal/utils/cachehits/stat_test.go b/internal/utils/cachehits/stat_test.go index e031051..8845f76 100644 --- a/internal/utils/cachehits/stat_test.go +++ b/internal/utils/cachehits/stat_test.go @@ -58,10 +58,10 @@ func TestNewStat(t *testing.T) { { var stat = cachehits.NewStat(5) - for i := 0; i < 10001; i++ { + for i := 0; i < 100001; i++ { stat.IncreaseCached("a") } - for i := 0; i < 499; i++ { + for i := 0; i < 4999; i++ { stat.IncreaseHit("a") }