Skip to content

Commit

Permalink
Merge bcac126 into a573364
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch committed Dec 28, 2018
2 parents a573364 + bcac126 commit 8cf5763
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/tempurl/tempurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (
func Alloc() string {
for i := 0; i < 10; i++ {
if u := tryAllocTestURL(); u != "" {
log.Infof("alloc url: %s", u)
return u
}
time.Sleep(time.Second)
Expand Down
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 8cf5763

Please sign in to comment.