Skip to content

Commit

Permalink
Merge pull request #347 from nats-io/remove_extra_delete_from_map
Browse files Browse the repository at this point in the history
Set required gnatsd version to 1.0.7 for test related to async INFO
  • Loading branch information
kozlovic committed Mar 4, 2018
2 parents 0718c1c + ad59919 commit 8ea9eac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -1874,9 +1874,9 @@ func (nc *Conn) processInfo(info string) error {
// Remove from the temp map so that at the end we are left with only
// new (or restarted) servers that need to be added to the pool.
delete(tmp, curl)
// Keep the implicit one if we are currently connected to it.
// Keep servers that were set through Options, but also the one that
// we are currently connected to (even if it is a discovered server).
if !srv.isImplicit || srv.url == nc.url {
delete(tmp, curl)
continue
}
if !inInfo {
Expand Down
16 changes: 9 additions & 7 deletions test/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ func (d *checkPoolUpdatedDialer) Dial(network, address string) (net.Conn, error)
}

func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) {
if err := serverVersionAtLeast(1, 0, 6); err != nil {
if err := serverVersionAtLeast(1, 0, 7); err != nil {
t.Skipf(err.Error())
}
s1Opts := test.DefaultTestOptions
Expand Down Expand Up @@ -702,25 +702,27 @@ func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) {
// so try again on failure.
var (
ds []string
timeout = time.Now().Add(3 * time.Second)
timeout = time.Now().Add(5 * time.Second)
)
for time.Now().Before(timeout) {
startCheck:
ds = nc.Servers()
if len(ds) == len(expected) {
m := make(map[string]struct{}, len(ds))
for _, url := range ds {
m[url] = struct{}{}
}
ok := true
for _, url := range expected {
if _, present := m[url]; !present {
time.Sleep(15 * time.Millisecond)
goto startCheck
ok = false
break
}
}
// we are good
return
if ok {
return
}
}
time.Sleep(50 * time.Millisecond)
}
stackFatalf(t, "Expected %v, got %v", expected, ds)
}
Expand Down

0 comments on commit 8ea9eac

Please sign in to comment.