Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added version to stress tests files #1433

Merged
merged 3 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ stress-test-e2e: $(ensure-build-image)
--gameserver-image=$(GS_TEST_IMAGE) \
--pullsecret=$(IMAGE_PULL_SECRET) \
--stress $(STRESS_TEST_LEVEL) \
--perf-output $(PERF_OUTPUT_DIR)
--perf-output $(PERF_OUTPUT_DIR) \
--version $(VERSION)

# Run test on install yaml - make sure there is no change
# mostly this is for CI
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/fleet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,8 @@ func TestScaleUpAndDownInParallelStressTest(t *testing.T) {

var fleets []*agonesv1.Fleet

scaleUpStats := framework.NewStatsCollector(fmt.Sprintf("fleet_%v_scale_up", fleetSize))
scaleDownStats := framework.NewStatsCollector(fmt.Sprintf("fleet_%v_scale_down", fleetSize))
scaleUpStats := framework.NewStatsCollector(fmt.Sprintf("fleet_%v_scale_up", fleetSize), framework.Version)
scaleDownStats := framework.NewStatsCollector(fmt.Sprintf("fleet_%v_scale_down", fleetSize), framework.Version)

defer scaleUpStats.Report()
defer scaleDownStats.Report()
Expand Down
7 changes: 5 additions & 2 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type Framework struct {
PullSecret string
StressTestLevel int
PerfOutputDir string
Version string
}

// New setups a testing framework using a kubeconfig path and the game server image to use for testing.
Expand Down Expand Up @@ -115,6 +116,7 @@ func NewFromFlags() (*Framework, error) {
"optional secret to be used for pulling the gameserver and/or Agones SDK sidecar images")
stressTestLevel := flag.Int("stress", 0, "enable stress test at given level 0-100")
perfOutputDir := flag.String("perf-output", "", "write performance statistics to the specified directory")
version := flag.String("version", "", "agones controller version that was tested in the release version plus the short hash of the latest commit")
Copy link
Collaborator

@aLekSer aLekSer Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version := flag.String("version", "", "agones controller version that was tested in the release version plus the short hash of the latest commit")
version := flag.String("version", "", "agones controller version to be tested, consists of release version plus the short hash of the latest commit")


flag.Parse()

Expand All @@ -127,6 +129,7 @@ func NewFromFlags() (*Framework, error) {
framework.PullSecret = *pullSecret
framework.StressTestLevel = *stressTestLevel
framework.PerfOutputDir = *perfOutputDir
framework.Version = *version

return framework, nil
}
Expand Down Expand Up @@ -304,11 +307,11 @@ func (f *Framework) WaitForFleetGameServerListCondition(flt *agonesv1.Fleet,

// NewStatsCollector returns new instance of statistics collector,
// which can be used to emit performance statistics for load tests and stress tests.
func (f *Framework) NewStatsCollector(name string) *StatsCollector {
func (f *Framework) NewStatsCollector(name, version string) *StatsCollector {
if f.StressTestLevel > 0 {
name = fmt.Sprintf("stress_%v_%v", f.StressTestLevel, name)
}
return &StatsCollector{name: name, outputDir: f.PerfOutputDir}
return &StatsCollector{name: name, outputDir: f.PerfOutputDir, version: version}
}

// CleanUp Delete all Agones resources in a given namespace.
Expand Down
27 changes: 20 additions & 7 deletions test/e2e/framework/perf.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package framework

import (
"encoding/json"
"fmt"
"net/http"
"os"
"path/filepath"
Expand All @@ -20,6 +21,7 @@ import (
type StatsCollector struct {
name string
outputDir string
version string

mu sync.Mutex
samples []time.Duration
Expand Down Expand Up @@ -76,8 +78,8 @@ func (p *StatsCollector) Report() {

var rr fhttp.HTTPRunnerResults
rr.RunType = "HTTP"
rr.Labels = "Agones " + p.name
rr.StartTime = time.Now()
rr.Labels = fmt.Sprintf("Agones %s_%s", p.name, p.version)
rr.StartTime = time.Now().UTC()
rr.ActualDuration = p.lastSampleTime.Sub(p.firstSampleTime)
rr.DurationHistogram = h.Export()
rr.DurationHistogram.CalcPercentiles([]float64{50, 90, 95, 99, 99.9})
Expand All @@ -98,18 +100,29 @@ func (p *StatsCollector) Report() {
Info(p.name)

if p.outputDir != "" {
os.MkdirAll(p.outputDir, 0755) //nolint:errcheck
err := os.MkdirAll(p.outputDir, 0755)
if err != nil {
logrus.WithError(err).Errorf("unable to create a folder: %s", p.outputDir)
return
}

fname := filepath.Join(p.outputDir, p.name+"_"+rr.StartTime.UTC().Format("2006-01-02_1504")+".json")
fname := filepath.Join(p.outputDir, fmt.Sprintf("%s_%s_%s.json", p.name, p.version, rr.StartTime.Format("2006-01-02_1504")))
f, err := os.Create(fname)
if err != nil {
logrus.WithError(err).Error("unable to create performance log")
logrus.WithError(err).Errorf("unable to create performance log: %s", fname)
return
}
defer f.Close() //nolint:errcheck
defer func() {
if cerr := f.Close(); cerr != nil {
logrus.Error(cerr)
}
}()

e := json.NewEncoder(f)
e.SetIndent("", " ")
e.Encode(rr) //nolint:errcheck
err = e.Encode(rr)
if err != nil {
logrus.Error(err)
}
}
}