Skip to content

Commit

Permalink
record-tester: Accumulate errors from finite testers
Browse files Browse the repository at this point in the history
  • Loading branch information
victorges committed Dec 24, 2021
1 parent a82ec88 commit bb451e1
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions internal/testers/streamer2.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package testers

import (
"context"
"errors"
"fmt"
"strings"
"time"

"github.com/golang/glog"
Expand Down Expand Up @@ -94,16 +96,31 @@ func (sr *streamer2) StartStreaming(sourceFileName string, rtmpIngestURL, mediaU
tests = append(tests, startFunc(sr.ctx, mediaURL, waitForTarget, sr.Streamer2Options))
}
go func() {
testsDone := onAnyDone(sr.ctx, tests)
var (
ctx, cancel = context.WithCancel(sr.ctx)
testsDone = onAnyDone(ctx, tests)
errs = []string{}
)
defer cancel()
for {
select {
case <-sr.ctx.Done():
return
case test := <-testsDone:
if err := test.GlobalErr(); err != nil {
sr.fatalEnd(err)
return
if sr.globalError == nil {
sr.globalError = err
time.AfterFunc(10*time.Second, cancel)
}
errs = append(errs, err.Error())
}
case <-ctx.Done():
if len(errs) > 0 {
msg := errs[0]
if len(errs) > 1 {
msg = "Multiple errors: " + strings.Join(errs, "; ")
}
sr.fatalEnd(errors.New(msg))
}
return
}
}
}()
Expand Down

0 comments on commit bb451e1

Please sign in to comment.