From 333d24f71bde315299d02ff47bfb4324b5af6298 Mon Sep 17 00:00:00 2001 From: QianyongXu <13038089398@163.com> Date: Thu, 24 Oct 2024 19:11:44 -0700 Subject: [PATCH] update file trigger and resolve licenses --- licenses/LICENSE_OF_ILOGTAIL_DEPENDENCIES.md | 10 ++++++++++ test/engine/trigger/file.go | 19 ++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/licenses/LICENSE_OF_ILOGTAIL_DEPENDENCIES.md b/licenses/LICENSE_OF_ILOGTAIL_DEPENDENCIES.md index e0b2d8fa91..f8814a01d8 100644 --- a/licenses/LICENSE_OF_ILOGTAIL_DEPENDENCIES.md +++ b/licenses/LICENSE_OF_ILOGTAIL_DEPENDENCIES.md @@ -101,6 +101,8 @@ When distributed in a binary form, iLogtail may contain portions of the followin - [github.com/golang/groupcache](https://pkg.go.dev/github.com/golang/groupcache?tab=licenses) - [sigs.k8s.io/controller-runtime](https://pkg.go.dev/sigs.k8s.io/controller-runtime?tab=licenses) - [github.com/iLogtail/VictoriaMetrics fork from github.com/VictoriaMetrics/VictoriaMetrics](http://github.com/iLogtail/VictoriaMetrics) based on Apache-2.0 +- [cloud.google.com/go/compute/metadata](https://pkg.go.dev/cloud.google.com/go/compute/metadata?tab=licenses) +- [github.com/VictoriaMetrics/metricsql](https://pkg.go.dev/github.com/VictoriaMetrics/metricsql?tab=licenses) ## BSD licenses @@ -229,6 +231,13 @@ When distributed in a binary form, iLogtail may contain portions of the followin - [github.com/stretchr/testify](https://pkg.go.dev/github.com/stretchr/testify?tab=licenses) - [go.uber.org/goleak](https://pkg.go.dev/go.uber.org/goleak?tab=licenses) - [github.com/influxdata/telegraf](https://pkg.go.dev/github.com/influxdata/telegraf?tab=licenses) +- [github.com/valyala/fastjson](https://pkg.go.dev/github.com/valyala/fastjson?tab=licenses) +- [github.com/valyala/fastrand](https://pkg.go.dev/github.com/valyala/fastrand?tab=licenses) +- [github.com/valyala/fasttemplate](https://pkg.go.dev/github.com/valyala/fasttemplate?tab=licenses) +- [github.com/valyala/gozstd](https://pkg.go.dev/github.com/valyala/gozstd?tab=licenses) +- [github.com/valyala/histogram](https://pkg.go.dev/github.com/valyala/histogram?tab=licenses) +- [github.com/valyala/quicktemplate](https://pkg.go.dev/github.com/valyala/quicktemplate?tab=licenses) +- [github.com/VictoriaMetrics/fasthttp](https://pkg.go.dev/github.com/VictoriaMetrics/fasthttp?tab=licenses) ## ISC licenses @@ -254,3 +263,4 @@ When distributed in a binary form, iLogtail may contain portions of the followin - [github.com/iLogtail/pyroscope-lib fork from github.com/pyroscope-io/pyroscope](http://github.com/iLogtail/pyroscope-lib) based on Apache-2.0 - [github.com/iLogtail/gonvml fork from github.com/mindprince/gonvml](https://github.com/iLogtail/gonvml) based on Apache-2.0 - [github.com/iLogtail/handy fork from github.com/streadway/handy](http://github.com/iLogtail/handy) based on BSD-2-Clause +- [github.com/iLogtail/metrics fork from github.com/VictoriaMetrics/metrics](http://github.com/iLogtail/metrics) based on MIT diff --git a/test/engine/trigger/file.go b/test/engine/trigger/file.go index 373aebbe52..69659460db 100644 --- a/test/engine/trigger/file.go +++ b/test/engine/trigger/file.go @@ -8,8 +8,6 @@ import ( "path/filepath" "time" - "golang.org/x/time/rate" - "github.com/alibaba/ilogtail/test/config" ) @@ -24,30 +22,29 @@ func GenerateRandomNginxLogToFile(ctx context.Context, speed, totalTime int, pat file, _ := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600) // #nosec G304 rand.Seed(time.Now().UnixNano()) - maxLogLen := 1024 nginxLog := genNginxLog() - limiter := rate.NewLimiter(rate.Limit(speed*1024*1024), maxLogLen) - timeout := time.After(time.Minute * time.Duration(totalTime)) + timePre := time.Now() + var bytes int64 = 0 + for { select { - // context is done - case <-ctx.Done(): - // clear file - _ = file.Close() - return ctx, nil // all time is done case <-timeout: // clear file _ = file.Close() return ctx, nil default: - if limiter.AllowN(time.Now(), len(nginxLog)) { + timeNow := time.Now() + bytes += int64(timeNow.Sub(timePre).Microseconds() * int64(speed)) + for bytes > int64(len(nginxLog)) { _, _ = file.WriteString(nginxLog + "\n") // #nosec G307 + bytes -= int64(len(nginxLog)) nginxLog = genNginxLog() } + timePre = timeNow } } }