Test agent RPC client connection retries

This commit is contained in:
Chavez 2016-03-29 11:30:18 -07:00
parent 10f297e8fc
commit 09f962a75b
1 changed files with 9 additions and 2 deletions

View File

@ -3,8 +3,6 @@ package agent
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/hashicorp/consul/testutil"
"github.com/hashicorp/serf/serf"
"io" "io"
"io/ioutil" "io/ioutil"
"net" "net"
@ -14,6 +12,9 @@ import (
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/hashicorp/consul/testutil"
"github.com/hashicorp/serf/serf"
) )
type rpcParts struct { type rpcParts struct {
@ -40,6 +41,9 @@ func testRPCClientWithConfig(t *testing.T, cb func(c *Config)) *rpcParts {
lw := NewLogWriter(512) lw := NewLogWriter(512)
mult := io.MultiWriter(os.Stderr, lw) mult := io.MultiWriter(os.Stderr, lw)
configTry := 0
RECONF:
configTry += 1
conf := nextConfig() conf := nextConfig()
cb(conf) cb(conf)
@ -50,6 +54,9 @@ func testRPCClientWithConfig(t *testing.T, cb func(c *Config)) *rpcParts {
l, err := net.Listen(rpcAddr.Network(), rpcAddr.String()) l, err := net.Listen(rpcAddr.Network(), rpcAddr.String())
if err != nil { if err != nil {
if configTry < 3 {
goto RECONF
}
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }