0
-require File.dirname(__FILE__) + '/../ruby_lib/ebb'
0
-class EbbTest < Test::Unit::TestCase
0
- server = Ebb::Server.new(self, :port => 4044)
0
- STDOUT.reopen "/dev/null", "a"
0
- Process.kill('KILL', @pid)
0
- Net::HTTP.get_response(URI.parse("http://0.0.0.0:4044#{path}"))
0
- Net::HTTP.post_form(URI.parse("http://0.0.0.0:4044#{path}"), data)
0
- commands = env['PATH_INFO'].split('/')
0
- if commands.include?('bytes')
0
- n = commands.last.to_i
0
- raise "bytes called with n <= 0" if n <= 0
0
- body = @@responses[n] || "C"*n
0
- elsif commands.include?('env')
0
- env.delete('rack.input') # delete this because it's hard to marshal
0
- env.delete('rack.errors')
0
- body = Base64.encode64(Marshal.dump(env))
0
- elsif commands.include?('test_post_length')
0
- while chunk = env['rack.input'].read(512)
0
- content_length_header = env['HTTP_CONTENT_LENGTH'].to_i
0
- if content_length_header == input_body.length
0
- body = "Content-Length matches input length"
0
- body = "Content-Length header is #{content_length_header} but body length is #{input_body.length}"
0
- # content_length = #{env['HTTP_CONTENT_LENGTH'].to_i}
0
- # input_body.length = #{input_body.length}"
0
- body = "Undefined url"
0
- [status, {'Content-Type' => 'text/plain'}, body]
0
- [1,10,1000].each do |i|
0
- response = get("/bytes/#{i}")
0
- assert_equal "#{'C'*i.to_i}", response.body
0
- response = get('/blah')
0
- assert_equal "Undefined url", response.body
0
- [1,10,321,123,1000].each do |i|
0
- response = post("/test_post_length", 'C'*i)
0
- assert_equal 200, response.code.to_i, response.body
0
- # this is rough but does detect major problems
0
- r = %x{ab -n 1000 -c 50 -q http://0.0.0.0:4044/bytes/123}
0
- assert r =~ /Requests per second:\s*(\d+)/, r
0
- assert $1.to_i > 100, r
0
- [50,60,100].each do |i|
0
- response = post("/test_post_length", 'C'*1024*i)
0
- assert_equal 200, response.code.to_i, response.body
0
- response = get('/env')
0
- env = Marshal.load(Base64.decode64(response.body))
0
- assert_equal '/env', env['PATH_INFO']
0
- assert_equal '/env', env['REQUEST_PATH']
0
- assert_equal 'HTTP/1.1', env['SERVER_PROTOCOL']
0
- assert_equal 'CGI/1.2', env['GATEWAY_INTERFACE']
0
- assert_equal '0.0.0.0', env['SERVER_NAME']
0
- assert_equal '4044', env['SERVER_PORT']
0
- assert_equal 'GET', env['REQUEST_METHOD']
0
-class EbbRailsTest < Test::Unit::TestCase
0
- # just to make sure there isn't some load error
0
- def test_ebb_rails_version
0
- out = %x{ruby #{Ebb::LIBDIR}/../bin/ebb_rails -v}
0
- assert_match %r{Ebb #{Ebb::VERSION}}, out
0
- # Net::HTTP.get_response(URI.parse("http://0.0.0.0:4043#{path}"))
0
- # def test_starting_with_many_options
0
- # %x{cd /tmp && rails ebb_test && ruby #{Ebb::LIBDIR}/../bin/ebb_rails start -d -e development -c /tmp/ebb_test -u www -g www -P /tmp/ebb.1.pid -p 4043 &}
0
- # assert_equal 200, response.code
0
- # Process.kill('KILL', %x{cat /tmp/ebb.1.pid})
0
-# class SocketTest < Test::Unit::TestCase
0
-# def test_socket_creation
0
-# filename = '/tmp/ebb.socket'
0
-# server = Ebb::Server.new(TestApp.new, {:socket => filename})
0
-# assert File.exists?(filename)
0
-# Process.kill('KILL', @pid)
0
-# assert !File.exists?(filename)
Comments
No one has commented yet.