djberg96/net-ping — pull request #34 by ianheggie (2014-03-28 04:30:14+00:00)
Title: Adds extra tests to check timeouts are enforced (and finds some bugs)

I noticed some work has been done on timeouts, so I added extra tests to check timeouts are enforced.

This brings to light two problems:
1. http ping works differently between ruby 1.9.2 and ruby 1.9.3 (1.9.2 doesn't wait for delayed response from a http server, 1.9.3 does) - I am assuming a http ping should discover where a load balancer etc accepts a connection but then for whatever reason a response is not sent back in a timely fashion (server farm hung etc)
2. JRuby - http ping waits forever for http server to respond

I could hive the two problems off into "allowed failure" tests, so the tests pass if no one breaks what already works. (And then add issues that point to the failing tests) Do you want me to do that?

Note - to be complete, the test should be expanded to check connection to an IP#/port that has a drop packet firewall rule (which normally hangs tcp connections for a while). This would require adding a firewall rule to the travis box - what do you think?

I think it is doable, but we need something like BLACK_HOLE_HOST_PORT=192.168.0.122:3333 passed in to the tests, so if set then the tests can assume that that host:port combination will silently drop any packets sent to it, thus causing a tcp connection to hang for some period of time.

I am unsure if we can rely on the IP# in the reserved for document range ( http://tools.ietf.org/html/rfc5737 ) to drop packets rather than returning a connection refused icmp packet. If not, then i would need to consider adding a firewall rule to the test host to drop the packets.

p.s. simple test from my location works:

$ time telnet 192.0.2.12
Trying 192.0.2.12...
telnet: Unable to connect to remote host: Connection timed out

real	2m7.251s
user	0m0.006s
sys	0m0.000s