diff --git a/cmd/mockbackend/e2etesting.go b/cmd/mockbackend/e2etesting.go index 34172cf1f..e342ddcba 100644 --- a/cmd/mockbackend/e2etesting.go +++ b/cmd/mockbackend/e2etesting.go @@ -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 { @@ -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 { diff --git a/cmd/mockbackend/testcases/find_error/find_error.yaml b/cmd/mockbackend/testcases/find_error/find_error.yaml index 53b5003f7..b2c8e812e 100644 --- a/cmd/mockbackend/testcases/find_error/find_error.yaml +++ b/cmd/mockbackend/testcases/find_error/find_error.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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" diff --git a/cmd/mockbackend/testcases/i484/i484.yaml b/cmd/mockbackend/testcases/i484/i484.yaml index 628e7f558..b507ac747 100644 --- a/cmd/mockbackend/testcases/i484/i484.yaml +++ b/cmd/mockbackend/testcases/i484/i484.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/i503/i503.yaml b/cmd/mockbackend/testcases/i503/i503.yaml index 4a794df2a..2db1ab616 100644 --- a/cmd/mockbackend/testcases/i503/i503.yaml +++ b/cmd/mockbackend/testcases/i503/i503.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/i506/i506.yaml b/cmd/mockbackend/testcases/i506/i506.yaml index 98737d16b..e548c83c1 100644 --- a/cmd/mockbackend/testcases/i506/i506.yaml +++ b/cmd/mockbackend/testcases/i506/i506.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/i516/i516.yaml b/cmd/mockbackend/testcases/i516/i516.yaml index d2f0ff424..2a7fd1f3e 100644 --- a/cmd/mockbackend/testcases/i516/i516.yaml +++ b/cmd/mockbackend/testcases/i516/i516.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/i517/i517.yaml b/cmd/mockbackend/testcases/i517/i517.yaml index e9158ef3d..13d957b26 100644 --- a/cmd/mockbackend/testcases/i517/i517.yaml +++ b/cmd/mockbackend/testcases/i517/i517.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/i545/i545.yaml b/cmd/mockbackend/testcases/i545/i545.yaml index bb9329ed7..408c11b80 100644 --- a/cmd/mockbackend/testcases/i545/i545.yaml +++ b/cmd/mockbackend/testcases/i545/i545.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/i565/i565.yaml b/cmd/mockbackend/testcases/i565/i565.yaml index 1fc4762ff..b5bf515df 100644 --- a/cmd/mockbackend/testcases/i565/i565.yaml +++ b/cmd/mockbackend/testcases/i565/i565.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/i580/i580.yaml b/cmd/mockbackend/testcases/i580/i580.yaml index 29baa4d35..592af6ecc 100644 --- a/cmd/mockbackend/testcases/i580/i580.yaml +++ b/cmd/mockbackend/testcases/i580/i580.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/i584/i584.yaml b/cmd/mockbackend/testcases/i584/i584.yaml index 909c0b3dc..f017af54b 100644 --- a/cmd/mockbackend/testcases/i584/i584.yaml +++ b/cmd/mockbackend/testcases/i584/i584.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/i589/i589.yaml b/cmd/mockbackend/testcases/i589/i589.yaml index 49565dec3..c5e720442 100644 --- a/cmd/mockbackend/testcases/i589/i589.yaml +++ b/cmd/mockbackend/testcases/i589/i589.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/i598/i598.yaml b/cmd/mockbackend/testcases/i598/i598.yaml index 3ca392499..ad358807e 100644 --- a/cmd/mockbackend/testcases/i598/i598.yaml +++ b/cmd/mockbackend/testcases/i598/i598.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/i661/i661.yaml b/cmd/mockbackend/testcases/i661/i661.yaml index 6b2cda9c3..e41e676fa 100644 --- a/cmd/mockbackend/testcases/i661/i661.yaml +++ b/cmd/mockbackend/testcases/i661/i661.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/pr500/pr500.yaml b/cmd/mockbackend/testcases/pr500/pr500.yaml index f994ad017..1004f0158 100644 --- a/cmd/mockbackend/testcases/pr500/pr500.yaml +++ b/cmd/mockbackend/testcases/pr500/pr500.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/pr529/pr529.yaml b/cmd/mockbackend/testcases/pr529/pr529.yaml index 0a75eefcf..78abea6ad 100644 --- a/cmd/mockbackend/testcases/pr529/pr529.yaml +++ b/cmd/mockbackend/testcases/pr529/pr529.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/pr560/pr560.yaml b/cmd/mockbackend/testcases/pr560/pr560.yaml index 57202e0d2..23b8947d0 100644 --- a/cmd/mockbackend/testcases/pr560/pr560.yaml +++ b/cmd/mockbackend/testcases/pr560/pr560.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/pr594-403-504/pr594-403-504.yaml b/cmd/mockbackend/testcases/pr594-403-504/pr594-403-504.yaml index 0cf2e6c68..9473be4b4 100644 --- a/cmd/mockbackend/testcases/pr594-403-504/pr594-403-504.yaml +++ b/cmd/mockbackend/testcases/pr594-403-504/pr594-403-504.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/pr594-maskerror/pr594-maskerror.yaml b/cmd/mockbackend/testcases/pr594-maskerror/pr594-maskerror.yaml index 415ede7a4..57b95205a 100644 --- a/cmd/mockbackend/testcases/pr594-maskerror/pr594-maskerror.yaml +++ b/cmd/mockbackend/testcases/pr594-maskerror/pr594-maskerror.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/pr743/pr743.yaml b/cmd/mockbackend/testcases/pr743/pr743.yaml index 7425befb4..79d119043 100644 --- a/cmd/mockbackend/testcases/pr743/pr743.yaml +++ b/cmd/mockbackend/testcases/pr743/pr743.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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 diff --git a/cmd/mockbackend/testcases/pr817/pr817.yaml b/cmd/mockbackend/testcases/pr817/pr817.yaml index 6e5ca6c36..50d5953ff 100644 --- a/cmd/mockbackend/testcases/pr817/pr817.yaml +++ b/cmd/mockbackend/testcases/pr817/pr817.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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" diff --git a/cmd/mockbackend/testcases/render_error/render_error.yaml b/cmd/mockbackend/testcases/render_error/render_error.yaml index e57dd6a3a..83134f220 100644 --- a/cmd/mockbackend/testcases/render_error/render_error.yaml +++ b/cmd/mockbackend/testcases/render_error/render_error.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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" diff --git a/cmd/mockbackend/testcases/render_error_all/render_error_all.yaml b/cmd/mockbackend/testcases/render_error_all/render_error_all.yaml index d312d89d0..850514f92 100644 --- a/cmd/mockbackend/testcases/render_error_all/render_error_all.yaml +++ b/cmd/mockbackend/testcases/render_error_all/render_error_all.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-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" diff --git a/cmd/mockbackend/testcases/render_error_all_rr/carbonapi.yaml b/cmd/mockbackend/testcases/render_error_all_rr/carbonapi.yaml index ed6101937..a4f1f15e5 100644 --- a/cmd/mockbackend/testcases/render_error_all_rr/carbonapi.yaml +++ b/cmd/mockbackend/testcases/render_error_all_rr/carbonapi.yaml @@ -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" diff --git a/cmd/mockbackend/testcases/render_error_all_rr/render_error_all_rr.yaml b/cmd/mockbackend/testcases/render_error_all_rr/render_error_all_rr.yaml index a401b99ae..39ebc3a35 100644 --- a/cmd/mockbackend/testcases/render_error_all_rr/render_error_all_rr.yaml +++ b/cmd/mockbackend/testcases/render_error_all_rr/render_error_all_rr.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-config" - "./cmd/mockbackend/testcases/render_error_all_rr/carbonapi.yaml" - "-exact-config" + aliveURL: "http://127.0.0.1:8081" queries: - endpoint: "http://127.0.0.1:8081" type: "GET" @@ -15,9 +17,9 @@ test: httpCode: 200 contentType: "application/json" expectedResults: - - metrics: - - target: "a" - datapoints: [[0,1],[1,2],[2,3],[2,4],[3,5]] + - metrics: + - target: "a" + datapoints: [[0,1],[1,2],[2,3],[2,4],[3,5]] # empty - endpoint: "http://127.0.0.1:8081" diff --git a/cmd/mockbackend/testcases/tags_error/tags_error.yaml b/cmd/mockbackend/testcases/tags_error/tags_error.yaml index e21dd36a5..177d148c3 100644 --- a/cmd/mockbackend/testcases/tags_error/tags_error.yaml +++ b/cmd/mockbackend/testcases/tags_error/tags_error.yaml @@ -1,5 +1,6 @@ version: "v1" test: + startDelay: 100ms apps: - name: "carbonapi" binary: "./carbonapi" @@ -7,6 +8,7 @@ test: - "-config" - "./cmd/mockbackend/carbonapi_singlebackend.yaml" - "-exact-config" + aliveURL: "http://127.0.0.1:8081" queries: - endpoint: "http://127.0.0.1:8081" type: "GET"