Wednesday, July 22, 2009

Multi-threaded JRuby-rack/Sinatra Testing

Based on similar test source in JRuby, I came up with a sample multi-threaded Rack test that works with our Sinatra app. This doesn't expose an issue that we were recently seeing during load testing (when using Warbler, Tomcat 5.5, running on server). It should definitely not be a substitute for load testing (for example: via JMeter). However, maybe it might be of use in determining other thread-related issues. This starts 100 threads and each thread hits the service 1000 times:
  def test_multiple_threads_testing_a_sinatra_service
    th = []
    100.times do  
      th << {
        1000.times do      
          post '/myservice', :myreqparam1 => 'blah', :myreqparam2 => 'blah', :myreqparam3 => 'blah'
          assert last_response.ok?, 'got error code from hitting service'
    th.each do |t|

No comments: