etcdserver: Speed-up v3compactor unit tests.

The tests were taking ~15s because of 5s wait time in Recorder !?
This commit is contained in:
Piotr Tabor
2020-09-11 18:59:33 +02:00
parent 76e769ce95
commit 0a106754d3
3 changed files with 17 additions and 11 deletions

View File

@@ -82,11 +82,16 @@ func (r *RecorderBuffered) Chan() <-chan Action {
// RecorderStream writes all Actions to an unbuffered channel
type recorderStream struct {
ch chan Action
ch chan Action
waitTimeout time.Duration
}
func NewRecorderStream() Recorder {
return &recorderStream{ch: make(chan Action)}
return NewRecorderStreamWithWaitTimout(time.Duration(5 * time.Second))
}
func NewRecorderStreamWithWaitTimout(waitTimeout time.Duration) Recorder {
return &recorderStream{ch: make(chan Action), waitTimeout: waitTimeout}
}
func (r *recorderStream) Record(a Action) {
@@ -110,7 +115,7 @@ func (r *recorderStream) Chan() <-chan Action {
func (r *recorderStream) Wait(n int) ([]Action, error) {
acts := make([]Action, n)
timeoutC := time.After(5 * time.Second)
timeoutC := time.After(r.waitTimeout)
for i := 0; i < n; i++ {
select {
case acts[i] = <-r.ch: