Skip to content

Commit

Permalink
tests(e2e): check if app is alive for reduce startup delay
Browse files Browse the repository at this point in the history
  • Loading branch information
msaf1980 committed Mar 21, 2024
1 parent 7432348 commit 2f5c5e9
Show file tree
Hide file tree
Showing 26 changed files with 79 additions and 13 deletions.
32 changes: 25 additions & 7 deletions cmd/mockbackend/e2etesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ import (
)

type TestSchema struct {
Apps []App
Queries []Query
Apps []App
StartDelay time.Duration `yaml:"startDelay"`
Queries []Query
}

type App struct {
Name string
Binary string
Args []string
Name string
Binary string
Args []string
AliveURL string `yaml:"aliveURL"`
}

type Query struct {
Expand Down Expand Up @@ -409,8 +411,24 @@ func e2eTest(logger *zap.Logger, noapp, breakOnError, verbose bool) bool {
}

wgStart.Wait()
logger.Info("will sleep for 1 seconds to start all required apps")
time.Sleep(1 * time.Second)
logger.Info("will sleep to start all required apps")
if cfg.Test.StartDelay <= 0 {
cfg.Test.StartDelay = time.Second
}
aliveDelay := time.Millisecond * 50
for _, c := range cfg.Test.Apps {
if c.AliveURL != "" {
for i := 0; i < 30; i++ {
resp, err := http.Get(c.AliveURL)
if err == nil && resp != nil && resp.StatusCode == http.StatusOK {
break
} else {
time.Sleep(aliveDelay)
}
}
}
}
time.Sleep(cfg.Test.StartDelay)
}

for _, t := range cfg.Test.Queries {
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/find_error/find_error.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/testcases/render_error/carbonapi.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
type: "GET"
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/i484/i484.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/testcases/i484/carbonapi.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/i503/i503.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/carbonapi_singlebackend.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/i506/i506.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/testcases/i506/carbonapi.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/i516/i516.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/carbonapi_singlebackend.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/i517/i517.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/carbonapi_singlebackend.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/i545/i545.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/testcases/i545/carbonapi.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/i565/i565.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/carbonapi_singlebackend.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/i580/i580.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/carbonapi_singlebackend.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/i584/i584.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/carbonapi_singlebackend.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/i589/i589.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/carbonapi_singlebackend.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/i598/i598.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/testcases/i598/carbonapi.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/i661/i661.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/testcases/i598/carbonapi.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/pr500/pr500.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/carbonapi_singlebackend.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/pr529/pr529.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/carbonapi_singlebackend.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/pr560/pr560.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/carbonapi_singlebackend.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/pr594-403-504/pr594-403-504.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/testcases/pr594-403-504/carbonapi.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/testcases/pr594-maskerror/carbonapi.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/pr743/pr743.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/testcases/pr743/carbonapi.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
delay: 1
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/pr817/pr817.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/testcases/pr817/carbonapi.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
type: "GET"
Expand Down
2 changes: 2 additions & 0 deletions cmd/mockbackend/testcases/render_error/render_error.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/testcases/render_error/carbonapi.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
type: "GET"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: "v1"
test:
startDelay: 100ms
apps:
- name: "carbonapi"
binary: "./carbonapi"
args:
- "-config"
- "./cmd/mockbackend/testcases/render_error_all/carbonapi.yaml"
- "-exact-config"
aliveURL: "http://127.0.0.1:8081"
queries:
- endpoint: "http://127.0.0.1:8081"
type: "GET"
Expand Down
6 changes: 3 additions & 3 deletions cmd/mockbackend/testcases/render_error_all_rr/carbonapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ upstreams:
requireSuccessAll: true
buckets: 10
timeouts:
find: "2s"
render: "10s"
find: "200s"
render: "1000s"
connect: "200ms"
concurrencyLimitPerServer: 0
keepAliveInterval: "30s"
maxIdleConnsPerHost: 100
backendsv2:
backends:
-
-
groupName: "mock-001"
protocol: "auto"
lbMethod: "rr"
Expand Down
Loading

0 comments on commit 2f5c5e9

Please sign in to comment.