Skip to content

Commit

Permalink
Merge 3210afc into 04170fa
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch committed Dec 27, 2018
2 parents 04170fa + 3210afc commit 359a356
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() {
for i := 0; i < 10; i++ {
err := server.Run(ctx)
// retryable error
if err != nil && strings.Contains(err.Error(), "address already in use") {
server.Stop()
time.Sleep(time.Second)
continue
}
resC <- err
return
}
}()
return resC
}

Expand Down

0 comments on commit 359a356

Please sign in to comment.