mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: Speed-up v3compactor unit tests.
The tests were taking ~15s because of 5s wait time in Recorder !?
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user