Исправить замечания ревью: останавливать лестницу только при перегрузке системы, проверять файлы серий до запуска, исправить единицы контроля шума, убрать лишние комментарии
This commit is contained in:
@@ -88,7 +88,7 @@ func parse(mode string, args []string) (config, error) {
|
||||
fs.StringVar(&cfg.Duration, "duration", "60s", "timeline: duration")
|
||||
fs.StringVar(&cfg.Timeout, "timeout", "2s", "how long the generator waits for a response (class client_timeout)")
|
||||
fs.Uint64Var(&cfg.Seed, "seed", 1, "random seed of the request mix")
|
||||
fs.BoolVar(&cfg.StopOnFail, "stop-on-fail", false, "bench: end the ladder after the first step that fails the capacity criterion")
|
||||
fs.BoolVar(&cfg.StopOnFail, "stop-on-fail", false, "bench: end the ladder after the first step over 1 % errors or 500 ms p99")
|
||||
fs.BoolVar(&cfg.Scrape, "scrape", false, "sample HAProxy statistics and replica expvar every second")
|
||||
fs.StringVar(&cfg.StatsURL, "stats-url", "http://lb:8404/;csv", "HAProxy statistics CSV")
|
||||
fs.StringVar(&cfg.APIHost, "api-host", "api", "DNS name of the API replicas")
|
||||
@@ -208,7 +208,7 @@ func runBench(ctx context.Context, cfg config) error {
|
||||
}
|
||||
fmt.Printf("step %6.0f rps: ok %7.1f rps, errors %5.2f%%, p99 %7.1f ms, lag p99 %5.1f ms, valid %v, passed %v\n",
|
||||
rate, s.OKRPS, 100*s.ErrorShare, s.P99Ms, s.LagP99Ms, s.Valid, s.Passed)
|
||||
if cfg.StopOnFail && !s.Passed {
|
||||
if cfg.StopOnFail && s.overloaded() {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,10 +121,14 @@ func summarize(rate float64, d time.Duration, samples []sample) stepSummary {
|
||||
lagP99 := percentile(lags, 99)
|
||||
s.LagP99Ms = ms(lagP99)
|
||||
s.Valid = lagP99 <= maxValidLag
|
||||
s.Passed = s.Valid && s.ErrorShare < maxErrorShare && percentile(ok, 99) <= sloP99
|
||||
s.Passed = s.Valid && !s.overloaded()
|
||||
return s
|
||||
}
|
||||
|
||||
func (s stepSummary) overloaded() bool {
|
||||
return s.ErrorShare >= maxErrorShare || s.P99Ms > ms(sloP99)
|
||||
}
|
||||
|
||||
func ms(d time.Duration) float64 {
|
||||
return float64(d.Microseconds()) / 1000
|
||||
}
|
||||
|
||||
@@ -126,3 +126,23 @@ func TestStepPassesOnlyWithinTheObjective(t *testing.T) {
|
||||
t.Fatalf("an invalid step must fail: %+v", s)
|
||||
}
|
||||
}
|
||||
|
||||
// The ladder stops when the system leaves the objective, not when the
|
||||
// generator alone fell behind: a later step may still be valid and pass.
|
||||
func TestOnlyTheSystemEndsTheLadder(t *testing.T) {
|
||||
ok := func(latency, lag time.Duration) sample {
|
||||
return sample{class: "ok", latency: latency, lag: lag}
|
||||
}
|
||||
late := []sample{ok(10*time.Millisecond, 50*time.Millisecond), ok(10*time.Millisecond, 50*time.Millisecond)}
|
||||
if s := summarize(2, time.Second, late); s.overloaded() {
|
||||
t.Fatalf("a lagging generator must not end the ladder: %+v", s)
|
||||
}
|
||||
slow := []sample{ok(10*time.Millisecond, time.Millisecond), ok(600*time.Millisecond, time.Millisecond)}
|
||||
if s := summarize(2, time.Second, slow); !s.overloaded() {
|
||||
t.Fatalf("p99 above 500 ms must end the ladder: %+v", s)
|
||||
}
|
||||
failing := []sample{ok(10*time.Millisecond, time.Millisecond), {class: "client_timeout", lag: time.Millisecond}}
|
||||
if s := summarize(2, time.Second, failing); !s.overloaded() {
|
||||
t.Fatalf("errors above 1 %% must end the ladder: %+v", s)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user