Commit 81c4eea
committed
Fix port collisions in adapter_lint
In order to 'reserve' a free TCP Server port, we create a TCPServer,
take a note of its port number, and then immediately close it.
We'd then ask our adapter to use the port we just finished with via
that adapter's configuration.
While this isn't a particularly safe way of 'reserving' a port,
it's the best we can do with heterogeneous adapters that have a one-way
config method.
However, this would cause intermittent test failures when our 'canary'
socket did not get out of the way in time for an adapter to bind its
server. Socket#close does not actually block until the socket is
closed at OS level, it just frees the Ruby handle to it.
Actually waiting for the socket to become free or garbage-collecting
it to force the issue is counterproductive – we'd need to poll the port
or run a full GC, which would take more time than a
simple sleep. Additionally, the sleep needs to be tuned so that tests
are not unduly slowed by it – too quick and we'll see failures, too
slow and our builds will reflect it.1 parent 07f02c2 commit 81c4eea
1 file changed
+13
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
9 | 21 | | |
10 | 22 | | |
11 | 23 | | |
| |||
0 commit comments