Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Abingcbc committed Dec 17, 2024
1 parent ef6a6d8 commit 2521cb4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
10 changes: 10 additions & 0 deletions test/engine/setup/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,13 @@ func SetAgentPID(ctx context.Context) (context.Context, error) {
}
return context.WithValue(ctx, config.AgentPIDKey, result), nil
}

func RunCommandOnSource(ctx context.Context, command string) (context.Context, error) {
_, err := Env.ExecOnSource(ctx, command)
return ctx, err
}

func RunCommandOnLoongCollector(ctx context.Context, command string) (context.Context, error) {
_, err := Env.ExecOnLoongCollector(command)
return ctx, err
}
26 changes: 15 additions & 11 deletions test/engine/setup/subscriber/sls.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type SLSSubscriber struct {
Aliuid string
Region string
Endpoint string
QueryEndpoint string
Project string
Logstore string
}
Expand Down Expand Up @@ -112,7 +113,7 @@ func (s *SLSSubscriber) getLogFromSLS(sql string, from int32) (*sls.GetLogsRespo
From: tea.Int32(from),
To: tea.Int32(now),
}
resp, err := s.client.GetLogs(tea.String(config.TestConfig.Project), tea.String(config.TestConfig.GetLogstore(s.TelemetryType)), req)
resp, err := s.client.GetLogs(tea.String(s.Project), tea.String(s.Logstore), req)
if err != nil {
return nil, err
}
Expand All @@ -134,15 +135,7 @@ func createSLSClient(accessKeyID, accessKeySecret, endpoint string) *sls.Client

func init() {
RegisterCreator(slsName, func(spec map[string]interface{}) (Subscriber, error) {
telemetryType := "logs"
if v, ok := spec["telemetry_type"]; ok {
telemetryType = v.(string)
}
fmt.Println("create sls subscriber with telemetry type", telemetryType)
l := &SLSSubscriber{
client: createSLSClient(config.TestConfig.AccessKeyID, config.TestConfig.AccessKeySecret, config.GetQueryEndpoint()),
TelemetryType: telemetryType,
}
l := &SLSSubscriber{}
if v, ok := spec["aliuid"]; ok {
l.Aliuid = v.(string)
} else {
Expand All @@ -166,8 +159,19 @@ func init() {
if v, ok := spec["logstore"]; ok {
l.Logstore = v.(string)
} else {
l.Logstore = config.TestConfig.GetLogstore(telemetryType)
l.Logstore = config.TestConfig.Logstore
}
if v, ok := spec["query_endpoint"]; ok {
l.QueryEndpoint = v.(string)
} else {
l.QueryEndpoint = config.TestConfig.Endpoint
}
if v, ok := spec["telemetry_type"]; ok {
l.TelemetryType = v.(string)
} else {
l.TelemetryType = "logs"
}
l.client = createSLSClient(config.TestConfig.AccessKeyID, config.TestConfig.AccessKeySecret, l.QueryEndpoint)
return l, nil
})
doc.Register("subscriber", slsName, new(SLSSubscriber))
Expand Down
2 changes: 2 additions & 0 deletions test/engine/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func ScenarioInitializer(ctx *godog.ScenarioContext) {
ctx.Given(`^subcribe data from \{(\S+)\} with config`, subscriber.InitSubscriber)
ctx.Given(`^mkdir \{(.*)\}`, setup.Mkdir)
ctx.Given(`^docker-compose boot type \{(\S+)\}$`, setup.SetDockerComposeBootType)
ctx.Given(`^run command on datasource \{(.*)\}$`, setup.RunCommandOnSource)
ctx.Given(`^run command on loongcollector \{(.*)\}$`, setup.RunCommandOnLoongCollector)

// chaos
ctx.Given(`^network delay package \{(\d+)\}ms for ip \{(.*)\}`, chaos.NetworkDelay)
Expand Down
3 changes: 2 additions & 1 deletion test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
"strings"
"time"

"github.com/alibaba/ilogtail/test/engine"
"github.com/cucumber/godog"

"github.com/alibaba/ilogtail/test/engine"
)

func main() {
Expand Down

0 comments on commit 2521cb4

Please sign in to comment.