tests with Unicorn and Thin for out-of-sync responses
This commit is contained in:
parent
76730d4a7c
commit
4abf6b8875
|
@ -14,3 +14,7 @@ benchmark
|
|||
*#*
|
||||
*.class
|
||||
*.swp
|
||||
*.pid
|
||||
*.log
|
||||
test/load/unicorn/unicorn.rb
|
||||
test/load/thin/config.yml
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
require "rubygems"
|
||||
require "sinatra"
|
||||
|
||||
require File.join(File.dirname(__FILE__), 'load.rb')
|
||||
|
||||
run Load
|
|
@ -0,0 +1,6 @@
|
|||
require "rubygems"
|
||||
require "sinatra"
|
||||
|
||||
require File.join(File.dirname(__FILE__), 'load.rb')
|
||||
|
||||
run Load
|
|
@ -0,0 +1,24 @@
|
|||
require File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'mongo')
|
||||
require 'logger'
|
||||
|
||||
$con = Mongo::Connection.new
|
||||
$db = $con['foo']
|
||||
|
||||
class Load < Sinatra::Base
|
||||
|
||||
configure do
|
||||
LOGGER = Logger.new("sinatra.log")
|
||||
enable :logging, :dump_errors
|
||||
set :raise_errors, true
|
||||
end
|
||||
|
||||
get '/' do
|
||||
3.times do |n|
|
||||
if (v=$db.eval("1 + #{n}")) != 1 + n
|
||||
STDERR << "#{1 + n} expected but got #{v}"
|
||||
raise StandardError, "#{1 + n} expected but got #{v}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
require "rubygems"
|
||||
require "sinatra"
|
||||
|
||||
require File.join(File.dirname(__FILE__), 'load.rb')
|
||||
|
||||
run Load
|
|
@ -0,0 +1,23 @@
|
|||
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'mongo')
|
||||
|
||||
$con = Mongo::Connection.new
|
||||
$db = $con['foo']
|
||||
|
||||
class Load < Sinatra::Base
|
||||
|
||||
configure do
|
||||
LOGGER = Logger.new("sinatra.log")
|
||||
enable :logging, :dump_errors
|
||||
set :raise_errors, true
|
||||
end
|
||||
|
||||
get '/' do
|
||||
3.times do |n|
|
||||
if (v=$db.eval("1 + #{n}")) != 1 + n
|
||||
STDERR << "#{1 + n} expected but got #{v}"
|
||||
raise StandardError, "#{1 + n} expected but got #{v}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# set path to app that will be used to configure unicorn,
|
||||
# # note the trailing slash in this example
|
||||
@dir = "/home/kyle/work/10gen/ruby-driver/test/load/"
|
||||
|
||||
worker_processes 10
|
||||
working_directory @dir
|
||||
|
||||
preload_app true
|
||||
|
||||
timeout 30
|
||||
|
||||
# Specify path to socket unicorn listens to,
|
||||
# we will use this in our nginx.conf later
|
||||
listen "#{@dir}tmp/sockets/unicorn.sock", :backlog => 64
|
||||
|
||||
# Set process id path
|
||||
pid "#{@dir}tmp/pids/unicorn.pid"
|
||||
|
||||
# # Set log file paths
|
||||
stderr_path "#{@dir}log/unicorn.stderr.log"
|
||||
stdout_path "#{@dir}log/unicorn.stdout.log"
|
||||
|
||||
# NOTE: You need this when using forking web servers!
|
||||
after_fork do |server, worker|
|
||||
$con.close if $con
|
||||
$con = Mongo::Connection.new
|
||||
$db = $con['foo']
|
||||
STDERR << "FORKED #{server} #{worker}"
|
||||
end
|
Loading…
Reference in New Issue