Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use exact IPv4/IPv6 address in test_run:cmd() #197

Merged
merged 1 commit into from Dec 31, 2019

Conversation

Totktonada
Copy link
Member

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.

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.

[1]: https://lists.tarantool.org/pipermail/tarantool-patches/2019-December/013321.html
[2]: https://github.com/gevent/gevent/blob/ba3b15de7eb568fa09fdf1a9d28241288163ba67/src/gevent/baseserver.py#L406-L409
[3]: https://tools.ietf.org/rfc/rfc3484.txt
@Totktonada Totktonada added the bug Something isn't working label Dec 25, 2019
Copy link
Contributor

@avtikhon avtikhon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change seems clear and reasonable, so LGTM, please commit.

@Totktonada Totktonada merged commit b23eeb7 into master Dec 31, 2019
@Totktonada Totktonada deleted the Totktonada/use-exact-address-in-test-run-cmd branch December 31, 2019 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants