Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Abingcbc committed Nov 7, 2024
1 parent b01c366 commit e143471
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/engine/trigger/ebpf/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func rwFile(ctx context.Context, commandCnt int, filenames string) error {
func mmapFile(ctx context.Context, commandCnt int, filenames string) error {
files := strings.Split(filenames, ",")
for _, file := range files {
mmapFileCommand := trigger.GetRunTriggerCommand("mmap", "commandCnt", strconv.FormatInt(int64(commandCnt), 10), "filename", file)
mmapFileCommand := trigger.GetRunTriggerCommand("ebpf", "mmap", "commandCnt", strconv.FormatInt(int64(commandCnt), 10), "filename", file)
if _, err := setup.Env.ExecOnSource(ctx, mmapFileCommand); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions test/engine/trigger/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ import (
"github.com/alibaba/ilogtail/test/config"
)

const commandTemplate = "python3 %s.py %s"
const commandTemplate = "python3 remote_%s.py %s"

func BeginTrigger(ctx context.Context) (context.Context, error) {
startTime := time.Now().Unix()
return context.WithValue(ctx, config.StartTimeContextKey, int32(startTime)), nil
}

func GetRunTriggerCommand(triggerName string, kvs ...string) string {
func GetRunTriggerCommand(scenrio, triggerName string, kvs ...string) string {
args := make([]string, 0)
for i := 0; i < len(kvs); i += 2 {
args = append(args, fmt.Sprintf("--%s", kvs[i]), kvs[i+1])
}
return fmt.Sprintf(commandTemplate, filepath.Join(config.TestConfig.WorkDir, "engine", "trigger", "remote", triggerName), strings.Join(args, " "))
return fmt.Sprintf(commandTemplate, filepath.Join(config.TestConfig.WorkDir, "engine", "trigger", scenrio, triggerName), strings.Join(args, " "))
}
13 changes: 8 additions & 5 deletions test/engine/trigger/log/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package log

import (
"context"
"fmt"
"strconv"
"time"

Expand Down Expand Up @@ -61,17 +62,19 @@ func Nginx(ctx context.Context, rate, duration int, path string) (context.Contex
func generate(ctx context.Context, mode, path string, count, interval int, customKV ...string) (context.Context, error) {
time.Sleep(3 * time.Second)
customKV = append(customKV, "mode", mode, "path", path, "count", strconv.Itoa(count), "interval", strconv.Itoa(interval))
command := trigger.GetRunTriggerCommand("log", customKV...)
if _, err := setup.Env.ExecOnSource(ctx, command); err != nil {
return ctx, err
}
command := trigger.GetRunTriggerCommand("log", "file", customKV...)
go func() {
if _, err := setup.Env.ExecOnSource(ctx, command); err != nil {
fmt.Println(err)
}
}()
return ctx, nil
}

func generateBenchmark(ctx context.Context, mode, path string, rate, duration int, customKV ...string) (context.Context, error) {
time.Sleep(3 * time.Second)
customKV = append(customKV, "mode", mode, "path", path, "rate", strconv.Itoa(rate), "duration", strconv.Itoa(duration))
command := trigger.GetRunTriggerCommand("log_benchmark", customKV...)
command := trigger.GetRunTriggerCommand("log", "file_benchmark", customKV...)
if _, err := setup.Env.ExecOnSource(ctx, command); err != nil {
return ctx, err
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e143471

Please sign in to comment.