libwww-perl / WWW-Mechanize

Handy web browsing in a Perl object
https://metacpan.org/pod/WWW::Mechanize
Other
68 stars 52 forks source link

WWW::Mechanize: t/local/referer.t hangs during automated testing #281

Open jkeenan opened 5 years ago

jkeenan commented 5 years ago

Today I tested WWW-Mechanize as part of the CPAN-River-3000 against perl-5.31.3. The test named in the subject line hung indefinitely:

{
  author => "OALDERS",
  dist => "WWW-Mechanize",
  distname => "WWW-Mechanize-1.91",
  distversion => 1.91,
  grade => "FAIL",
  prereqs => undef,
  test_output => [
    "Building and testing WWW-Mechanize-1.91",
    "cp lib/WWW/Mechanize/Link.pm blib/lib/WWW/Mechanize/Link.pm",
    "cp lib/WWW/Mechanize/FAQ.pod blib/lib/WWW/Mechanize/FAQ.pod",
    "cp lib/WWW/Mechanize/Image.pm blib/lib/WWW/Mechanize/Image.pm",
    "cp lib/WWW/Mechanize.pm blib/lib/WWW/Mechanize.pm",
    "cp lib/WWW/Mechanize/Cookbook.pod blib/lib/WWW/Mechanize/Cookbook.pod",
    "cp lib/WWW/Mechanize/Examples.pod blib/lib/WWW/Mechanize/Examples.pod",
    "cp bin/mech-dump blib/script/mech-dump",
...
    "t/local/post.t ........................... ok",
    "Error GETing http://127.0.0.1:17036/: Can't connect to 127.0.0.1:17036 (Connection refused) at t/local/referer.t line 39.",
    "-> FAIL Timed out (> 1800s). Use --verbose to retry.",
  ],
  via => "App::cpanminus::reporter 0.17 (1.7044)",
}

This 30-minute hang caused (a) caused the overall test harness to take 30 minutes longer to complete than would be expected; (b) caused WWW-Mechanize to be graded FAIL, which in turn meant that all of this distros reverse dependencies could not be reached during automated testing.

Could this test be revised so that it is not run during automated testing? Or could the test be made more robust otherwise?

Thank you very much. Jim Keenan

jkeenan commented 5 years ago

This is probably related to: https://github.com/libwww-perl/HTTP-Daemon/issues/33

daniloegea commented 1 year ago

Hi,

I noticed the same problem on Ubuntu during the execution of autopkgtests. It will get stuck on t/local/referer.t. https://autopkgtest.ubuntu.com/results/autopkgtest-mantic/mantic/amd64/libw/libwww-mechanize-perl/20230630_164758_6e12a@/log.gz

Inspecting the process a bit closer showed this:

ubuntu      2084  0.0  0.9  44264 37100 ?        S    13:42   0:00 /usr/bin/perl t/local/referer.t
ubuntu      2085  0.0  0.0   2732  1536 ?        S    13:42   0:00 sh -c "/usr/bin/perl" "/tmp/autopkgtest.WQUrrm/autopkgtest_tmp/smokeDgM2Mo/t/local/referer-server"
ubuntu      2086  0.0  0.3  18396 12928 ?        S    13:42   0:00 /usr/bin/perl /tmp/autopkgtest.WQUrrm/autopkgtest_tmp/smokeDgM2Mo/t/local/referer-server
ubuntu      2140  0.0  0.0   6652  2304 pts/0    S+   15:46   0:00 grep --color=auto perl

referer.t is waiting on referer-server, supposedly at the call to close:

strace: Process 2084 attached
wait4(2085,

referer-server is blocked on accept():

strace: Process 2086 attached
accept4(3,

Unfortunately I don't have any partial output from the execution of referer.t and I can't reproduce it on my machine. The only situation I can get that test to block forever is by not calling /quit-server.

That is the only problematic test, if I skip it, all the other ones will run fine.

Lib versions

ii  libwww-mechanize-perl            2.17-1                                  all          module to automate interaction with websites
ii  libwww-perl                      6.71-1                                  all          simple and consistent interface to the world-wide web
ii  libhttp-daemon-perl              6.16-1                                  all          simple http server class
jkeenan commented 1 year ago

Today I successfully install WWW::Mechanize 2.17 against perl-5.38.0 on FreeBSD-12. I used cpan as the installer, however I also ran the module's test suite using cpanm --test-only and all tests PASSed.

I'm no longer running the CPAN-River-3000 program mentioned in the first post nearly four years ago, so I cannot say whether this module would run smoothly in that program or not. The report from @daniloegea suggests that the more highly automated the testing program is, the greater the likelihood that t/local/referer.t will hang. However, WWW::Mechanize and its prerequisites have all had fresh CPAN releases in recent years, so I don't know what else to suggest.