mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 03:24:40 -07:00
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:
@@ -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")
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
13
test/test.go
13
test/test.go
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user