tests with Unicorn and Thin for out-of-sync responses
This commit is contained in:
parent
76730d4a7c
commit
4abf6b8875
4
.gitignore
vendored
4
.gitignore
vendored
@ -14,3 +14,7 @@ benchmark
|
|||||||
*#*
|
*#*
|
||||||
*.class
|
*.class
|
||||||
*.swp
|
*.swp
|
||||||
|
*.pid
|
||||||
|
*.log
|
||||||
|
test/load/unicorn/unicorn.rb
|
||||||
|
test/load/thin/config.yml
|
||||||
|
6
test/load/thin/config.ru
Normal file
6
test/load/thin/config.ru
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
require "rubygems"
|
||||||
|
require "sinatra"
|
||||||
|
|
||||||
|
require File.join(File.dirname(__FILE__), 'load.rb')
|
||||||
|
|
||||||
|
run Load
|
6
test/load/thin/config.yml.template
Normal file
6
test/load/thin/config.yml.template
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
require "rubygems"
|
||||||
|
require "sinatra"
|
||||||
|
|
||||||
|
require File.join(File.dirname(__FILE__), 'load.rb')
|
||||||
|
|
||||||
|
run Load
|
24
test/load/thin/load.rb
Normal file
24
test/load/thin/load.rb
Normal file
@ -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
|
6
test/load/unicorn/config.ru
Normal file
6
test/load/unicorn/config.ru
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
require "rubygems"
|
||||||
|
require "sinatra"
|
||||||
|
|
||||||
|
require File.join(File.dirname(__FILE__), 'load.rb')
|
||||||
|
|
||||||
|
run Load
|
23
test/load/unicorn/load.rb
Normal file
23
test/load/unicorn/load.rb
Normal file
@ -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
|
29
test/load/unicorn/unicorn.rb.template
Normal file
29
test/load/unicorn/unicorn.rb.template
Normal file
@ -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
Block a user