Use exact IPv4/IPv6 address in test_run:cmd() #197
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When test-run's inspector listens on a IPv4 port and some other process
listens on a IPv6 port of the same number, test_run:cmd() could connect
to this process rather then the inspector, because 'localhost' hostname
was used to connect.
Now test-run passes actual IP address of the inspector via an
environment variable and test_run:cmd() uses it to avoid the ambiguity
that is described above.
The problem was found during many parallel runs of app/socket.test.lua
test from tarantool, see case 4 in 1 (untitled, see right under case
3). This test starts many TCP servers and in rare cases a server port
may be the same as inspector's one.
There are two details that increase probability of the problem:
It seems test-run's inspector always listens on IPv4 address, because
it is configured with 'localhost' hostname and
gevent.server.StreamServer implementation always chooses IPv4 for
'localhost' (see 2, _parse_address() function).
socket.tcp_connect() typically tries to connect to an IPv6 address
first and only then to an IPv4 one, because getaddrinfo() returns
addresses in this order according to RFC 3484 (see 3, section 2.1
'Policy table'). This however can be configured in /etc/gai.conf.