Bug #6573

Webrick test failures

Added by Bohuslav Kabrda almost 2 years ago. Updated 5 months ago.

[ruby-core:45563]
Status:Assigned
Priority:Normal
Assignee:Hiroshi Nakamura
Category:-
Target version:next minor
ruby -v:ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] Backport:

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):

50) Failure:
testcgi(TestWEBrickCGI) [/builddir/build/BUILD/ruby-1.9.3-p194/test/webrick/testcgi.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
<"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">\n\n Internal Server Error\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:
testscriptdisclosure(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!

ruby-1.9.3.p195-fix-webrick-tests.patch Magnifier (501 Bytes) Bohuslav Kabrda, 06/22/2012 06:03 PM

History

#2 Updated by Vit Ondruch almost 2 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 :/

#3 Updated by Bohuslav Kabrda almost 2 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.

#4 Updated by Bohuslav Kabrda almost 2 years ago

Minimal reproducer:
1. Don't have ruby installed (no /usr/bin/ruby).
2. Build Ruby and run
$ make test-all TESTS="-v test/webrick/testhttpproxy.rb test/webrick/testcgi.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

#5 Updated by Michael Artz almost 2 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.

#6 Updated by Michael Artz almost 2 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.

#7 Updated by Bohuslav Kabrda almost 2 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!

#8 Updated by Anonymous almost 2 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-27358

Author: 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):

50) Failure:
testcgi(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
<"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">\n\n
Internal Server Error\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:
testscriptdisclosure(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!

http://bugs.ruby-lang.org/

#9 Updated by Michael Artz almost 2 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.

#10 Updated by Bohuslav Kabrda almost 2 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?

#11 Updated by Bohuslav Kabrda almost 2 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.

#12 Updated by Yusuke Endoh almost 2 years ago

  • Status changed from Open to Assigned
  • Assignee set to Hiroshi Nakamura

#13 Updated by Vit Ondruch over 1 year 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.

#14 Updated by Hiroshi Nakamura over 1 year 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.

#15 Updated by Vit Ondruch about 1 year 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 :/

#16 Updated by Vit Ondruch about 1 year ago

The attached patch does not work every time. I went ahead and applied 1) 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

#17 Updated by Yui NARUSE about 1 year ago

  • Target version changed from 1.9.3 to next minor

#18 Updated by Vit Ondruch 5 months ago

Could you please consider applying the patch? Thank you.

Also available in: Atom PDF