1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Cleaned up the test suite so it spews less logging. Fixed up the debug access logging so it works.

git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@136 19e92222-5c0b-0410-8929-a290d50e31e9
This commit is contained in:
zedshaw 2006-04-01 09:09:10 +00:00
parent e20a52b735
commit b5b3900abd
6 changed files with 23 additions and 30 deletions

View file

@ -227,7 +227,7 @@ module RequestLog
def process(request,response)
p = request.params
STDERR.puts "#{p['REMOTE_ADDR']} - [#{HttpServer.httpdate(Time.now)}] \"#{p['REQUEST_METHOD']} #{p["REQUEST_URI"]} HTTP/1.1\""
STDERR.puts "#{p['REMOTE_ADDR']} - [#{Mongrel::HttpServer.httpdate(Time.now)}] \"#{p['REQUEST_METHOD']} #{p["REQUEST_URI"]} HTTP/1.1\""
end
end

View file

@ -38,8 +38,8 @@ class Stats
end
# Dump this Stats object with an optional additional message.
def dump(msg = "")
STDERR.puts "[#{@name}] #{msg} : SUM=#@sum, SUMSQ=#@sumsq, N=#@n, MEAN=#{mean}, SD=#{sd}, MIN=#@min, MAX=#@max"
def dump(msg = "", out=STDERR)
out.puts "[#{@name}] #{msg} : SUM=#@sum, SUMSQ=#@sumsq, N=#@n, MEAN=#{mean}, SD=#{sd}, MIN=#@min, MAX=#@max"
end
# Calculates and returns the mean for the data passed so far.

View file

@ -15,6 +15,8 @@ class MongrelDbgTest < Test::Unit::TestCase
def test_tracing_to_log
out = StringIO.new
MongrelDbg::begin_trace(:rails)
MongrelDbg::trace(:rails, "Good stuff")
MongrelDbg::end_trace(:rails)
@ -23,9 +25,9 @@ class MongrelDbgTest < Test::Unit::TestCase
assert File.exist?("log/mongrel_debug/rails.log"), "Didn't make the rails.log file"
assert File.size("log/mongrel_debug/rails.log") > 0, "Didn't write anything to the log."
Class.report_object_creations
Class.report_object_creations(out)
Class.reset_object_creations
Class.report_object_creations
Class.report_object_creations(out)
end
end

View file

@ -39,14 +39,17 @@ class HttpParserTest < Test::Unit::TestCase
end
def test_query_parse
puts HttpRequest.query_parse("zed=1&frank=2").inspect
puts HttpRequest.query_parse("zed=1&zed=2&zed=3&frank=11;zed=45").inspect
res = HttpRequest.query_parse("zed=1&frank=2")
assert res["zed"], "didn't get the request right"
assert res["frank"], "no frank"
assert_equal "1", res["zed"], "wrong result"
assert_equal "2", res["frank"], "wrong result"
puts Benchmark.measure {
10000.times do |i|
g = HttpRequest.query_parse("zed=1&zed=2&zed=3&frank=11").inspect
end
}
res = HttpRequest.query_parse("zed=1&zed=2&zed=3&frank=11;zed=45")
assert res["zed"], "didn't get the request right"
assert res["frank"], "no frank"
assert_equal 4,res["zed"].length, "wrong number for zed"
assert_equal "11",res["frank"], "wrong number for frank"
end

View file

@ -4,13 +4,15 @@ require 'mongrel/stats'
class StatsTest < Test::Unit::TestCase
def test_sampling_speed
out = StringIO.new
s = Stats.new("test")
t = Stats.new("time")
10000.times { s.sample(rand(20)); t.tick }
s.dump("FIRST")
t.dump("FIRST")
s.dump("FIRST", out)
t.dump("FIRST", out)
old_mean = s.mean
old_sd = s.sd
@ -19,8 +21,8 @@ class StatsTest < Test::Unit::TestCase
t.reset
10000.times { s.sample(rand(20)); t.tick }
s.dump("SECOND")
t.dump("SECOND")
s.dump("SECOND", out)
t.dump("SECOND", out)
assert_not_equal old_mean, s.mean
assert_not_equal old_mean, s.sd
end

View file

@ -91,20 +91,6 @@ class URIClassifierTest < Test::Unit::TestCase
end
def test_performance
count = 8500
u = URIClassifier.new
u.register("stuff",1)
res = Benchmark.measure { count.times { u.resolve("stuff") } }
reg_unreg = Benchmark.measure { count.times { u.register("other",1); u.unregister("other"); } }
puts "\nRESOLVE(#{count}): #{res}"
puts "REG_UNREG(#{count}): #{reg_unreg}"
end
def test_uri_branching
u = URIClassifier.new
u.register("/test", 1)