Skip to content

Commit

Permalink
Merge e71ec70 into a573364
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch committed Dec 28, 2018
2 parents a573364 + e71ec70 commit 6cfd60b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package tests
import (
"context"
"os"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -293,7 +294,19 @@ func NewTestCluster(initialServerCount int, opts ...ConfigOption) (*TestCluster,
// RunServer starts to run TestServer.
func (c *TestCluster) RunServer(ctx context.Context, server *TestServer) <-chan error {
resC := make(chan error)
go func() { resC <- server.Run(ctx) }()
go func() {
var err error
for i := 0; i < 10; i++ {
err = server.Run(ctx)
// retryable error
if err != nil && strings.Contains(err.Error(), "address already in use") {
time.Sleep(time.Second)
continue
}
break
}
resC <- err
}()
return resC
}

Expand Down

0 comments on commit 6cfd60b

Please sign in to comment.