Merge pull request #188 from nats-io/fix_server_start_check

Fix code that checks that server is started + route test
This commit is contained in:
Derek Collison
2016-02-03 18:51:26 -08:00
3 changed files with 23 additions and 1 deletions

View File

@@ -46,6 +46,11 @@ func RunServer(opts *Options) *Server {
continue
}
conn.Close()
// Wait a bit to give a chance to the server to remove this
// "client" from its state, which may otherwise interfere with
// some tests.
time.Sleep(25 * time.Millisecond)
return s
}
panic("Unable to start NATS Server in Go Routine")

View File

@@ -253,6 +253,12 @@ func TestRouteQueueSemantics(t *testing.T) {
defer client.Close()
// Make sure client connection is fully processed before creating route
// connection, so we are sure that client ID will be "2" ("1" being used
// by the connection created to check the server is started)
clientSend("PING\r\n")
clientExpect(pongRe)
route := createRouteConn(t, opts.ClusterHost, opts.ClusterPort)
defer route.Close()

View File

@@ -104,6 +104,10 @@ func RunServerWithAuth(opts *server.Options, auth server.Auth) *server.Server {
continue
}
conn.Close()
// Wait a bit to give a chance to the server to remove this
// "client" from its state, which may otherwise interfere with
// some tests.
time.Sleep(25 * time.Millisecond)
return s
}
panic("Unable to start NATS Server in Go Routine")
@@ -133,6 +137,10 @@ func startServer(t tLogger, port int, other string) *natsServer {
}
} else {
c.Close()
// Wait a bit to give a chance to the server to remove this
// "client" from its state, which may otherwise interfere with
// some tests.
time.Sleep(25 * time.Millisecond)
break
}
}
@@ -210,8 +218,11 @@ func checkSocket(t tLogger, addr string, wait time.Duration) {
time.Sleep(50 * time.Millisecond)
continue
}
// We bound to the addr, so close and return.
conn.Close()
// Wait a bit to give a chance to the server to remove this
// "client" from its state, which may otherwise interfere with
// some tests.
time.Sleep(25 * time.Millisecond)
return
}
// We have failed to bind the socket in the time allowed.