Bug #6573
closedWebrick test failures
Description
Hi,
I'm randomly getting test failures for WEBrick with Ruby 1.9.3. The problem seems to be that WEBrick hangs during some test suite executions (I think it may be improperly shut down after previous tests). These are the failures I'm getting (running Fedora 17 x86_64):
- Failure:
test_cgi(TestWEBrickCGI) [/builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/test_cgi.rb:34]:
webrick log start:
[2012-06-11 10:06:35] INFO WEBrick 1.3.1
[2012-06-11 10:06:35] INFO ruby 1.9.3 (2012-04-20) [x86_64-linux]
[2012-06-11 10:06:35] INFO WEBrick::HTTPServer#start: pid=15944 port=40082
[2012-06-11 10:06:35] ERROR CGIHandler: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi exit with 127
[2012-06-11 10:06:35] ERROR Premature end of script headers: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi
webrick log end.
<"/webrick.cgi"> expected but was
<"\n\n
Internal Server Error¶
\n Premature end of script headers: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi\n\n \n WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20) OpenSSL/1.0.1c at\n 127.0.0.1:40082\n \n \n\n">.
51) Failure:
test_script_disclosure(WEBrick::TestFileHandler) [/builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/test_filehandler.rb:265]:
webrick log start:
[2012-06-11 10:06:49] INFO WEBrick 1.3.1
[2012-06-11 10:06:49] INFO ruby 1.9.3 (2012-04-20) [x86_64-linux]
[2012-06-11 10:06:49] INFO WEBrick::HTTPServer#start: pid=15944 port=34515
[2012-06-11 10:06:49] ERROR CGIHandler: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi exit with 127
[2012-06-11 10:06:49] ERROR Premature end of script headers: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi
webrick log end.
<"200"> expected but was
<"500">.
Here is the full build log from Fedora's Koji: http://koji.fedoraproject.org/koji/getfile?taskID=4148723&name=build.log
Is anyone experiencing the same failures
Thanks!
Files
Updated by vo.x (Vit Ondruch) over 12 years ago
It seems that the same issues are facing Debian guys: https://buildd.debian.org/status/fetch.php?pkg=ruby1.9.1&arch=armhf&ver=1.9.3.194-1&stamp=1338887114
Updated by vo.x (Vit Ondruch) over 12 years ago
vo.x (Vit Ondruch) wrote:
It seems that the same issues are facing Debian guys: https://buildd.debian.org/status/fetch.php?pkg=ruby1.9.1&arch=armhf&ver=1.9.3.194-1&stamp=1338887114
Arrgh, the Debian error is something different: http://bugs.ruby-lang.org/issues/5135 sorry for confusion :/
Updated by Anonymous over 12 years ago
Hmm, actually it seems that the tests don't fail randomly; The error seems to be:
NameError: uninitialized constant TestWEBrickCGI::RubyBin
Which then forces the webrick.cgi to use /usr/bin/ruby, which is not found during the build, if Ruby are not installed.
Updated by Anonymous over 12 years ago
Minimal reproducer:
- Don't have ruby installed (no /usr/bin/ruby).
- Build Ruby and run
$ make test-all TESTS="-v test/webrick/test_httpproxy.rb test/webrick/test_cgi.rb test/webrick/test_filehandler.rb"
The test_httpproxy.rb seems to cause this. Strangely, when I comment out 3 its requires (webrick, webrick/httpproxy, webrick/ssl), all its test still run and pass and so do the two, that I reported to fail. So it seems that this issue is hidden somewhere in these 3 requires. It really puzzles me that all of these 3 requires must be commented out, in order for the tests to pass.
When running with "-v", the failing tests also print
sh: /usr/bin/ruby: No such file or directory
Updated by mlartz (Michael Artz) over 12 years ago
I'm seeing the same behavior with CentOS 6.2, both using your (Fedora's) RPM spec file and building Ruby from scratch.
Based on @bkabrada's "fixes" via commenting the webrick 'requires's, I dug a little deeper. It looks like "require '../ruby/envutil'" needs to come before any of the webrick 'require's, as that is where RubyBin is set up. This, along with all of the webrick 'require's (i.e. webrick, webrick/https, webrick/httpproxy) is all done in 'utils.rb'. Luckily, this is required in 'test_httpproxy.rb', however it is after the webrick requires, which seems to be why commenting out the require statements worked ... they were getting required anyway in utils.rb.
Unfortunately, all of the above works when the webrick tests are executed alone (make yes-test-all TESTS="-v test/webrick/test*.rb"), but they still fail when executed with the entire test suite (make yes-test-all). So I'm stumped.
Updated by mlartz (Michael Artz) over 12 years ago
It appears that WEBrick::HTTPServlet::CGIHandler (webrick/httpservlet/cgihandler.rb) file embeds RbConfig.ruby into a constant when the file is required. test/ruby/envutil.rb monkeypatches RbConfig.ruby to use the newly compiled Ruby. If, however, webrick gets 'require'd before test/ruby/envutil, then the internal CGIHandler constant has already been set.
So there is a simple fix, but I'm not sure if its the right one (although it feels right). Put the following line into test/runner.rb:
require_relative 'ruby/envutil'
which should setup the environment for all the tests, which is what I think we want.
The not-so-simple solution is to find the offending webrick-requiring test and update it to require ruby/envutil before it requires webrick. This seems like unnecessary work, assuming that the previous solution is sufficient.
I'm not in a place where I can provide a patch at the moment, so I'm hoping that someone else can finalize this.
Updated by Anonymous over 12 years ago
Michael, thanks, a very helpful information. I believe that the patch you are proposing is correct, yet I would prefer a different approach (attaching). A little problem that I see with your proposed patch that it alters environment for many tests, it seems to be too global. Therefore I would only propose modifying test_httpproxy.rb to require utils.rb in the first place, that fixes all.
Could someone review/commit this patch (and possibly to other releases/versions of Ruby too)?
Thanks!
Updated by Anonymous over 12 years ago
r
On Fri, Jun 22, 2012 at 1:03 PM, bkabrda (Bohuslav Kabrda) <
bkabrda@redhat.com> wrote:
Issue #6573 has been updated by bkabrda (Bohuslav Kabrda).
File ruby-1.9.3.p195-fix-webrick-tests.patch added
Michael, thanks, a very helpful information. I believe that the patch you
are proposing is correct, yet I would prefer a different approach
(attaching). A little problem that I see with your proposed patch that it
alters environment for many tests, it seems to be too global. Therefore I
would only propose modifying test_httpproxy.rb to require utils.rb in the
first place, that fixes all.
Could someone review/commit this patch (and possibly to other
releases/versions of Ruby too)?
Thanks!Bug #6573: Webrick test failures
https://bugs.ruby-lang.org/issues/6573#change-27358Author: bkabrda (Bohuslav Kabrda)
Status: Open
Priority: Normal
Assignee:
Category:
Target version: 1.9.3
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]Hi,
I'm randomly getting test failures for WEBrick with Ruby 1.9.3. The
problem seems to be that WEBrick hangs during some test suite executions (I
think it may be improperly shut down after previous tests). These are the
failures I'm getting (running Fedora 17 x86_64):
- Failure:
test_cgi(TestWEBrickCGI)
[/builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/test_cgi.rb:34]:
webrick log start:
[2012-06-11 10:06:35] INFO WEBrick 1.3.1
[2012-06-11 10:06:35] INFO ruby 1.9.3 (2012-04-20) [x86_64-linux]
[2012-06-11 10:06:35] INFO WEBrick::HTTPServer#start: pid=15944
port=40082
[2012-06-11 10:06:35] ERROR CGIHandler:
/builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi exit with 127
[2012-06-11 10:06:35] ERROR Premature end of script headers:
/builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgiwebrick log end.
<TITLE>Internal Server Error</TITLE>\n \n
<"/webrick.cgi"> expected but was
<"\n\nInternal Server Error¶
\n Premature end of script headers: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi\n
\n \n WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20) OpenSSL/1.0.1c at\n 127.0.0.1:40082\n \n \n\n">. 51) Failure: test_script_disclosure(WEBrick::TestFileHandler) [/builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/test_filehandler.rb:265]: webrick log start: [2012-06-11 10:06:49] INFO WEBrick 1.3.1 [2012-06-11 10:06:49] INFO ruby 1.9.3 (2012-04-20) [x86_64-linux] [2012-06-11 10:06:49] INFO WEBrick::HTTPServer#start: pid=15944 port=34515 [2012-06-11 10:06:49] ERROR CGIHandler: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi exit with 127 [2012-06-11 10:06:49] ERROR Premature end of script headers: /builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/webrick.cgi webrick log end. <"200"> expected but was <"500">.Here is the full build log from Fedora's Koji:
http://koji.fedoraproject.org/koji/getfile?taskID=4148723&name=build.logIs anyone experiencing the same failures
Thanks!
Updated by mlartz (Michael Artz) over 12 years ago
Unfortunately, like I mentioned earlier, just doing this for test_httpproxy.rb fixed it when just running webrick tests, but still failed when running the entire test suite, as some other non-webrick test includes webrick without first including envutils. I think that my solution is the right one, since all tests should want to have the local version of Ruby, which is about all that envutils does. I used your spec file (plus my fix) to successfully build a ruby 1.9.3 for CentOS 6.
Updated by Anonymous over 12 years ago
Hmm, it is strange that I don't have any problems building with my patch - all tests pass for me. Are you sure you didn't make any further adjustments?
Updated by Anonymous over 12 years ago
Thinking of it further, I realized that this may be caused by order in which tests are required - and I think that they aren't required in the same order every time. So maybe I was just lucky when running test suite. But your proposed solution should make the tests pass every time.
Updated by mame (Yusuke Endoh) over 12 years ago
- Status changed from Open to Assigned
- Assignee set to nahi (Hiroshi Nakamura)
Updated by vo.x (Vit Ondruch) about 12 years ago
Can somebody look into this issue, please? This is very annoying bug. When I am doing build for Fedora or Red Hat Enterprise Linux, it builds for more platforms at once in parallel, so there is higher chance to fail. Now I am doing already 4th attempt but this bug always hits me :/ Thank you.
Updated by nahi (Hiroshi Nakamura) about 12 years ago
Thanks to bkabrda and mlartz's minimal reproducer and the investigation, I could easily understand the issue.
I think we should fix this by avoiding RbConfig.ruby caching at cgihandler.rb. Let me try.
Updated by vo.x (Vit Ondruch) almost 12 years ago
Could somebody please do something about this bug? I am sad that although this was reported almost 8 months ago and triaged including patch, it is still not fixed. Sometimes I have feeling that it would be faster to ask committer rights myself :/
Updated by vo.x (Vit Ondruch) almost 12 years ago
The attached patch does not work every time. I went ahead and applied [1] (i.e. the patch described in comment 6, if I got it correctly ;)) for Fedora and so far so good.
[1] http://pkgs.fedoraproject.org/cgit/ruby.git/tree/ruby-1.9.3.p195-fix-webrick-tests.patch
Updated by naruse (Yui NARUSE) almost 12 years ago
- Target version changed from 1.9.3 to 2.6
Updated by vo.x (Vit Ondruch) about 11 years ago
Could you please consider applying the patch? Thank you.
Updated by hsbt (Hiroshi SHIBATA) over 10 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
Applied in changeset r46160.
- test/runner.rb: fixed randomly test failure.
[Bug #6573][ruby-core:45563]