Commit Graph

76 Commits

Author SHA1 Message Date
Tyler Treat
6e3f58f48c Fix tests and cleanup log output 2017-06-14 10:38:21 -05:00
Peter Miron
00744ff426 converted MonitorAddr and ClusterAddr to *net.TCPAddr 2017-06-12 17:40:36 -04:00
Peter Miron
d1f38f38a2 changes to support random ports for clusters and profiler. 2017-06-10 10:35:01 -04:00
Peter Miron
f2a9cc8cb0 fixed go fmt'ing 2017-06-08 11:37:23 -04:00
Peter Miron
43a3f1ef1d cleaned up naming to MonitorAddr instead of HttpPort (as it could be either Http or Https). added test for nil to improve coverage. 2017-06-08 10:46:55 -04:00
Peter Miron
41aa44cd8d Added ability to use random ports to limit unit test port contention. 2017-06-08 10:19:56 -04:00
Ivan Kozlovic
1fb9f211ca Added gosimple
- Get gosimple package
- Updated staticcheck's URL
- Moved build and above checks in `before_script` section to fail fast
- Fixed reports from gosimple
2017-01-25 13:30:11 -07:00
Ivan Kozlovic
95d0152449 [ADDED] Make Write deadline configurable
We use a hardcoded value of 2 seconds for Write deadline when
writing data to client's socket.
This PR makes that value configurable.

Question is should we push the setting down to the client's object
to avoid indirection such as client.srv.opts.WriteDeadline?
2017-01-18 20:33:44 -07:00
Ivan Kozlovic
5f471b6e7f Replace GetListenEndpoint() with ReadyForConnections()
The RunServer() function (and the various variants)
call Server.Start() in a go-routine, but do not return until
it has verified that the server is ready to accept connections.
To do so, it use GetListenEndpoint() to get a suitable connect
address (replacing "0.0.0.0" or "::" with localhost - important
on Windows). It then creates a raw TCP connection to ensure the
server is started, repeating the process in case of failure up
to 10 seconds.

This PR replaces this with a function that checks that client
listener, and route listener if configured, are set. This removes
the need to get a connect address and create test tcp connections.

The reason for this change is that NATS Streaming when starting
the NATS Server (unless configured to connect to a remote one)
calls RunServerWithAuth(), which when getting "localhost" from
GetListenEndpoint(), would fail trying to resolve it. This happened
for the NATS Streaming Docker image built with Go 1.7+.
2016-12-09 14:03:45 -07:00
Derek Collison
8fbacaaea1 Cleanup for cluster opts 2016-12-02 14:29:22 -08:00
Waldemar Quevedo
ff2d6d1983 Add function and test for processing sub command args 2016-12-01 18:18:52 -08:00
Ivan Kozlovic
ca268290a6 Perform the check on accept, not in processing CONNECT
This will protect the server from non NATS clients (telnet, etc),
or misbehaving clients that would create the tcp connection but
block before sending the CONNECT.
The drawback is that the client may or may not receive the error
message (in my tests, it was getting only between 10%-20% of times).
2016-12-01 08:48:04 -07:00
Ivan Kozlovic
6bcd324955 [FIXED] Honor max_connections setting
The max_connections config parameter was accepted but the server
would not check this limit when processing client connections.

Resolves #386
2016-11-30 18:20:12 -07:00
Ivan Kozlovic
c543c77c74 Check that 0.0.0.0 or [::] is not returned as a client connect URL 2016-08-17 11:15:05 -06:00
Derek Collison
a31e6b2b77 Merge pull request #324 from nats-io/fix_route_ipv6
[FIXED] Cluster's listener with IPv6
2016-08-12 15:20:36 -07:00
Ivan Kozlovic
3b8412049e [FIXED] Cluster's listener with IPv6
Trying to use IPv6 address for the cluster host would fail.
Also, there were some unclosed channels in case of accept loop
setup failures.

Resolves #323
2016-08-12 15:54:15 -06:00
Ivan Kozlovic
fc7d92a04a [FIXED] When server listens to any interface, return only global IPs
The server was returning all resolved IP addresses, including link
local addresses, which did not make sense for remote clients.

Resolves #321
2016-08-12 14:22:24 -06:00
Ivan Kozlovic
fda5bd7ac7 [ADDED] Server sends INFO with cluster URLs to clients with support
Clients that will be at the ClientProtoInfo protocol level (or above)
will now receive an asynchronous INFO protocol when the server
they connect to adds a *new* route. This means that when the cluster
adds a new server, all clients in the cluster should now be notified
of this new addition.
2016-07-26 10:55:55 -06:00
Colin Sullivan
88af5f193a Add TestTlsCipher. 2016-04-22 15:00:19 -06:00
Derek Collison
f23f55518c gosimple fixes 2016-03-31 07:28:40 -07:00
Ivan Kozlovic
eb0eabff04 Replace all changes with simple 25ms delay after connection close. 2016-02-03 18:58:42 -07:00
Ivan Kozlovic
437458e13e Fix completeConnection + fix monitor test.
Don't check what is sent back. The point is that the client should be fully initialized at this point.
We can't ensure using metrics that the "check" connection is gone since in some tests, the server is started and clients auto-reconnect to it.
For tests that depend on the number of clients connected (such as the monitor one), have specific code for those tests.
2016-02-03 18:08:52 -07:00
Ivan Kozlovic
0a4da78f38 Fix code that checks that server is started + route test
- The raw connection used to check that the server is started now consumes the INFO and sends PING and consumes PONG before returning.
- The route test needs to make sure that the client connection has client id 2. Using PING/PONG before creating route connection to make sure of that.
2016-02-03 15:01:00 -07:00
Ivan Kozlovic
d133e68338 Adapt tests for Travis GCE.
* Add server.GetListenEndpoint() to return options' host and port when server is ready to accept client connections. The server can be asked to pick a random port. This function returns a string of the form "host:port" with the port selected by the net.Listen() call.
* Replace the use of server.Addr() with above function to connect to the starting server (using net.Dial) to check for success. The original issue was that, when no hostname is specified in the configuration, the server uses 0.0.0.0 for the listen address. However, server.Addr() would return "[::]", even on a machine with IPv6 disabled, which would cause the net.Dial call to fail with "network unreachable".
2015-12-10 13:06:18 -07:00
Derek Collison
ed9d7337ce More route tests 2015-06-16 10:57:47 -07:00
Derek Collison
19f2427c10 additional test coverage 2015-06-16 09:08:03 -07:00