Skip to content

Commit

Permalink
add more steps in E2E framework (alibaba#1837)
Browse files Browse the repository at this point in the history
* add more steps in E2E framework

* fix

* fix

* fix

* fix

* fix

* typo

* fix
  • Loading branch information
Abingcbc authored Oct 31, 2024
1 parent 095d89c commit 3d56d3b
Show file tree
Hide file tree
Showing 50 changed files with 850 additions and 389 deletions.
4 changes: 3 additions & 1 deletion test/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var TestConfig Config

type Config struct {
// Log
LocalConfigDir string `mapstructure:"local_config_dir" yaml:"local_config_dir"`
GeneratedLogDir string `mapstructure:"generated_log_dir" yaml:"generated_log_dir"`
WorkDir string `mapstructure:"work_dir" yaml:"work_dir"`
// Host
Expand Down Expand Up @@ -65,9 +66,10 @@ func ParseConfig() {

TestConfig = Config{}
// Log
TestConfig.LocalConfigDir = os.Getenv("LOCAL_CONFIG_DIR")
TestConfig.GeneratedLogDir = os.Getenv("GENERATED_LOG_DIR")
if len(TestConfig.GeneratedLogDir) == 0 {
TestConfig.GeneratedLogDir = "/tmp/ilogtail"
TestConfig.GeneratedLogDir = "/tmp/loongcollector"
}
TestConfig.WorkDir = os.Getenv("WORK_DIR")

Expand Down
1 change: 1 addition & 0 deletions test/config/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ const (
ExposePortKey ContextKey = "exposePort"
CurrentWorkingDeploymentKey ContextKey = "currentWorkingDeployment"
QueryKey ContextKey = "query"
AgentPIDKey ContextKey = "agentPID"
)
4 changes: 2 additions & 2 deletions test/e2e/test_cases/aggregator_context/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
environment:
- STDOUT_SWITCH=true
depends_on:
- ilogtailC
- loongcollectorC
container_2:
build:
context: .
Expand All @@ -37,4 +37,4 @@ services:
timeout: 5s
retries: 3
depends_on:
- ilogtailC
- loongcollectorC
54 changes: 0 additions & 54 deletions test/e2e/test_cases/aggregator_context/ilogtail-e2e.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion test/e2e/test_cases/flusher_clickhouse/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Feature: flusher clickhouse
BufferMinBytes: 10000000
BufferMaxBytes: 100000000
"""
Given iLogtail depends on containers {["clickhouse"]}
Given loongcollector depends on containers {["clickhouse"]}
When start docker-compose {flusher_clickhouse}
Then there is at least {10} logs
Then the log fields match kv
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_cases/flusher_elasticsearch/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Feature: flusher elasticsearch
Username: elastic
Password: BtpoRTeyjmC=ruTIUoNN
"""
Given iLogtail depends on containers {["elasticsearch"]}
Given loongcollector depends on containers {["elasticsearch"]}
When start docker-compose {flusher_elasticsearch}
Then there is at least {10} logs
Then the log fields match kv
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_cases/flusher_http/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Feature: flusher http
- Type: ext_request_breaker
FailureRatio: 0.1
"""
Given iLogtail depends on containers {["influxdb"]}
Given loongcollector depends on containers {["influxdb"]}
When start docker-compose {flusher_http}
Then there is at least {10} logs
Then the log fields match kv
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/test_cases/flusher_loki/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Feature: flusher loki
Given subcribe data from {loki} with config
"""
address: http://loki:3100
tenant_id: ilogtail
tenant_id: loongcollector
target_labels:
loki_name: hello
source: ilogtail
source: loongcollector
"""
Given {flusher-loki-case} local config as below
"""
Expand All @@ -29,7 +29,7 @@ Feature: flusher loki
TagFieldsRename:
loki_name: name
URL: http://loki:3100/loki/api/v1/push
TenantID: ilogtail
TenantID: loongcollector
MaxMessageWait: 100000000
MaxMessageBytes: 1024
Timeout: 1000000000000
Expand All @@ -39,9 +39,9 @@ Feature: flusher loki
DynamicLabels:
- tag.loki_name
StaticLabels:
source: ilogtail
source: loongcollector
"""
Given iLogtail depends on containers {["loki"]}
Given loongcollector depends on containers {["loki"]}
When start docker-compose {flusher_loki}
Then there is at least {10} logs
Then the log fields match kv
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_cases/input_canal/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: input canal
TextToString: true
EnableDDL: true
"""
Given iLogtail depends on containers {["mysql"]}
Given loongcollector depends on containers {["mysql"]}
When start docker-compose {input_canal}
When generate {10} http logs, with interval {10}ms, url: {http://client:10999/add/data}, method: {GET}, body:
"""
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_cases/input_canal_binfile_mode/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: input canal binfile mode
TextToString: true
EnableDDL: true
"""
Given iLogtail depends on containers {["mysql"]}
Given loongcollector depends on containers {["mysql"]}
When start docker-compose {input_canal}
When generate {10} http logs, with interval {10}ms, url: {http://client:10999/add/data}, method: {GET}, body:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ services:
environment:
- STDOUT_SWITCH=true
depends_on:
- ilogtailC
- loongcollectorC
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ services:
environment:
- STDOUT_SWITCH=true
depends_on:
- ilogtailC
- loongcollectorC
4 changes: 2 additions & 2 deletions test/e2e/test_cases/input_http_server/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Feature: input http server
FieldType: json
ExpondJson: true
"""
Given iLogtail expose port {18089} to {18089}
Given loongcollector expose port {18089} to {18089}
When start docker-compose {input_http_server}
When generate {10} http logs, with interval {10}ms, url: {http://ilogtailC:18089/?db=mydb}, method: {POST}, body:
When generate {10} http logs, with interval {10}ms, url: {http://loongcollectorC:18089/?db=mydb}, method: {POST}, body:
"""
weather,city=hz value=32
"""
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_cases/input_mssql/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Feature: input mssql
Password: MSsqlpa#1word
StateMent: "select * from LogtailTestTable where id > ? ORDER BY id"
"""
Given iLogtail depends on containers {["setup"]}
Given loongcollector depends on containers {["setup"]}
When start docker-compose {input_mssql}
Then there is at least {4} logs
Then the log fields match as below
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_cases/input_mysql/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Feature: input mysql
CheckPointStart: "0"
IntervalMs: 1000
"""
Given iLogtail depends on containers {["mysql"]}
Given loongcollector depends on containers {["mysql"]}
When start docker-compose {input_mysql}
Then there is at least {500} logs
Then the log fields match as below
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_cases/input_pgsql/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Feature: input pgsql
Password: postgres
StateMent: "select * from specialalarmtest where id > $1"
"""
Given iLogtail depends on containers {["pgsql"]}
Given loongcollector depends on containers {["pgsql"]}
When start docker-compose {input_pgsql}
Then there is at least {10} logs
Then the log fields match as below
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_cases/input_static_file/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: input static file
- "/root/test/**/a*.log"
MaxDirSearchDepth: 10
"""
Given iLogtail container mount {./a.log} to {/root/test/1/2/3/axxxx.log}
Given loongcollector container mount {./a.log} to {/root/test/1/2/3/axxxx.log}
When start docker-compose {input_static_file}
Then there is at least {1000} logs
Then the log fields match kv
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_cases/reader_deleted/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Feature: reader deleted
- /root/test/simple.log
FlushTimeoutSecs: 3
"""
Given iLogtail container mount {./volume} to {/root/test}
Given loongcollector container mount {./volume} to {/root/test}
When start docker-compose {reader_deleted}
Then there is at least {1} logs
2 changes: 1 addition & 1 deletion test/e2e/test_cases/reader_deleted/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ services:
environment:
- STDOUT_SWITCH=true
depends_on:
- ilogtailC
- loongcollectorC
2 changes: 1 addition & 1 deletion test/e2e/test_cases/reader_flush_timeout/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Feature: reader flush timeout
- /root/test/simple.log
FlushTimeoutSecs: 1
"""
Given iLogtail container mount {./a.log} to {/root/test/simple.log}
Given loongcollector container mount {./a.log} to {/root/test/simple.log}
When start docker-compose {reader_flush_timeout}
Then there is at least {5} logs
2 changes: 1 addition & 1 deletion test/e2e/test_cases/reader_log_rotate/case.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Feature: reader log rotate
- /root/test/simple.log
FlushTimeoutSecs: 2
"""
Given iLogtail container mount {./volume} to {/root/test}
Given loongcollector container mount {./volume} to {/root/test}
When start docker-compose {reader_log_rotate}
Then there is at least {6} logs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Feature: reader new line after timeout
- /root/test/a.log
FlushTimeoutSecs: 1
"""
Given iLogtail container mount {./a.log} to {/root/test/a.log}
Given loongcollector container mount {./a.log} to {/root/test/a.log}
When start docker-compose {reader_new_line_after_timeout}
Then there is at least {6} logs
2 changes: 1 addition & 1 deletion test/engine/cleanup/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

func GoTestCache(ctx context.Context) (context.Context, error) {
command := "/usr/local/go/bin/go clean -testcache"
if err := setup.Env.ExecOnSource(ctx, command); err != nil {
if _, err := setup.Env.ExecOnSource(ctx, command); err != nil {
return ctx, err
}
return ctx, nil
Expand Down
1 change: 0 additions & 1 deletion test/engine/cleanup/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func All() {
_, _ = AllGeneratedLog(ctx)
_, _ = GoTestCache(ctx)
_, _ = DeleteContainers(ctx)
// FIXME: if this test case has no subscriber and the previous one has subscriber, it will panic
if subscriber.TestSubscriber != nil {
_ = subscriber.TestSubscriber.Stop()
}
Expand Down
2 changes: 1 addition & 1 deletion test/engine/cleanup/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

func AllGeneratedLog(ctx context.Context) (context.Context, error) {
command := fmt.Sprintf("rm -rf %s/*", config.TestConfig.GeneratedLogDir)
if err := setup.Env.ExecOnSource(ctx, command); err != nil {
if _, err := setup.Env.ExecOnSource(ctx, command); err != nil {
return ctx, err
}
return ctx, nil
Expand Down
9 changes: 4 additions & 5 deletions test/engine/control/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"github.com/alibaba/ilogtail/test/engine/setup/subscriber"
)

const iLogtailLocalConfigDir = "/usr/local/loongcollector/conf/local"
const lotailpluginHTTPAddress = "ilogtailC:18689"
const E2EProjectName = "e2e-test-project"
const E2ELogstoreName = "e2e-test-logstore"
Expand All @@ -55,8 +54,8 @@ func AddLocalConfig(ctx context.Context, configName, c string) (context.Context,
}
} else {
command := fmt.Sprintf(`cd %s && cat << 'EOF' > %s.yaml
%s`, iLogtailLocalConfigDir, configName, c)
if err := setup.Env.ExecOnLogtail(command); err != nil {
%s`, config.TestConfig.LocalConfigDir, configName, c)
if _, err := setup.Env.ExecOnLogtail(command); err != nil {
return ctx, err
}
time.Sleep(5 * time.Second)
Expand All @@ -65,8 +64,8 @@ func AddLocalConfig(ctx context.Context, configName, c string) (context.Context,
}

func RemoveAllLocalConfig(ctx context.Context) (context.Context, error) {
command := fmt.Sprintf("cd %s && rm -rf *.yaml", iLogtailLocalConfigDir)
if err := setup.Env.ExecOnLogtail(command); err != nil {
command := fmt.Sprintf("cd %s && rm -rf *.yaml", config.TestConfig.LocalConfigDir)
if _, err := setup.Env.ExecOnLogtail(command); err != nil {
return ctx, err
}
return ctx, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,25 @@ func RemoveLabel(ctx context.Context, labelStr string) (context.Context, error)
}
return ctx, nil
}

func ApplyYaml(ctx context.Context, yaml string) (context.Context, error) {
if k8sEnv, ok := setup.Env.(*setup.K8sEnv); ok {
if err := k8sEnv.Apply(yaml); err != nil {
return ctx, err
}
} else {
return ctx, fmt.Errorf("try to apply yaml, but env is not k8s env")
}
return ctx, nil
}

func DeleteYaml(ctx context.Context, yaml string) (context.Context, error) {
if k8sEnv, ok := setup.Env.(*setup.K8sEnv); ok {
if err := k8sEnv.Delete(yaml); err != nil {
return ctx, err
}
} else {
return ctx, fmt.Errorf("try to delete yaml, but env is not k8s env")
}
return ctx, nil
}
Loading

0 comments on commit 3d56d3b

Please sign in to comment.