Commit 9f95e062 authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

removing unused timeout parameter from EventMachine::HttpRequest calls

parent 49d9345e
...@@ -18,13 +18,13 @@ describe "Broadcast Properties" do ...@@ -18,13 +18,13 @@ describe "Broadcast Properties" do
nginx_run_server(config, :timeout => 5) do |conf| nginx_run_server(config, :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub.callback do pub.callback do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + channel_broad_fail).get :head => headers, :timeout => 60 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + channel_broad_fail).get :head => headers
sub_1.callback do |chunk| sub_1.callback do |chunk|
sub_1.response_header.status.should eql(403) sub_1.response_header.status.should eql(403)
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + channel_broad).get :head => headers, :timeout => 60 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + channel_broad).get :head => headers
sub_2.stream do |chunk2| sub_2.stream do |chunk2|
chunk2.should eql("#{conf.header_template}\r\n") chunk2.should eql("#{conf.header_template}\r\n")
EventMachine.stop EventMachine.stop
...@@ -44,12 +44,12 @@ describe "Broadcast Properties" do ...@@ -44,12 +44,12 @@ describe "Broadcast Properties" do
nginx_run_server(config.merge(:broadcast_channel_max_qtd => 2), :timeout => 5) do |conf| nginx_run_server(config.merge(:broadcast_channel_max_qtd => 2), :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub.callback do pub.callback do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + channel_broad1 + '/' + channel_broad2 + '/' + channel_broad3).get :head => headers, :timeout => 60 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + channel_broad1 + '/' + channel_broad2 + '/' + channel_broad3).get :head => headers
sub_1.callback do |chunk| sub_1.callback do |chunk|
sub_1.response_header.status.should eql(403) sub_1.response_header.status.should eql(403)
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + channel_broad1 + '/' + channel_broad2).get :head => headers, :timeout => 60 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + channel_broad1 + '/' + channel_broad2).get :head => headers
sub_2.stream do sub_2.stream do
EventMachine.stop EventMachine.stop
end end
......
This diff is collapsed.
This diff is collapsed.
...@@ -34,12 +34,12 @@ describe "Send Signals" do ...@@ -34,12 +34,12 @@ describe "Send Signals" do
nginx_run_server(config, :timeout => 60) do |conf| nginx_run_server(config, :timeout => 60) do |conf|
EventMachine.run do EventMachine.run do
# create subscriber # create subscriber
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.stream do |chunk| sub_1.stream do |chunk|
response = response + chunk response = response + chunk
if response.strip == conf.header_template if response.strip == conf.header_template
# check statistics # check statistics
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 30 pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_1.callback do pub_1.callback do
pub_1.response_header.status.should eql(200) pub_1.response_header.status.should eql(200)
pub_1.response_header.content_length.should_not eql(0) pub_1.response_header.content_length.should_not eql(0)
...@@ -61,7 +61,7 @@ describe "Send Signals" do ...@@ -61,7 +61,7 @@ describe "Send Signals" do
EM.add_periodic_timer(0.5) do EM.add_periodic_timer(0.5) do
# check statistics again # check statistics again
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 30 pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_4.callback do pub_4.callback do
resp_3 = JSON.parse(pub_4.response) resp_3 = JSON.parse(pub_4.response)
resp_3.has_key?("by_worker").should be_true resp_3.has_key?("by_worker").should be_true
...@@ -70,15 +70,15 @@ describe "Send Signals" do ...@@ -70,15 +70,15 @@ describe "Send Signals" do
conectted_after_reloaded = true conectted_after_reloaded = true
# publish a message # publish a message
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub_2.callback do pub_2.callback do
# add new subscriber # add new subscriber
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers, :timeout => 30 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers
sub_2.stream do |chunk| sub_2.stream do |chunk|
response2 = response2 + chunk response2 = response2 + chunk
if response2.strip == conf.header_template if response2.strip == conf.header_template
# check statistics again # check statistics again
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 30 pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_3.callback do pub_3.callback do
resp_2 = JSON.parse(pub_3.response) resp_2 = JSON.parse(pub_3.response)
...@@ -125,7 +125,7 @@ describe "Send Signals" do ...@@ -125,7 +125,7 @@ describe "Send Signals" do
EventMachine.run do EventMachine.run do
publish_message_inline(channel, {}, body) publish_message_inline(channel, {}, body)
# check statistics # check statistics
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 30 pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_1.callback do pub_1.callback do
pub_1.response_header.status.should eql(200) pub_1.response_header.status.should eql(200)
pub_1.response_header.content_length.should_not eql(0) pub_1.response_header.content_length.should_not eql(0)
...@@ -142,7 +142,7 @@ describe "Send Signals" do ...@@ -142,7 +142,7 @@ describe "Send Signals" do
sleep 5 sleep 5
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do pub_2.callback do
pub_2.response_header.status.should eql(200) pub_2.response_header.status.should eql(200)
pub_2.response_header.content_length.should_not eql(0) pub_2.response_header.content_length.should_not eql(0)
......
...@@ -8,7 +8,7 @@ describe "Publisher Channel id collision" do ...@@ -8,7 +8,7 @@ describe "Publisher Channel id collision" do
nginx_run_server do |conf| nginx_run_server do |conf|
channels.each do |channel| channels.each do |channel|
EventMachine.run do EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel).post :body => 'x', :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel).post :body => 'x'
pub.callback do pub.callback do
pub.response_header.status.should eql(200) pub.response_header.status.should eql(200)
EventMachine.stop EventMachine.stop
......
This diff is collapsed.
...@@ -22,7 +22,7 @@ describe "Publisher Publishing Messages" do ...@@ -22,7 +22,7 @@ describe "Publisher Publishing Messages" do
EventMachine.stop EventMachine.stop
end end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
end end
end end
end end
...@@ -54,7 +54,7 @@ describe "Publisher Publishing Messages" do ...@@ -54,7 +54,7 @@ describe "Publisher Publishing Messages" do
EventMachine.stop EventMachine.stop
end end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
end end
end end
end end
...@@ -89,7 +89,7 @@ describe "Publisher Publishing Messages" do ...@@ -89,7 +89,7 @@ describe "Publisher Publishing Messages" do
end end
end end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
end end
end end
end end
...@@ -145,7 +145,7 @@ describe "Publisher Publishing Messages" do ...@@ -145,7 +145,7 @@ describe "Publisher Publishing Messages" do
EventMachine.stop EventMachine.stop
end end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-Id' => event_id), :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-Id' => event_id), :body => body
end end
end end
end end
...@@ -168,7 +168,7 @@ describe "Publisher Publishing Messages" do ...@@ -168,7 +168,7 @@ describe "Publisher Publishing Messages" do
EventMachine.stop EventMachine.stop
end end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-type' => event_type), :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-type' => event_type), :body => body
end end
end end
end end
...@@ -191,7 +191,7 @@ describe "Publisher Publishing Messages" do ...@@ -191,7 +191,7 @@ describe "Publisher Publishing Messages" do
EventMachine.stop EventMachine.stop
end end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-Ids' => event_id), :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-Ids' => event_id), :body => body
end end
EventMachine.run do EventMachine.run do
...@@ -205,7 +205,7 @@ describe "Publisher Publishing Messages" do ...@@ -205,7 +205,7 @@ describe "Publisher Publishing Messages" do
EventMachine.stop EventMachine.stop
end end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-I' => event_id), :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-I' => event_id), :body => body
end end
end end
end end
...@@ -232,7 +232,7 @@ describe "Publisher Publishing Messages" do ...@@ -232,7 +232,7 @@ describe "Publisher Publishing Messages" do
end end
now = Time.now now = Time.now
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
end end
end end
end end
...@@ -261,8 +261,8 @@ describe "Publisher Publishing Messages" do ...@@ -261,8 +261,8 @@ describe "Publisher Publishing Messages" do
EventMachine.stop EventMachine.stop
end end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
end end
end end
end end
......
...@@ -16,7 +16,7 @@ RSpec.configure do |config| ...@@ -16,7 +16,7 @@ RSpec.configure do |config|
end end
def publish_message_inline(channel, headers, body, &block) def publish_message_inline(channel, headers, body, &block)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub.callback do pub.callback do
fail("Request was not accepted") if pub.response_header.status != 200 fail("Request was not accepted") if pub.response_header.status != 200
block.call unless block.nil? block.call unless block.nil?
...@@ -49,7 +49,7 @@ def create_channel_by_subscribe(channel, headers, timeout=60, &block) ...@@ -49,7 +49,7 @@ def create_channel_by_subscribe(channel, headers, timeout=60, &block)
end end
def publish_message_inline_with_callbacks(channel, headers, body, callbacks = {}) def publish_message_inline_with_callbacks(channel, headers, body, callbacks = {})
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub.callback do pub.callback do
if pub.response_header.status == 200 if pub.response_header.status == 200
callbacks[:success].call(pub.response_header.status, pub.response) unless callbacks[:success].nil? callbacks[:success].call(pub.response_header.status, pub.response) unless callbacks[:success].nil?
......
...@@ -16,7 +16,7 @@ describe "Comunication Properties" do ...@@ -16,7 +16,7 @@ describe "Comunication Properties" do
nginx_run_server(config, :timeout => 5) do |conf| nginx_run_server(config, :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 60 sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub.stream do |chunk| sub.stream do |chunk|
chunk.should eql("#{conf.header_template}\r\n") chunk.should eql("#{conf.header_template}\r\n")
EventMachine.stop EventMachine.stop
...@@ -31,15 +31,15 @@ describe "Comunication Properties" do ...@@ -31,15 +31,15 @@ describe "Comunication Properties" do
nginx_run_server(config.merge(:authorized_channels_only => "on"), :timeout => 5) do |conf| nginx_run_server(config.merge(:authorized_channels_only => "on"), :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 60 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.callback do |chunk| sub_1.callback do |chunk|
sub_1.response_header.status.should eql(403) sub_1.response_header.status.should eql(403)
sub_1.response_header.content_length.should eql(0) sub_1.response_header.content_length.should eql(0)
sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscriber could not create channels.") sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscriber could not create channels.")
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub.callback do pub.callback do
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 60 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_2.stream do |chunk2| sub_2.stream do |chunk2|
chunk2.should eql("#{conf.header_template}\r\n") chunk2.should eql("#{conf.header_template}\r\n")
EventMachine.stop EventMachine.stop
...@@ -58,9 +58,9 @@ describe "Comunication Properties" do ...@@ -58,9 +58,9 @@ describe "Comunication Properties" do
nginx_run_server(config, :timeout => 20) do |conf| nginx_run_server(config, :timeout => 20) do |conf|
EventMachine.run do EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
time_2 = EM.add_timer(2) do time_2 = EM.add_timer(2) do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers, :timeout => 60 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers
sub_1.stream do |chunk| sub_1.stream do |chunk|
response_1 += chunk unless response_1.include?(body) response_1 += chunk unless response_1.include?(body)
sub_1.close if response_1.include?(body) sub_1.close if response_1.include?(body)
...@@ -68,7 +68,7 @@ describe "Comunication Properties" do ...@@ -68,7 +68,7 @@ describe "Comunication Properties" do
end end
EM.add_timer(6) do EM.add_timer(6) do
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers, :timeout => 60 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers
sub_2.stream do |chunk| sub_2.stream do |chunk|
response_2 += chunk unless response_2.include?(body) response_2 += chunk unless response_2.include?(body)
sub_2.close if response_2.include?(body) sub_2.close if response_2.include?(body)
...@@ -77,7 +77,7 @@ describe "Comunication Properties" do ...@@ -77,7 +77,7 @@ describe "Comunication Properties" do
#message will be certainly expired at 15 seconds #message will be certainly expired at 15 seconds
EM.add_timer(16) do EM.add_timer(16) do
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers, :timeout => 60 sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers
sub_3.stream do |chunk| sub_3.stream do |chunk|
response_3 += chunk unless response_3.include?(body) response_3 += chunk unless response_3.include?(body)
sub_3.close if response_3.include?(body) sub_3.close if response_3.include?(body)
...@@ -103,7 +103,7 @@ describe "Comunication Properties" do ...@@ -103,7 +103,7 @@ describe "Comunication Properties" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers, :timeout => 60 sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers
sub.stream do |chunk| sub.stream do |chunk|
response += chunk response += chunk
...@@ -129,7 +129,7 @@ describe "Comunication Properties" do ...@@ -129,7 +129,7 @@ describe "Comunication Properties" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers, :timeout => 60 sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers
sub.stream do |chunk| sub.stream do |chunk|
response += chunk response += chunk
......
...@@ -17,17 +17,17 @@ describe "Subscriber Padding by user agent" do ...@@ -17,17 +17,17 @@ describe "Subscriber Padding by user agent" do
nginx_run_server(config.merge(:header_template => "0123456789"), :timeout => 5) do |conf| nginx_run_server(config.merge(:header_template => "0123456789"), :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1"), :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do sub_1.callback do
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
sub_1.response.size.should eql(1100 + conf.header_template.size + 4) sub_1.response.size.should eql(1100 + conf.header_template.size + 4)
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 2"), :timeout => 30 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 2")
sub_2.callback do sub_2.callback do
sub_2.response_header.status.should eql(200) sub_2.response_header.status.should eql(200)
sub_2.response.size.should eql(4097 + conf.header_template.size + 4) sub_2.response.size.should eql(4097 + conf.header_template.size + 4)
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 3"), :timeout => 30 sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 3")
sub_3.callback do sub_3.callback do
sub_3.response_header.status.should eql(200) sub_3.response_header.status.should eql(200)
sub_3.response.size.should eql(conf.header_template.size + 2) sub_3.response.size.should eql(conf.header_template.size + 2)
...@@ -47,17 +47,17 @@ describe "Subscriber Padding by user agent" do ...@@ -47,17 +47,17 @@ describe "Subscriber Padding by user agent" do
nginx_run_server(config, :timeout => 5) do |conf| nginx_run_server(config, :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1"), :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback { sub_1.callback {
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
sub_1.response.size.should eql(500 + body.size + 4) sub_1.response.size.should eql(500 + body.size + 4)
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 2"), :timeout => 30 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 2")
sub_2.callback { sub_2.callback {
sub_2.response_header.status.should eql(200) sub_2.response_header.status.should eql(200)
sub_2.response.size.should eql(body.size + 2) sub_2.response.size.should eql(body.size + 2)
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 3"), :timeout => 30 sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 3")
sub_3.callback { sub_3.callback {
sub_3.response_header.status.should eql(200) sub_3.response_header.status.should eql(200)
sub_3.response.size.should eql(body.size + 2) sub_3.response.size.should eql(body.size + 2)
...@@ -81,7 +81,7 @@ describe "Subscriber Padding by user agent" do ...@@ -81,7 +81,7 @@ describe "Subscriber Padding by user agent" do
i = 1 i = 1
expected_padding = 545 expected_padding = 545
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1"), :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do sub_1.callback do
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
sub_1.response.size.should eql(expected_padding + i + 4) sub_1.response.size.should eql(expected_padding + i + 4)
...@@ -89,7 +89,7 @@ describe "Subscriber Padding by user agent" do ...@@ -89,7 +89,7 @@ describe "Subscriber Padding by user agent" do
i = 105 i = 105
expected_padding = 600 - ((i/100).to_i * 100) expected_padding = 600 - ((i/100).to_i * 100)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1"), :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do sub_1.callback do
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
sub_1.response.size.should eql(expected_padding + i + 4) sub_1.response.size.should eql(expected_padding + i + 4)
...@@ -97,7 +97,7 @@ describe "Subscriber Padding by user agent" do ...@@ -97,7 +97,7 @@ describe "Subscriber Padding by user agent" do
i = 221 i = 221
expected_padding = 600 - ((i/100).to_i * 100) expected_padding = 600 - ((i/100).to_i * 100)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1"), :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do sub_1.callback do
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
sub_1.response.size.should eql(expected_padding + i + 4) sub_1.response.size.should eql(expected_padding + i + 4)
...@@ -105,7 +105,7 @@ describe "Subscriber Padding by user agent" do ...@@ -105,7 +105,7 @@ describe "Subscriber Padding by user agent" do
i = 331 i = 331
expected_padding = 600 - ((i/100).to_i * 100) expected_padding = 600 - ((i/100).to_i * 100)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1"), :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do sub_1.callback do
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
sub_1.response.size.should eql(expected_padding + i + 4) sub_1.response.size.should eql(expected_padding + i + 4)
...@@ -113,7 +113,7 @@ describe "Subscriber Padding by user agent" do ...@@ -113,7 +113,7 @@ describe "Subscriber Padding by user agent" do
i = 435 i = 435
expected_padding = 600 - ((i/100).to_i * 100) expected_padding = 600 - ((i/100).to_i * 100)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1"), :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do sub_1.callback do
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
sub_1.response.size.should eql(expected_padding + i + 4) sub_1.response.size.should eql(expected_padding + i + 4)
...@@ -121,14 +121,14 @@ describe "Subscriber Padding by user agent" do ...@@ -121,14 +121,14 @@ describe "Subscriber Padding by user agent" do
i = 502 i = 502
expected_padding = 600 - ((i/100).to_i * 100) expected_padding = 600 - ((i/100).to_i * 100)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1"), :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do sub_1.callback do
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
sub_1.response.size.should eql(expected_padding + i + 4) sub_1.response.size.should eql(expected_padding + i + 4)
i = 550 i = 550
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1"), :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do sub_1.callback do
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
sub_1.response.size.should eql(i + 2) sub_1.response.size.should eql(i + 2)
...@@ -157,12 +157,12 @@ describe "Subscriber Padding by user agent" do ...@@ -157,12 +157,12 @@ describe "Subscriber Padding by user agent" do
nginx_run_server(config.merge(:padding_by_user_agent => "[T|t]est 1,1024,512", :user_agent => "$arg_ua", :header_template => "0123456789"), :timeout => 10) do |conf| nginx_run_server(config.merge(:padding_by_user_agent => "[T|t]est 1,1024,512", :user_agent => "$arg_ua", :header_template => "0123456789"), :timeout => 10) do |conf|
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?ua=test 1').get :head => headers, :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?ua=test 1').get :head => headers
sub_1.callback do sub_1.callback do
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
sub_1.response.size.should eql(1024 + conf.header_template.size + 4) sub_1.response.size.should eql(1024 + conf.header_template.size + 4)
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?ua=test 2').get :head => headers, :timeout => 30 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?ua=test 2').get :head => headers
sub_2.callback do sub_2.callback do
sub_2.response_header.status.should eql(200) sub_2.response_header.status.should eql(200)
sub_2.response.size.should eql(conf.header_template.size + 2) sub_2.response.size.should eql(conf.header_template.size + 2)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment