jonathanstowe / CheckSocket

very simple Raku function to test if a TCP socket is listening on a given address
Artistic License 2.0
2 stars 1 forks source link

If localhost is set to "::1", CheckSocket tests will fail. #1

Open Xliff opened 8 years ago

Xliff commented 8 years ago

Here is the resulting failure.

==> Testing CheckSocket t/001-use.t ... ok

start server on port 5000

Failed test 'check-socket - port 50000 numeric IP'

at t/002-func.t line 36

Looks like you failed 1 test of 6

t/002-func.t .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/6 subtests

Test Summary Report

t/002-func.t (Wstat: 256 Tests: 6 Failed: 1) Failed test: 6 Non-zero exit status: 1 Files=2, Tests=7, 2 wallclock secs ( 0.02 usr 0.00 sys + 2.45 cusr 0.12 csys = 2.59 CPU) Result: FAIL The spawned process exited unsuccessfully (exit code: 1) in sub run-and-gather-output at /root/.rakudobrew/moar-nom/install/share/perl6/site/sources/24811C576EF8F85E7672B26955C802BB2FC94675 line 85 in block at /root/.rakudobrew/moar-nom/install/share/perl6/site/sources/48E2EB9144E069353B240AD2D147B48C65F70152 line 22 in sub indir at /root/.rakudobrew/moar-nom/install/share/perl6/site/sources/24811C576EF8F85E7672B26955C802BB2FC94675 line 20 in method test at /root/.rakudobrew/moar-nom/install/share/perl6/site/sources/48E2EB9144E069353B240AD2D147B48C65F70152 line 5 in method install at /root/.rakudobrew/moar-nom/install/share/perl6/site/sources/582CB7486602954A4601BDCE5A0EAC54B05DA58A line 156 in block at /root/.rakudobrew/moar-nom/install/share/perl6/site/sources/582CB7486602954A4601BDCE5A0EAC54B05DA58A line 229 in method resolve at /root/.rakudobrew/moar-nom/install/share/perl6/site/sources/582CB7486602954A4601BDCE5A0EAC54B05DA58A line 223 in sub MAIN at /root/.rakudobrew/moar-nom/install/share/perl6/site/resources/E0D978079BB5081DE986D058BB8AB08252F05CC8 line 18 in block at /root/.rakudobrew/moar-nom/install/share/perl6/site/resources/E0D978079BB5081DE986D058BB8AB08252F05CC8 line 152

Xliff commented 8 years ago

The easy fix is to remove "localhost" from the "::1" definition in /etc/hosts, however rather than having that done, maybe the test can correct this so that a system change isn't necessary?

Thanks,

Xliff commented 8 years ago

Supplemental:

if "localhost" resolves to both "127.0.0.1" AND to "::1", the test will fail. If "localhost" resolves to just "127.0.0.1", the test passes.

jonathanstowe commented 8 years ago

Strangely, on a FreeBSD machine that is configured with both 4 & 6 addresses as 'localhost' it works.

The problem is that there is no built-in way to know which one you are going to get, and the only way of forcing the choice of v4/v6 is by using a numeric IP on the test server, and then the client fails because it gets the v6 address first :(

SooOOOoo I'm going to TODO the test for the time being and add a note on the https://rt.perl.org/Ticket/Display.html?id=123282 on the way that v6 is dealt with :)