Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httpclient testsuite doesn't run #689

Closed
nahi opened this issue Feb 18, 2011 · 15 comments
Closed

httpclient testsuite doesn't run #689

nahi opened this issue Feb 18, 2011 · 15 comments

Comments

@nahi
Copy link

nahi commented Feb 18, 2011

httpclient testsuite uses HTTPClient as a socket client and WEBrick as a socket server. Single testcase runs fine but if I try run 2 or more testcases, it fails.

0% rbx -v -Ilib test/test_httpclient.rb -n test_agent_name             
rubinius 1.2.1 (1.8.7 release 2011-02-15 JI) [x86_64-unknown-linux-gnu]
Loaded suite test/test_httpclient
Started
.
Finished in 0.23560699999999998 seconds.

1 tests, 2 assertions, 0 failures, 0 errors

0% rbx -v -Ilib test/test_httpclient.rb -n test_agent_name -n test_from
rubinius 1.2.1 (1.8.7 release 2011-02-15 JI) [x86_64-unknown-linux-gnu]
Loaded suite test/test_httpclient
Started
.EE
Finished in 0.18129700000000004 seconds.

  1) Error:
test_from(TestHTTPClient):
Errno::EADDRINUSE: Address already in use - bind(2)
    kernel/common/errno.rb:16:in `handle'
    /home/nahi/ruby/rubinius-1.2.1/lib/socket.rb:1081:in `tcp_setup'
    /home/nahi/ruby/rubinius-1.2.1/lib/socket.rb:1118:in `initialize'
    /home/nahi/ruby/rubinius-1.2.1/lib/webrick/utils.rb:73:in `create_listeners'
    kernel/bootstrap/array.rb:71:in `each'
    /home/nahi/ruby/rubinius-1.2.1/lib/webrick/utils.rb:70:in `create_listeners'
    /home/nahi/ruby/rubinius-1.2.1/lib/webrick/server.rb:75:in `listen'
    /home/nahi/ruby/rubinius-1.2.1/lib/webrick/server.rb:63:in `initialize'
    /home/nahi/ruby/rubinius-1.2.1/lib/webrick/httpserver.rb:24:in `initialize'
    test/test_httpclient.rb:1260:in `setup_server'
    test/test_httpclient.rb:26:in `setup'
    kernel/bootstrap/array.rb:71:in `each'
    kernel/bootstrap/array.rb:71:in `each'

  2) Error:
test_from(TestHTTPClient):
NoMethodError: undefined method `reset_all' on nil:NilClass.
    kernel/delta/kernel.rb:85:in `reset_all (method_missing)'
    test/test_httpclient.rb:1295:in `teardown_client'
    test/test_httpclient.rb:31:in `teardown'
    kernel/bootstrap/array.rb:71:in `each'
    kernel/bootstrap/array.rb:71:in `each'

2 tests, 2 assertions, 0 failures, 2 errors
1% 

It looks that WEBrick server doesn't terminated properly at teardown.
https://github.com/nahi/httpclient/blob/master/test/test_httpclient.rb#L1287

Steps to reproduce:

  1. git clone git://github.com/nahi/httpclient.git
  2. cd httpclient
  3. rbx -v -Ilib test/test_httpclient.rb -n test_agent_name -n test_from

P.S. It runs fine on CRuby and JRuby.

0% ruby187 -v -Ilib test/test_httpclient.rb -n test_agent_name
ruby 1.8.7 (2010-12-23 patchlevel 330) [x86_64-linux]
Loaded suite test/test_httpclient
Started
.
Finished in 0.029171 seconds.

1 tests, 2 assertions, 0 failures, 0 errors

0% ruby -v -Ilib test/test_httpclient.rb -n test_agent_name 
ruby 1.9.3dev (2011-02-05 trunk 30801) [x86_64-linux]
test/test_httpclient.rb:1189: warning: assigned but unused variable - server_thread
Run options: -n test_agent_name

# Running tests:

.

Finished tests in 0.165934s, 6.0265 tests/s, 12.0530 assertions/s.

1 tests, 2 assertions, 0 failures, 0 errors, 0 skips

0% jruby -v -Ilib test/test_httpclient.rb -n test_agent_name
jruby 1.6.0.RC2 (ruby 1.8.7 patchlevel 330) (2011-02-18 a265ce6) (Java HotSpot(TM) 64-Bit Server VM 1.7.0-ea) [linux-amd64-java]
Loaded suite test/test_httpclient
Started
.
Finished in 0.828 seconds.

1 tests, 2 assertions, 0 failures, 0 errors
@brixen
Copy link
Member

brixen commented Feb 18, 2011

The two tests are running in OS X 10.5 for me. I see you're on a 64bit Linux. Which distro is that?

@brixen
Copy link
Member

brixen commented Feb 18, 2011

Also, how have you built rbx--from a clone, using rvm?

@nahi
Copy link
Author

nahi commented Feb 18, 2011

Sorry, I should have written that. Ubuntu 10.10.

% uname -a
Linux ubuntu 2.6.35-25-generic #44-Ubuntu SMP Fri Jan 21 17:40:44 UTC 2011 x86_64 GNU/Linux

It's a VMware guest running on Windows 7 as a host.

With adding '@server_thread.kill if @server_thread' at teardown_server, it runs fine but it takes long time to finish. Timing issue?

Sorry for an newbie question, is there some config option to change Thread scheduling in Rubinius?

@nahi
Copy link
Author

nahi commented Feb 18, 2011

I built rbx from 1.2.1 tarball. IIRC...

% wget rubinius-1.2.1-20110215.tar.gz
% gzip -dc rubinius-1.2.1-20110215.tar.gz | tar xvf -
% cd rubinius-1.2.1
% ./configure
% rake # without 'install'
% bin/rbx -v

@brixen
Copy link
Member

brixen commented Feb 18, 2011

So, e.g.

rbx -v -Ilib test/test_httpclient.rb -n test_agent_name -n test_from -n test_host_given -n test_host_header

runs fine for me on OSX but just running all the specs in test_httpclient.rb takes a really long time. I'm looking at that.

I'll try running on ubunto 10.10 64bit.

There is no way exposed to change the Thread scheduling.

@brixen
Copy link
Member

brixen commented Feb 18, 2011

Ahh, I see the race in teardown_server and the different timings on Linux made this show up.

Would you mind trying to profile the slow code (ie use -Xprofile on an extraction of code from the tests) to help us track that down?

@nahi
Copy link
Author

nahi commented Feb 18, 2011

  • On my Ubuntu64 10.10 box, no slowdown occurs. It just fails quickly as I posted above
  • With adding '@server_thread.kill if @server_thread' at teardown_server, it runs too slow (possibly stuck?) So I cannot get -Xprofile data.

Here's a -Xprofile result from 'no slow down' code. I didn't add Thread#kill.

% rbx -Xprofile -v -Ilib test/test_httpclient.rb -n test_agent_name -n test_from 
rubinius 1.2.1 (1.8.7 release 2011-02-15) [x86_64-unknown-linux-gnu]
Loaded suite test/test_httpclient
Started
.EE
Finished in 0.213754 seconds.

  1) Error:
test_from(TestHTTPClient):
Errno::EADDRINUSE: Address already in use - bind(2)
    kernel/common/errno.rb:16:in `handle'
    /home/nahi/ruby/rubinius-1.2.1/lib/socket.rb:1081:in `tcp_setup'
    /home/nahi/ruby/rubinius-1.2.1/lib/socket.rb:1118:in `initialize'
    /home/nahi/ruby/rubinius-1.2.1/lib/webrick/utils.rb:73:in `create_listeners'
    kernel/bootstrap/array.rb:71:in `each'
    /home/nahi/ruby/rubinius-1.2.1/lib/webrick/utils.rb:70:in `create_listeners'
    /home/nahi/ruby/rubinius-1.2.1/lib/webrick/server.rb:75:in `listen'
    /home/nahi/ruby/rubinius-1.2.1/lib/webrick/server.rb:63:in `initialize'
    /home/nahi/ruby/rubinius-1.2.1/lib/webrick/httpserver.rb:24:in `initialize'
    test/test_httpclient.rb:1260:in `setup_server'
    test/test_httpclient.rb:26:in `setup'
    kernel/bootstrap/array.rb:71:in `each'
    kernel/bootstrap/array.rb:71:in `each'

  2) Error:
test_from(TestHTTPClient):
NoMethodError: undefined method `reset_all' on nil:NilClass.
    kernel/delta/kernel.rb:85:in `reset_all (method_missing)'
    test/test_httpclient.rb:1295:in `teardown_client'
    test/test_httpclient.rb:31:in `teardown'
    kernel/bootstrap/array.rb:71:in `each'
    kernel/bootstrap/array.rb:71:in `each'

2 tests, 2 assertions, 0 failures, 2 errors
Total running time: 1.561285969s

  %   cumulative   self                self     total
 time   seconds   seconds      calls  ms/call  ms/call  name
------------------------------------------------------------
   7.19    0.17      0.11          1   114.52   166.43  ObjectSpace.find_object
   6.34    0.10      0.10          1   100.89   100.89  Rubinius::Channel#receive_timeout
   5.21    0.08      0.08         12     6.92     6.92  GC.collect_young
   3.72    0.06      0.06       5355     0.01     0.01  Rubinius::VM.reset_method_cache
   3.64    0.06      0.06        104     0.56     0.56  Rubinius::CodeLoader#load_compiled_file
   2.14    0.95      0.03      27609     0.00     0.03  Array#each
   1.96    0.12      0.03        404     0.08     0.30  Rubinius::Melbourne#string_to_ast
   1.87    0.09      0.03      12537     0.00     0.01  Array#hash
   1.66    0.03      0.03          1    26.39    26.39  GC.collect_mature
   1.53    0.10      0.02      15454     0.00     0.01  Hash#find_entry
   1.45    0.03      0.02      37420     0.00     0.00  Hash::Entry#match?
   1.44    0.09      0.02      10444     0.00     0.01  Hash#[]=
   1.31    0.14      0.02       3556     0.01     0.04  Rubinius.add_method
   1.29    0.03      0.02      57492     0.00     0.00  Array#<<
   1.13    0.02      0.02        454     0.04     0.04  IO::InternalBuffer#fill
   0.96    0.03      0.02       2033     0.01     0.01  Module#_each_ancestor
   0.89    0.01      0.01          2     7.12     7.12  OpenSSL::X509::Store#add_file
   0.86    0.03      0.01      10344     0.00     0.00  Hash#new_entry
   0.83    0.04      0.01      15616     0.00     0.00  Rubinius::Melbourne::process_transforms<89> {}
   0.82    0.01      0.01      95584     0.00     0.00  Kernel#kind_of?
   0.81    0.06      0.01      14665     0.00     0.00  Array::hash<885> {}
   0.74    0.01      0.01       2501     0.00     0.00  FFI::Platform::POSIX.stat
   0.72    0.04      0.01       3024     0.00     0.01  Rubinius::Tuple#each
   0.71    0.01      0.01     121945     0.00     0.00  Rubinius::Tuple#at
   0.61    0.01      0.01      18917     0.00     0.00  Module::add_ivars<741> {}
   0.56    0.16      0.01      14028     0.00     0.01  Hash#[]
   0.56    0.01      0.01      18660     0.00     0.00  Rubinius::Generator::BasicBlock#add_stack
   0.55    0.01      0.01         22     0.40     0.40  IO#prim_write
   0.54    0.01      0.01      57492     0.00     0.00  Array#set_index
   0.51    0.06      0.01       6144     0.00     0.01  Rubinius::Generator::initialize<184> {}
   0.47    0.02      0.01      19131     0.00     0.00  Enumerable::find_all<436> {}
   0.46    0.01      0.01       5016     0.00     0.00  Array#[]
   0.46    0.03      0.01       1190     0.01     0.03  Hash#each_entry
   0.45    0.12      0.01       2296     0.00     0.05  Rubinius.add_defn_method
   0.44    0.01      0.01      19566     0.00     0.00  Hash#key_index
   0.44    0.01      0.01      16531     0.00     0.00  Type.coerce_to
   0.44    0.01      0.01      78269     0.00     0.00  Kernel#equal?
   0.43    0.01      0.01      73139     0.00     0.00  Rubinius::Tuple#[]
   0.43    0.02      0.01       2753     0.00     0.01  Array#initialize
   0.41    0.05      0.01      42992     0.00     0.00  Class#allocate
   0.41    0.06      0.01       9944     0.00     0.01  Hash#default
   0.40    0.01      0.01          8     0.80     0.80  Socket::Foreign._getaddrinfo
   0.39    0.38      0.01        392     0.02     0.98  Module#module_eval
   0.39    0.01      0.01       3938     0.00     0.00  Rubinius::Tuple#dup
   0.38    0.01      0.01       2455     0.00     0.00  String#[]

2,837 methods omitted

2,882 methods called a total of 1,947,549 times
1% 

@nahi
Copy link
Author

nahi commented Apr 8, 2011

Is this issue closed? I'm misunderstanding github Issues system though...

@brixen
Copy link
Member

brixen commented Apr 8, 2011

I'll reopen the ticket. Each time I commented on it, you closed it in your next comment. :P

@brixen brixen reopened this Apr 8, 2011
@nahi
Copy link
Author

nahi commented May 6, 2011

Oops. Sorry for that. I should have hit 'Comment & Close'...

@steveklabnik
Copy link
Member

Was trying this out, since this is such an old ticket, and here's what I get now:

$ ruby -v -Ilib test/test_httpclient.rb -n test_agent_name -n test_from
rubinius 2.0.0dev (1.8.7 bb18a1fc yyyy-mm-dd JI) [x86_64-apple-darwin10.8.0]
Loaded suite test/test_httpclient
Started
EE
Finished in 0.006546 seconds.

  1) Error:
test_agent_name(TestHTTPClient):
SocketError: nodename nor servname provided, or not known
    /Users/steveklabnik/.rvm/rubies/rbx-head/lib/socket.rb:280:in `getaddrinfo'
    /Users/steveklabnik/.rvm/rubies/rbx-head/lib/socket.rb:541:in `getaddrinfo'
    /Users/steveklabnik/.rvm/rubies/rbx-head/lib/webrick/utils.rb:63:in `create_listeners'
    /Users/steveklabnik/.rvm/rubies/rbx-head/lib/webrick/server.rb:75:in `listen'
    /Users/steveklabnik/.rvm/rubies/rbx-head/lib/webrick/server.rb:63:in `initialize'
    /Users/steveklabnik/.rvm/rubies/rbx-head/lib/webrick/httpserver.rb:24:in `initialize'
    test/test_httpclient.rb:1384:in `setup_server'
    test/test_httpclient.rb:10:in `setup'
    kernel/bootstrap/array.rb:66:in `each'
    kernel/bootstrap/array.rb:66:in `each'

  2) Error:
test_from(TestHTTPClient):
SocketError: nodename nor servname provided, or not known
    /Users/steveklabnik/.rvm/rubies/rbx-head/lib/socket.rb:280:in `getaddrinfo'
    /Users/steveklabnik/.rvm/rubies/rbx-head/lib/socket.rb:541:in `getaddrinfo'
    /Users/steveklabnik/.rvm/rubies/rbx-head/lib/webrick/utils.rb:63:in `create_listeners'
    /Users/steveklabnik/.rvm/rubies/rbx-head/lib/webrick/server.rb:75:in `listen'
    /Users/steveklabnik/.rvm/rubies/rbx-head/lib/webrick/server.rb:63:in `initialize'
    /Users/steveklabnik/.rvm/rubies/rbx-head/lib/webrick/httpserver.rb:24:in `initialize'
    test/test_httpclient.rb:1384:in `setup_server'
    test/test_httpclient.rb:10:in `setup'
    kernel/bootstrap/array.rb:66:in `each'
    kernel/bootstrap/array.rb:66:in `each'

2 tests, 0 assertions, 0 failures, 2 errors

Still works on 1.9.2p290.

@nahi
Copy link
Author

nahi commented Oct 13, 2011

1.2.4 and 2.0.0dev (of now) works for me.


% rbx124 -v -Ilib test/test_httpclient.rb -n test_agent_name -n test_from
rubinius 1.2.4 (1.8.7 release 2011-07-05 JI) [x86_64-unknown-linux-gnu]
Loaded suite test/test_httpclient
Started
..
Finished in 0.057264999999999996 seconds.

2 tests, 4 assertions, 0 failures, 0 errors
% rbx -v -Ilib test/test_httpclient.rb -n test_agent_name -n test_from 
rubinius 2.0.0dev (1.8.7 77af8dea yyyy-mm-dd JI) [x86_64-unknown-linux-gnu]
Loaded suite test/test_httpclient
Started
..
Finished in 0.18953399999999998 seconds.

2 tests, 4 assertions, 0 failures, 0 errors

But when I run whole test like 'rbx -Ilib test/test_httpclient.rb -v', it gets stuck.

% rbx -Ilib test/test_httpclient.rb
Loaded suite test/test_httpclient
Started
.[10 sec]..[180 sec or more and hit ^C]^CAn exception occurred running at_exit handlers
    Thread has been interrupted (Interrupt)

Backtrace:
       { } in Rubinius::Loader#signals at kernel/loader.rb:126
                    Signal.run_handler at kernel/common/signal.rb:68
              Rubinius.received_signal at kernel/delta/rubinius.rb:240
  HTTPClient::Session#read_body_length at lib/httpclient/session.rb+112
          HTTPClient::Session#get_body at lib/httpclient/session.rb:661
               HTTPClient#do_get_block at lib/httpclient.rb:1062
          { } in HTTPClient#do_request at lib/httpclient.rb:866
  HTTPClient#protect_keep_alive_disconnected at lib/httpclient.rb:953
                 HTTPClient#do_request at lib/httpclient.rb:865
                    HTTPClient#request at lib/httpclient.rb:753
                        HTTPClient#get at lib/httpclient.rb:658
     TestHTTPClient#test_broken_header at test/test_httpclient.rb:370
 Test::Unit::TestCase(TestHTTPClient)#run at /home/nahi/git/rubinius/lib/test
                                             /unit/testcase.rb:78
     { } in Test::Unit::TestSuite#run at /home/nahi/git/rubinius/lib/test/unit
                                         /testsuite.rb:34
                            Array#each at kernel/bootstrap/array.rb:66
            Test::Unit::TestSuite#run at /home/nahi/git/rubinius/lib/test/unit
                                         /testsuite.rb:33
     { } in Test::Unit::TestSuite#run at /home/nahi/git/rubinius/lib/test/unit
                                         /testsuite.rb:34
                            Array#each at kernel/bootstrap/array.rb:66
            Test::Unit::TestSuite#run at /home/nahi/git/rubinius/lib/test/unit
                                         /testsuite.rb:33
 Test::Unit::UI::TestRunnerMediator#run_suite at /home/nahi/git/rubinius/lib
                                                 /test/unit/ui
                                                 /testrunnermediator.rb:46
 Test::Unit::UI::Console::TestRunner#start_mediator at /home/nahi/git/rubinius
                                                       /lib/test/unit/ui/console
                                                       /testrunner.rb:67
 Test::Unit::UI::Console::TestRunner#start at /home/nahi/git/rubinius/lib/test
                                              /unit/ui/console/testrunner.rb:41
 Test::Unit::UI::TestRunnerUtilities(Class)#run at /home/nahi/git/rubinius/lib
                                                   /test/unit/ui
                                                   /testrunnerutilities.rb:29
           Test::Unit::AutoRunner#run at /home/nahi/git/rubinius/lib/test/unit
                                         /autorunner.rb:216
           Test::Unit::AutoRunner.run at /home/nahi/git/rubinius/lib/test/unit
                                         /autorunner.rb:12
             { } in Object#__script__ at /home/nahi/git/rubinius/lib/test
                                         /unit.rb:278
         Rubinius::Loader#run_at_exits at kernel/loader.rb:651
             Rubinius::Loader#epilogue at kernel/loader.rb:671
                 Rubinius::Loader#main at kernel/loader.rb:801
zsh: exit 1     /home/nahi/git/rubinius/bin/rbx -Ilib test/test_httpclient.rb

@dbussink
Copy link
Contributor

I've rerun this and I see no longer any hangs in httpclient specs. I do see quite a few failures but all but one seem to be due to hash order dependent tests.

@nahi
Copy link
Author

nahi commented Dec 13, 2011

Thanks! I'll try it today. Yes, the test suite of httpclient contains a Hash order bug (on CRuby 1.8). That's exactly my fault.

@nahi
Copy link
Author

nahi commented Dec 14, 2011

Yey, it works. http://travis-ci.org/#!/nahi/httpclient/jobs/404618
There's one failure from Regexp.quote(str, opt) not supported but I think you don't want bothered by this, because it's encoding related and removed from 1.9. Let me know if you're interested in it.

Thanks @dbussink for letting me know this! Thanks Rubinius team for making it work!

Closing this issue finally.

@nahi nahi closed this as completed Dec 14, 2011
hms pushed a commit to okl/httpclient that referenced this issue Aug 6, 2014
I should say 'httpclient does not run on rbx' at this moment.
 - rubinius/rubinius#689
 - http://travis-ci.org/#!/nahi/httpclient/builds/85213
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants