-
Notifications
You must be signed in to change notification settings - Fork 820
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added very simple stress test which scales fleets up/down repeatedly …
…and basic stress test harness. The same test is used during regular e2e tests, except it runs just a few iterations on smaller fleets. To run stress test simply invoke `make stress-test-e2e` optionally passing `STRESS_TEST_LEVEL`, which controls the fleet sizes to be used (1..100, defaults to 20). Depending on stress test level, you may need a cluster with lots of capacity. By convention 'make stress-test-e2e' runs all test cases whose names include 'StressTest' and ignores everything else.
- Loading branch information
Showing
5 changed files
with
188 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package framework | ||
|
||
import ( | ||
"sort" | ||
"sync" | ||
"time" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// PerfResults aggregates performance test results. | ||
// The AddSample() method is safe for concurrent use by multiple goroutines. | ||
type PerfResults struct { | ||
mu sync.Mutex | ||
samples []time.Duration | ||
|
||
firstSampleTime time.Time | ||
lastSampleTime time.Time | ||
} | ||
|
||
// AddSample adds a single time measurement. | ||
func (p *PerfResults) AddSample(d time.Duration) { | ||
p.mu.Lock() | ||
defer p.mu.Unlock() | ||
|
||
n := time.Now() | ||
if len(p.samples) == 0 { | ||
p.firstSampleTime = n | ||
} | ||
p.lastSampleTime = n | ||
p.samples = append(p.samples, d) | ||
} | ||
|
||
// Report outputs performance report to log. | ||
func (p *PerfResults) Report(name string) { | ||
if len(p.samples) == 0 { | ||
return | ||
} | ||
|
||
sort.Slice(p.samples, func(i, j int) bool { | ||
return p.samples[i] < p.samples[j] | ||
}) | ||
|
||
var sum time.Duration | ||
for _, s := range p.samples { | ||
sum += s | ||
} | ||
|
||
avg := time.Duration(int64(sum) / int64(len(p.samples))) | ||
logrus. | ||
WithField("avg", avg). | ||
WithField("count", len(p.samples)). | ||
WithField("min", p.samples[0].Seconds()). | ||
WithField("max", p.samples[len(p.samples)-1].Seconds()). | ||
WithField("p50", p.samples[len(p.samples)*500/1001].Seconds()). | ||
WithField("p90", p.samples[len(p.samples)*900/1001].Seconds()). | ||
WithField("p95", p.samples[len(p.samples)*950/1001].Seconds()). | ||
WithField("p99", p.samples[len(p.samples)*990/1001].Seconds()). | ||
WithField("p999", p.samples[len(p.samples)*999/1001].Seconds()). | ||
WithField("duration", p.lastSampleTime.Sub(p.firstSampleTime).Seconds()). | ||
Info(name) | ||
|
||
// TODO - use something like Fortio ("fortio.org/fortio/stats") to | ||
// generate histogram for long-term storage and analysis. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters