Skip to content

Increase Reporter extensibility #3291

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion clusterloader2/pkg/test/simple_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (str *simpleReporter) ReportTestStepFinish(duration time.Duration, stepName
}

func (str *simpleReporter) ReportTestStep(result *StepResult) {
for _, subtestResult := range result.getAllResults() {
for _, subtestResult := range result.GetAllResults() {
str.ReportTestStepFinish(subtestResult.duration, subtestResult.name, subtestResult.err)
}
}
Expand Down
22 changes: 14 additions & 8 deletions clusterloader2/pkg/test/step_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,43 @@ import (
"k8s.io/perf-tests/clusterloader2/pkg/errors"
)

type substepResult struct {
type SubstepResult struct {
name string
id int
duration time.Duration
err *errors.ErrorList
}

func (ss *SubstepResult) Name() string { return ss.name }
func (ss *SubstepResult) Duration() time.Duration { return ss.duration }
func (ss *SubstepResult) GetAllErrors() *errors.ErrorList { return ss.err }

type StepResult struct {
lock sync.Mutex
startTime time.Time
name string
err *errors.ErrorList

results []substepResult
results []SubstepResult
}

func NewStepResult(stepName string) *StepResult {
return &StepResult{
name: stepName,
startTime: time.Now(),
results: []substepResult{},
results: []SubstepResult{},
err: errors.NewErrorList(),
}
}

func (s *StepResult) Name() string { return s.name }

func (s *StepResult) AddSubStepResult(name string, id int, err *errors.ErrorList) {
s.lock.Lock()
defer s.lock.Unlock()

duration := time.Since(s.startTime)
s.results = append(s.results, substepResult{
s.results = append(s.results, SubstepResult{
name: name,
id: id,
duration: duration,
Expand All @@ -78,14 +84,14 @@ func (s *StepResult) GetAllErrors() *errors.ErrorList {
return s.getAllErrorsUnsafe()
}

func (s *StepResult) getAllResults() []substepResult {
func (s *StepResult) GetAllResults() []SubstepResult {
s.lock.Lock()
defer s.lock.Unlock()

results := []substepResult{}
results := []SubstepResult{}
// Special case for phases that do not report substeps.
if len(s.results) == 0 {
results = append(results, substepResult{
results = append(results, SubstepResult{
name: s.name,
duration: time.Since(s.startTime),
err: s.getAllErrorsUnsafe(),
Expand All @@ -97,7 +103,7 @@ func (s *StepResult) getAllResults() []substepResult {
})

for _, result := range s.results {
results = append(results, substepResult{
results = append(results, SubstepResult{
name: s.name + " " + result.name,
duration: result.duration,
err: result.err,
Expand Down