sergot / http-useragent

Web user agent class for Perl 6.
MIT License
36 stars 39 forks source link

Some tests still try to use the network even when NETWORK_TESTING is not set #184

Open zoffixznet opened 6 years ago

zoffixznet commented 6 years ago

Spotted this in a travis run:

[...]
# NETWORK_TESTING was not set
t/200-w3-test-encodings.t .. ok
t/210-content-encoding.t ... ok
t/220-binary-content.t ..... ok
t/230-binary-request.t ..... ok
    # Failed test 'right exception type (HTTP::UserAgent::Exception::X::HTTP::Internal)'
    # at /home/travis/.rakudobrew/moar-master/install/share/perl6/precomp/BE65026BFB5249C3382F8EDFB81A28020AC84608.1514511444.50491/C7/C712FE6969F786C9380D643DF17E85D06868219E line 1
    # Expected: HTTP::UserAgent::Exception::X::HTTP::Internal
    # Got:      X::AdHoc
    # Exception message: Could not connect socket: Connection refused
    # Looks like you failed 1 test of 3
# Failed test 'throws the correct exception'
# at t/250-issue-144.t line 28
# Looks like you failed 1 test of 1
t/250-issue-144.t .......... 
[...]
bbkr commented 6 years ago

This breaks CI for other modules using HTTP::UserAgent: https://travis-ci.org/bbkr/jsonrpc/jobs/351673499 .

zostay commented 6 years ago

Assuming I'm reading the code correctly, NETWORK_TESTING is a red herring. This problem has nothing to do with that.

I am running into this here: https://travis-ci.org/zostay/Amazon-DynamoDB/jobs/412756488

Looking at how the server is startup, my guess is that there's either a problem with how the test selects an available port or the timing. I suspect a timing issue. Since the server is running in a separate thread, it does not appear to be the case that the code guarantees that the server is running before it tries to contact it.

zostay commented 6 years ago

Looking through the build history of HTTP::UserAgent, the error occurs there too. For example,

https://travis-ci.org/sergot/http-useragent/builds/341064491