Sleep for longer, but try less often

This fixes an issue where the system can quickly run out of file
descriptors because they are accumulating faster than the kernel can
release them.
This commit is contained in:
Seth Vargo 2017-01-26 00:13:34 -05:00
parent c0b6c7ad3e
commit e3a4b2128b
No known key found for this signature in database
GPG Key ID: C921994F9C27E0FF
1 changed files with 4 additions and 3 deletions

View File

@ -1,19 +1,20 @@
package testutil
import (
"github.com/hashicorp/consul/consul/structs"
"testing"
"time"
"github.com/hashicorp/consul/consul/structs"
)
type testFn func() (bool, error)
type errorFn func(error)
func WaitForResult(test testFn, error errorFn) {
retries := 1000
retries := 100
for retries > 0 {
time.Sleep(10 * time.Millisecond)
time.Sleep(100 * time.Millisecond)
retries--
success, err := test()