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
......
...@@ -10,7 +10,7 @@ describe "Channel Statistics" do ...@@ -10,7 +10,7 @@ describe "Channel Statistics" do
nginx_run_server(config, :timeout => 5) do |conf| nginx_run_server(config, :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 30 pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_1.callback do pub_1.callback do
pub_1.response_header.status.should eql(404) pub_1.response_header.status.should eql(404)
pub_1.response_header.content_length.should eql(0) pub_1.response_header.content_length.should eql(0)
...@@ -29,7 +29,7 @@ describe "Channel Statistics" do ...@@ -29,7 +29,7 @@ describe "Channel Statistics" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).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)
...@@ -50,7 +50,7 @@ describe "Channel Statistics" do ...@@ -50,7 +50,7 @@ describe "Channel Statistics" do
nginx_run_server(config, :timeout => 5) do |conf| nginx_run_server(config, :timeout => 5) do |conf|
create_channel_by_subscribe(channel, headers) do create_channel_by_subscribe(channel, headers) do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 30 pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).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)
...@@ -68,7 +68,7 @@ describe "Channel Statistics" do ...@@ -68,7 +68,7 @@ describe "Channel Statistics" do
it "should return detailed channels statistics without existing channels" do it "should return detailed channels statistics without existing channels" do
nginx_run_server(config, :timeout => 5) do |conf| nginx_run_server(config, :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').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)
...@@ -89,7 +89,7 @@ describe "Channel Statistics" do ...@@ -89,7 +89,7 @@ describe "Channel Statistics" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').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)
...@@ -114,7 +114,7 @@ describe "Channel Statistics" do ...@@ -114,7 +114,7 @@ describe "Channel Statistics" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').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)
...@@ -138,7 +138,7 @@ describe "Channel Statistics" do ...@@ -138,7 +138,7 @@ describe "Channel Statistics" do
nginx_run_server(config, :timeout => 5) do |conf| nginx_run_server(config, :timeout => 5) do |conf|
create_channel_by_subscribe(channel, headers) do create_channel_by_subscribe(channel, headers) do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers, :timeout => 30 pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').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)
...@@ -157,7 +157,7 @@ describe "Channel Statistics" do ...@@ -157,7 +157,7 @@ describe "Channel Statistics" do
it "should return summarized channels statistics for a nonexistent channel" do it "should return summarized channels statistics for a nonexistent channel" do
nginx_run_server(config, :timeout => 5) do |conf| nginx_run_server(config, :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
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)
...@@ -179,7 +179,7 @@ describe "Channel Statistics" do ...@@ -179,7 +179,7 @@ describe "Channel Statistics" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
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)
...@@ -203,7 +203,7 @@ describe "Channel Statistics" do ...@@ -203,7 +203,7 @@ describe "Channel Statistics" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
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)
...@@ -225,7 +225,7 @@ describe "Channel Statistics" do ...@@ -225,7 +225,7 @@ describe "Channel Statistics" do
nginx_run_server(config, :timeout => 5) do |conf| nginx_run_server(config, :timeout => 5) do |conf|
create_channel_by_subscribe(channel, headers) do create_channel_by_subscribe(channel, headers) do
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)
...@@ -348,7 +348,7 @@ describe "Channel Statistics" do ...@@ -348,7 +348,7 @@ describe "Channel Statistics" do
end end
EventMachine.run do EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').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)
...@@ -363,7 +363,7 @@ describe "Channel Statistics" do ...@@ -363,7 +363,7 @@ describe "Channel Statistics" do
it "should return detailed channels statistics for a nonexistent channel using prefix id" do it "should return detailed channels statistics for a nonexistent channel using prefix id" do
nginx_run_server(config, :timeout => 5) do |conf| nginx_run_server(config, :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=prefix_*').get :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=prefix_*').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)
...@@ -386,7 +386,7 @@ describe "Channel Statistics" do ...@@ -386,7 +386,7 @@ describe "Channel Statistics" do
publish_message(channel_1, headers, body) publish_message(channel_1, headers, body)
EventMachine.run do EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ch_test_*').get :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ch_test_*').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)
...@@ -413,7 +413,7 @@ describe "Channel Statistics" do ...@@ -413,7 +413,7 @@ describe "Channel Statistics" do
publish_message(channel_1, headers, body) publish_message(channel_1, headers, body)
EventMachine.run do EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=*').get :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=*').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)
...@@ -442,7 +442,7 @@ describe "Channel Statistics" do ...@@ -442,7 +442,7 @@ describe "Channel Statistics" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=bd_test_*').get :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=bd_test_*').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)
...@@ -466,7 +466,7 @@ describe "Channel Statistics" do ...@@ -466,7 +466,7 @@ describe "Channel Statistics" do
nginx_run_server(config, :timeout => 5) do |conf| nginx_run_server(config, :timeout => 5) do |conf|
create_channel_by_subscribe(channel, headers) do create_channel_by_subscribe(channel, headers) do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ch_test_*').get :head => headers, :timeout => 30 pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ch_test_*').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)
...@@ -499,7 +499,7 @@ describe "Channel Statistics" do ...@@ -499,7 +499,7 @@ describe "Channel Statistics" do
end end
EventMachine.run do EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ch_test_get_detailed_channels_statistics_to_many_channels_using_prefix_10*').get :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ch_test_get_detailed_channels_statistics_to_many_channels_using_prefix_10*').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)
...@@ -520,7 +520,7 @@ describe "Channel Statistics" do ...@@ -520,7 +520,7 @@ describe "Channel Statistics" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').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)
...@@ -533,7 +533,7 @@ describe "Channel Statistics" do ...@@ -533,7 +533,7 @@ describe "Channel Statistics" do
response["infos"].to_s.should_not be_empty response["infos"].to_s.should_not be_empty
sleep(2) sleep(2)
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers, :timeout => 30 pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers
pub_3.callback do pub_3.callback do
pub_3.response_header.status.should eql(200) pub_3.response_header.status.should eql(200)
pub_3.response_header.content_length.should_not eql(0) pub_3.response_header.content_length.should_not eql(0)
...@@ -555,7 +555,7 @@ describe "Channel Statistics" do ...@@ -555,7 +555,7 @@ describe "Channel Statistics" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
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)
...@@ -572,7 +572,7 @@ describe "Channel Statistics" do ...@@ -572,7 +572,7 @@ describe "Channel Statistics" do
response["by_worker"][0]["uptime"].to_s.should_not be_empty response["by_worker"][0]["uptime"].to_s.should_not be_empty
sleep(2) sleep(2)
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
pub_3.response_header.status.should eql(200) pub_3.response_header.status.should eql(200)
pub_3.response_header.content_length.should_not eql(0) pub_3.response_header.content_length.should_not eql(0)
......
...@@ -27,13 +27,13 @@ describe "Cleanup Memory" do ...@@ -27,13 +27,13 @@ describe "Cleanup Memory" do
EventMachine.run do EventMachine.run do
# ensure channel will not be cleaned up # ensure channel will not be cleaned up
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
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, { publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status, content| :error => Proc.new do |status, content|
fill_memory_timer.cancel fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
result = JSON.parse(pub_2.response) result = JSON.parse(pub_2.response)
...@@ -44,28 +44,28 @@ describe "Cleanup Memory" do ...@@ -44,28 +44,28 @@ describe "Cleanup Memory" do
published_messages_setp_1.should be > (conf.max_messages_stored_per_channel) published_messages_setp_1.should be > (conf.max_messages_stored_per_channel)
stored_messages_setp_1.should_not eql(0) stored_messages_setp_1.should_not eql(0)
EM.add_timer(45) do EM.add_timer(45) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_3.callback do pub_3.callback do
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
JSON.parse(pub_3.response)["stored_messages"].to_i.should eql(0) JSON.parse(pub_3.response)["stored_messages"].to_i.should eql(0)
execute_changes_on_environment(conf) do execute_changes_on_environment(conf) do
# connect a subscriber on new worker # connect a subscriber on new worker
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
EM.add_timer(35) do EM.add_timer(35) do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, { publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status2, content2| :error => Proc.new do |status2, content2|
fill_memory_timer.cancel fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2 fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
EM.add_timer(50) do EM.add_timer(50) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_3.callback do pub_3.callback do
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
JSON.parse(pub_3.response)["stored_messages"].to_i.should eql(0) JSON.parse(pub_3.response)["stored_messages"].to_i.should eql(0)
...@@ -74,7 +74,7 @@ describe "Cleanup Memory" do ...@@ -74,7 +74,7 @@ describe "Cleanup Memory" do
publish_message_inline_with_callbacks(channel, headers, body, { publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status3, content3| :error => Proc.new do |status3, content3|
fill_memory_timer.cancel fill_memory_timer.cancel
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_4.callback do pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0)
result = JSON.parse(pub_4.response) result = JSON.parse(pub_4.response)
...@@ -116,7 +116,7 @@ describe "Cleanup Memory" do ...@@ -116,7 +116,7 @@ describe "Cleanup Memory" do
if (count < messages_to_publish) if (count < messages_to_publish)
publish_message_inline(channel, headers, body) publish_message_inline(channel, headers, body)
elsif (count == messages_to_publish) elsif (count == messages_to_publish)
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_1.callback do pub_1.callback do
fill_memory_timer.cancel fill_memory_timer.cancel
fail("Don't received the stats") if (pub_1.response_header.status != 200) || (pub_1.response_header.content_length == 0) fail("Don't received the stats") if (pub_1.response_header.status != 200) || (pub_1.response_header.content_length == 0)
...@@ -125,7 +125,7 @@ describe "Cleanup Memory" do ...@@ -125,7 +125,7 @@ describe "Cleanup Memory" do
execute_changes_on_environment(conf) do execute_changes_on_environment(conf) do
EM.add_timer(5) do # wait cleanup timer to be executed one time EM.add_timer(5) do # wait cleanup timer to be executed one time
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
stored_messages_setp_2 = JSON.parse(pub_2.response)["stored_messages"].to_i stored_messages_setp_2 = JSON.parse(pub_2.response)["stored_messages"].to_i
...@@ -155,13 +155,13 @@ describe "Cleanup Memory" do ...@@ -155,13 +155,13 @@ describe "Cleanup Memory" do
EventMachine.run do EventMachine.run do
# ensure channel will not be cleaned up # ensure channel will not be cleaned up
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
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, { publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status, content| :error => Proc.new do |status, content|
fill_memory_timer.cancel fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
result = JSON.parse(pub_2.response) result = JSON.parse(pub_2.response)
...@@ -172,21 +172,21 @@ describe "Cleanup Memory" do ...@@ -172,21 +172,21 @@ describe "Cleanup Memory" do
execute_changes_on_environment(conf) do execute_changes_on_environment(conf) do
# connect a subscriber on new worker # connect a subscriber on new worker
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
EM.add_timer(50) do EM.add_timer(50) do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, { publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status2, content2| :error => Proc.new do |status2, content2|
fill_memory_timer.cancel fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2 fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
EM.add_timer(60) do EM.add_timer(60) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_3.callback do pub_3.callback do
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
JSON.parse(pub_3.response)["stored_messages"].to_i.should eql(0) JSON.parse(pub_3.response)["stored_messages"].to_i.should eql(0)
...@@ -194,7 +194,7 @@ describe "Cleanup Memory" do ...@@ -194,7 +194,7 @@ describe "Cleanup Memory" do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, { publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status3, content3| :error => Proc.new do |status3, content3|
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_4.callback do pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0)
result = JSON.parse(pub_4.response) result = JSON.parse(pub_4.response)
...@@ -236,7 +236,7 @@ describe "Cleanup Memory" do ...@@ -236,7 +236,7 @@ describe "Cleanup Memory" do
publish_message_inline_with_callbacks(channel + i.to_s, headers, body, { publish_message_inline_with_callbacks(channel + i.to_s, headers, body, {
:error => Proc.new do |status, content| :error => Proc.new do |status, content|
fill_memory_timer.cancel fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
channels_setp_1 = JSON.parse(pub_2.response)["channels"].to_i channels_setp_1 = JSON.parse(pub_2.response)["channels"].to_i
...@@ -249,13 +249,13 @@ describe "Cleanup Memory" do ...@@ -249,13 +249,13 @@ describe "Cleanup Memory" do
publish_message_inline_with_callbacks(channel + j.to_s, headers, body, { publish_message_inline_with_callbacks(channel + j.to_s, headers, body, {
:error => Proc.new do |status2, content2| :error => Proc.new do |status2, content2|
fill_memory_timer.cancel fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
fail("Don't create more channel") if published_messages_setp_1 == JSON.parse(pub_2.response)["published_messages"].to_i fail("Don't create more channel") if published_messages_setp_1 == JSON.parse(pub_2.response)["published_messages"].to_i
EM.add_timer(40) do EM.add_timer(40) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_3.callback do pub_3.callback do
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
channels = JSON.parse(pub_3.response)["channels"].to_i channels = JSON.parse(pub_3.response)["channels"].to_i
...@@ -268,7 +268,7 @@ describe "Cleanup Memory" do ...@@ -268,7 +268,7 @@ describe "Cleanup Memory" do
publish_message_inline_with_callbacks(channel + i.to_s, headers, body, { publish_message_inline_with_callbacks(channel + i.to_s, headers, body, {
:error => Proc.new do |status3, content3| :error => Proc.new do |status3, content3|
fill_memory_timer.cancel fill_memory_timer.cancel
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_4.callback do pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0)
channels_setp_2 = JSON.parse(pub_4.response)["channels"].to_i channels_setp_2 = JSON.parse(pub_4.response)["channels"].to_i
...@@ -309,13 +309,13 @@ describe "Cleanup Memory" do ...@@ -309,13 +309,13 @@ describe "Cleanup Memory" do
EventMachine.run do EventMachine.run do
# ensure channel will not be cleaned up # ensure channel will not be cleaned up
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
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, { publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status, content| :error => Proc.new do |status, content|
fill_memory_timer.cancel fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
result = JSON.parse(pub_2.response) result = JSON.parse(pub_2.response)
...@@ -323,21 +323,21 @@ describe "Cleanup Memory" do ...@@ -323,21 +323,21 @@ describe "Cleanup Memory" do
execute_changes_on_environment(conf) do execute_changes_on_environment(conf) do
# connect a subscriber on new worker # connect a subscriber on new worker
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
EM.add_timer(35) do EM.add_timer(35) do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, { publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status2, content2| :error => Proc.new do |status2, content2|
fill_memory_timer.cancel fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
published_messages_setp_2.should_not eql(published_messages_setp_1) published_messages_setp_2.should_not eql(published_messages_setp_1)
EM.add_timer(35) do EM.add_timer(35) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_3.callback do pub_3.callback do
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
JSON.parse(pub_3.response)["channels"].to_i.should eql(0) JSON.parse(pub_3.response)["channels"].to_i.should eql(0)
...@@ -345,7 +345,7 @@ describe "Cleanup Memory" do ...@@ -345,7 +345,7 @@ describe "Cleanup Memory" do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, { publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status3, content3| :error => Proc.new do |status3, content3|
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_4.callback do pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0)
result = JSON.parse(pub_4.response) result = JSON.parse(pub_4.response)
...@@ -385,7 +385,7 @@ describe "Cleanup Memory" do ...@@ -385,7 +385,7 @@ describe "Cleanup Memory" do
publish_message_inline_with_callbacks(channel + i.to_s, headers, body, { publish_message_inline_with_callbacks(channel + i.to_s, headers, body, {
:error => Proc.new do |status, content| :error => Proc.new do |status, content|
fill_memory_timer.cancel fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
result = JSON.parse(pub_2.response) result = JSON.parse(pub_2.response)
...@@ -398,14 +398,14 @@ describe "Cleanup Memory" do ...@@ -398,14 +398,14 @@ describe "Cleanup Memory" do
publish_message_inline_with_callbacks(channel + j.to_s, headers, body, { publish_message_inline_with_callbacks(channel + j.to_s, headers, body, {
:error => Proc.new do |status2, content2| :error => Proc.new do |status2, content2|
fill_memory_timer.cancel fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
fail("Don't create more channel") if published_messages_setp_1 == published_messages_setp_2 fail("Don't create more channel") if published_messages_setp_1 == published_messages_setp_2
EM.add_timer(35) do EM.add_timer(35) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_3.callback do pub_3.callback do
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
JSON.parse(pub_3.response)["channels"].to_i.should eql(0) JSON.parse(pub_3.response)["channels"].to_i.should eql(0)
...@@ -414,7 +414,7 @@ describe "Cleanup Memory" do ...@@ -414,7 +414,7 @@ describe "Cleanup Memory" do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel + i.to_s, headers, body, { publish_message_inline_with_callbacks(channel + i.to_s, headers, body, {
:error => Proc.new do |status3, content3| :error => Proc.new do |status3, content3|
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_4.callback do pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0)
result = JSON.parse(pub_4.response) result = JSON.parse(pub_4.response)
...@@ -454,14 +454,14 @@ describe "Cleanup Memory" do ...@@ -454,14 +454,14 @@ describe "Cleanup Memory" do
EventMachine.run do EventMachine.run do
i = 0 i = 0
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s + i.to_s).post :body => body, :head => headers, :timeout => 30 pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s + i.to_s).post :body => body, :head => headers
pub_1.callback do pub_1.callback do
if pub_1.response_header.status == 500 if pub_1.response_header.status == 500
fill_memory_timer.cancel fill_memory_timer.cancel
i.times do |j| i.times do |j|
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s + j.to_s).delete :head => headers, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s + j.to_s).delete :head => headers
end end
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
result = JSON.parse(pub_2.response) result = JSON.parse(pub_2.response)
...@@ -472,11 +472,11 @@ describe "Cleanup Memory" do ...@@ -472,11 +472,11 @@ describe "Cleanup Memory" do
EM.add_timer(45) do EM.add_timer(45) do
i = 0 i = 0
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s + i.to_s).post :body => body, :head => headers, :timeout => 30 pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s + i.to_s).post :body => body, :head => headers
pub_1.callback do pub_1.callback do
if pub_1.response_header.status == 500 if pub_1.response_header.status == 500
fill_memory_timer.cancel fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
result = JSON.parse(pub_2.response) result = JSON.parse(pub_2.response)
...@@ -507,7 +507,7 @@ describe "Cleanup Memory" do ...@@ -507,7 +507,7 @@ describe "Cleanup Memory" do
EventMachine.run do EventMachine.run do
create_and_delete_channel_in_loop(channel, body, headers) do create_and_delete_channel_in_loop(channel, body, headers) do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
result = JSON.parse(pub_2.response) result = JSON.parse(pub_2.response)
...@@ -517,7 +517,7 @@ describe "Cleanup Memory" do ...@@ -517,7 +517,7 @@ describe "Cleanup Memory" do
execute_changes_on_environment(conf) do execute_changes_on_environment(conf) do
EM.add_timer(40) do EM.add_timer(40) do
create_and_delete_channel_in_loop(channel, body, headers) do create_and_delete_channel_in_loop(channel, body, headers) do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
result = JSON.parse(pub_2.response) result = JSON.parse(pub_2.response)
...@@ -536,10 +536,10 @@ describe "Cleanup Memory" do ...@@ -536,10 +536,10 @@ describe "Cleanup Memory" do
end end
def create_and_delete_channel(channel, body, headers, &block) def create_and_delete_channel(channel, body, headers, &block)
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :body => body, :head => headers, :timeout => 30 pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :body => body, :head => headers
pub_1.callback do pub_1.callback do
if pub_1.response_header.status == 200 if pub_1.response_header.status == 200
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do pub.callback do
block.call((pub.response_header.status == 200) ? :success : :error) block.call((pub.response_header.status == 200) ? :success : :error)
end end
......
...@@ -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
......
...@@ -419,13 +419,13 @@ describe "Publisher Properties" do ...@@ -419,13 +419,13 @@ describe "Publisher Properties" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do pub.callback do
pub.response_header.status.should eql(200) pub.response_header.status.should eql(200)
pub.response_header.content_length.should eql(0) pub.response_header.content_length.should eql(0)
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.") pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 30 stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
stats.callback do stats.callback do
stats.response_header.status.should eql(200) stats.response_header.status.should eql(200)
stats.response_header.content_length.should_not eql(0) stats.response_header.content_length.should_not eql(0)
...@@ -453,19 +453,19 @@ describe "Publisher Properties" do ...@@ -453,19 +453,19 @@ describe "Publisher Properties" do
resp = "" resp = ""
nginx_run_server(configuration, :timeout => 5) do |conf| nginx_run_server(configuration, :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 => 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|
resp = resp + chunk resp = resp + chunk
if resp.strip.empty? if resp.strip.empty?
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}, :timeout => 30 stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do stats.callback do
stats.response_header.status.should eql(200) stats.response_header.status.should eql(200)
stats.response_header.content_length.should_not eql(0) stats.response_header.content_length.should_not eql(0)
response = JSON.parse(stats.response) response = JSON.parse(stats.response)
response["subscribers"].to_i.should eql(1) response["subscribers"].to_i.should eql(1)
response["channels"].to_i.should eql(1) response["channels"].to_i.should eql(1)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do pub.callback do
pub.response_header.status.should eql(200) pub.response_header.status.should eql(200)
pub.response_header.content_length.should eql(0) pub.response_header.content_length.should eql(0)
...@@ -478,7 +478,7 @@ describe "Publisher Properties" do ...@@ -478,7 +478,7 @@ describe "Publisher Properties" do
response["id"].to_i.should eql(-2) response["id"].to_i.should eql(-2)
response["text"].should eql("Channel deleted") response["text"].should eql("Channel deleted")
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}, :timeout => 30 stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do stats.callback do
stats.response_header.status.should eql(200) stats.response_header.status.should eql(200)
stats.response_header.content_length.should_not eql(0) stats.response_header.content_length.should_not eql(0)
...@@ -509,12 +509,12 @@ describe "Publisher Properties" do ...@@ -509,12 +509,12 @@ describe "Publisher Properties" do
resp = "" resp = ""
nginx_run_server(configuration, :timeout => 5) do |conf| nginx_run_server(configuration, :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s).get :head => headers, :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s).get :head => headers
sub_1.stream do |chunk| sub_1.stream do |chunk|
resp = resp + chunk resp = resp + chunk
if resp.strip.empty? if resp.strip.empty?
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}, :timeout => 30 stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do stats.callback do
stats.response_header.status.should eql(200) stats.response_header.status.should eql(200)
stats.response_header.content_length.should_not eql(0) stats.response_header.content_length.should_not eql(0)
...@@ -522,7 +522,7 @@ describe "Publisher Properties" do ...@@ -522,7 +522,7 @@ describe "Publisher Properties" do
response["subscribers"].to_i.should eql(1) response["subscribers"].to_i.should eql(1)
response["channels"].to_i.should eql(2) response["channels"].to_i.should eql(2)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1.to_s).delete :head => headers, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1.to_s).delete :head => headers
pub.callback do pub.callback do
pub.response_header.status.should eql(200) pub.response_header.status.should eql(200)
pub.response_header.content_length.should eql(0) pub.response_header.content_length.should eql(0)
...@@ -537,7 +537,7 @@ describe "Publisher Properties" do ...@@ -537,7 +537,7 @@ describe "Publisher Properties" do
response["id"].to_i.should eql(-2) response["id"].to_i.should eql(-2)
response["text"].should eql("Channel deleted") response["text"].should eql("Channel deleted")
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}, :timeout => 30 stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do stats.callback do
stats.response_header.status.should eql(200) stats.response_header.status.should eql(200)
stats.response_header.content_length.should_not eql(0) stats.response_header.content_length.should_not eql(0)
...@@ -545,7 +545,7 @@ describe "Publisher Properties" do ...@@ -545,7 +545,7 @@ describe "Publisher Properties" do
response["subscribers"].to_i.should eql(1) response["subscribers"].to_i.should eql(1)
response["channels"].to_i.should eql(1) response["channels"].to_i.should eql(1)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2.to_s).post :head => headers, :body=> body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2.to_s).post :head => headers, :body=> body
pub.callback do pub.callback do
pub.response_header.status.should eql(200) pub.response_header.status.should eql(200)
end end
...@@ -557,7 +557,7 @@ describe "Publisher Properties" do ...@@ -557,7 +557,7 @@ describe "Publisher Properties" do
response["id"].to_i.should eql(1) response["id"].to_i.should eql(1)
response["text"].should eql(body) response["text"].should eql(body)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2.to_s).delete :head => headers, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2.to_s).delete :head => headers
pub.callback do pub.callback do
pub.response_header.status.should eql(200) pub.response_header.status.should eql(200)
pub.response_header.content_length.should eql(0) pub.response_header.content_length.should eql(0)
...@@ -569,7 +569,7 @@ describe "Publisher Properties" do ...@@ -569,7 +569,7 @@ describe "Publisher Properties" do
response["id"].to_i.should eql(-2) response["id"].to_i.should eql(-2)
response["text"].should eql("Channel deleted") response["text"].should eql("Channel deleted")
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}, :timeout => 30 stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do stats.callback do
stats.response_header.status.should eql(200) stats.response_header.status.should eql(200)
stats.response_header.content_length.should_not eql(0) stats.response_header.content_length.should_not eql(0)
...@@ -601,7 +601,7 @@ describe "Publisher Properties" do ...@@ -601,7 +601,7 @@ describe "Publisher Properties" do
nginx_run_server(configuration, :timeout => 10) do |conf| nginx_run_server(configuration, :timeout => 10) do |conf|
EventMachine.run do EventMachine.run do
resp_1 = "" resp_1 = ""
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s).get :head => headers, :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s).get :head => headers
sub_1.stream do |chunk| sub_1.stream do |chunk|
resp_1 += chunk resp_1 += chunk
end end
...@@ -610,7 +610,7 @@ describe "Publisher Properties" do ...@@ -610,7 +610,7 @@ describe "Publisher Properties" do
end end
resp_2 = "" resp_2 = ""
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_2.to_s).get :head => headers, :timeout => 30 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_2.to_s).get :head => headers
sub_2.stream do |chunk| sub_2.stream do |chunk|
resp_2 += chunk resp_2 += chunk
end end
...@@ -618,7 +618,7 @@ describe "Publisher Properties" do ...@@ -618,7 +618,7 @@ describe "Publisher Properties" do
resp_2.should eql("{\"id\":\"-2\", \"channel\":\"test_delete_channels_whith_subscribers_2\", \"text\":\"Channel deleted\"}\r\nFOOTER\r\n") resp_2.should eql("{\"id\":\"-2\", \"channel\":\"test_delete_channels_whith_subscribers_2\", \"text\":\"Channel deleted\"}\r\nFOOTER\r\n")
end end
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}, :timeout => 30 stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do stats.callback do
stats.response_header.status.should eql(200) stats.response_header.status.should eql(200)
stats.response_header.content_length.should_not eql(0) stats.response_header.content_length.should_not eql(0)
...@@ -627,14 +627,14 @@ describe "Publisher Properties" do ...@@ -627,14 +627,14 @@ describe "Publisher Properties" do
response["channels"].to_i.should eql(2) response["channels"].to_i.should eql(2)
end end
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1.to_s).delete :head => headers, :timeout => 30 pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1.to_s).delete :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 eql(0) pub_1.response_header.content_length.should eql(0)
pub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.") pub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
end end
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2.to_s).delete :head => headers, :timeout => 30 pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2.to_s).delete :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 eql(0) pub_2.response_header.content_length.should eql(0)
...@@ -642,7 +642,7 @@ describe "Publisher Properties" do ...@@ -642,7 +642,7 @@ describe "Publisher Properties" do
end end
EM.add_timer(5) do EM.add_timer(5) do
stats_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}, :timeout => 30 stats_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats_2.callback do stats_2.callback do
stats_2.response_header.status.should eql(200) stats_2.response_header.status.should eql(200)
stats_2.response_header.content_length.should_not eql(0) stats_2.response_header.content_length.should_not eql(0)
...@@ -670,12 +670,12 @@ describe "Publisher Properties" do ...@@ -670,12 +670,12 @@ describe "Publisher Properties" do
resp = "" resp = ""
nginx_run_server(configuration, :timeout => 5) do |conf| nginx_run_server(configuration, :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 => 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|
resp = resp + chunk resp = resp + chunk
if resp == "#{conf.header_template}\r\n" if resp == "#{conf.header_template}\r\n"
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do pub.callback do
pub.response_header.status.should eql(200) pub.response_header.status.should eql(200)
pub.response_header.content_length.should eql(0) pub.response_header.content_length.should eql(0)
...@@ -718,18 +718,18 @@ describe "Publisher Properties" do ...@@ -718,18 +718,18 @@ describe "Publisher Properties" do
resp2 = "" resp2 = ""
nginx_run_server(configuration, :timeout => 5) do |conf| nginx_run_server(configuration, :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 => 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|
resp = resp + chunk resp = resp + chunk
end end
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub2/' + channel.to_s).get :head => headers, :timeout => 30 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub2/' + channel.to_s).get :head => headers
sub_2.stream do |chunk| sub_2.stream do |chunk|
resp2 = resp2 + chunk resp2 = resp2 + chunk
end end
EM.add_timer(1) do EM.add_timer(1) do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do pub.callback do
pub.response_header.status.should eql(200) pub.response_header.status.should eql(200)
pub.response_header.content_length.should eql(0) pub.response_header.content_length.should eql(0)
...@@ -761,12 +761,12 @@ describe "Publisher Properties" do ...@@ -761,12 +761,12 @@ describe "Publisher Properties" do
resp = "" resp = ""
nginx_run_server(configuration, :timeout => 5) do |conf| nginx_run_server(configuration, :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 => 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|
resp = resp + chunk resp = resp + chunk
if resp.strip.empty? if resp.strip.empty?
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do pub.callback do
pub.response_header.status.should eql(200) pub.response_header.status.should eql(200)
pub.response_header.content_length.should eql(0) pub.response_header.content_length.should eql(0)
......
...@@ -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)
......
...@@ -14,7 +14,7 @@ describe "Subscriber Properties" do ...@@ -14,7 +14,7 @@ describe "Subscriber Properties" do
it "should not accept access without a channel path" do it "should not accept access without a channel path" 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/').get :head => headers, :timeout => 30 sub = EventMachine::HttpRequest.new(nginx_address + '/sub/').get :head => headers
sub.callback do sub.callback do
sub.response_header.content_length.should eql(0) sub.response_header.content_length.should eql(0)
sub.response_header.status.should eql(400) sub.response_header.status.should eql(400)
...@@ -76,7 +76,7 @@ describe "Subscriber Properties" do ...@@ -76,7 +76,7 @@ describe "Subscriber 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_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.callback do sub_1.callback do
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)
...@@ -96,9 +96,9 @@ describe "Subscriber Properties" do ...@@ -96,9 +96,9 @@ describe "Subscriber Properties" do
EventMachine.run do EventMachine.run do
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1).get(:head => headers, :timeout => 30)) multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1).get(:head => headers))
multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_2).get(:head => headers, :timeout => 30)) multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_2).get(:head => headers))
multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_3).get(:head => headers, :timeout => 30)) multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_3).get(:head => headers))
multi.callback do multi.callback do
multi.responses[:callback].length.should eql(3) multi.responses[:callback].length.should eql(3)
multi.responses[:callback].each do |name, response| multi.responses[:callback].each do |name, response|
...@@ -143,7 +143,7 @@ describe "Subscriber Properties" do ...@@ -143,7 +143,7 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:max_channel_id_length => 5), :timeout => 5) do |conf| nginx_run_server(config.merge(:max_channel_id_length => 5), :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s ).get :head => headers, :timeout => 30 sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s ).get :head => headers
sub.callback do sub.callback do
sub.response_header.content_length.should eql(0) sub.response_header.content_length.should eql(0)
sub.response_header.status.should eql(400) sub.response_header.status.should eql(400)
...@@ -227,7 +227,7 @@ describe "Subscriber Properties" do ...@@ -227,7 +227,7 @@ describe "Subscriber 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 => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.callback do sub_1.callback do
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)
...@@ -247,7 +247,7 @@ describe "Subscriber Properties" do ...@@ -247,7 +247,7 @@ describe "Subscriber Properties" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
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.callback do sub_1.callback do
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
EventMachine.stop EventMachine.stop
...@@ -267,7 +267,7 @@ describe "Subscriber Properties" do ...@@ -267,7 +267,7 @@ describe "Subscriber Properties" do
publish_message(channel, headers, body) publish_message(channel, headers, body)
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + broadcast_channel.to_s).get :head => headers, :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + broadcast_channel.to_s).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)
EventMachine.stop EventMachine.stop
...@@ -287,7 +287,7 @@ describe "Subscriber Properties" do ...@@ -287,7 +287,7 @@ describe "Subscriber Properties" do
sleep(5) #to ensure message was gone sleep(5) #to ensure message was gone
EventMachine.run do EventMachine.run do
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.callback do sub_1.callback do
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)
...@@ -310,7 +310,7 @@ describe "Subscriber Properties" do ...@@ -310,7 +310,7 @@ describe "Subscriber Properties" do
sleep(5) #to ensure message was gone sleep(5) #to ensure message was gone
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + broadcast_channel.to_s).get :head => headers, :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + broadcast_channel.to_s).get :head => headers
sub_1.callback do sub_1.callback do
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)
...@@ -338,7 +338,7 @@ describe "Subscriber Properties" do ...@@ -338,7 +338,7 @@ describe "Subscriber Properties" do
end end
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s + '.b5' + '/' + channel_3.to_s + '.b2').get :head => headers, :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s + '.b5' + '/' + channel_3.to_s + '.b2').get :head => headers
sub_1.stream do |chunk| sub_1.stream do |chunk|
response += chunk response += chunk
lines = response.split("\r\n") lines = response.split("\r\n")
...@@ -390,7 +390,7 @@ describe "Subscriber Properties" do ...@@ -390,7 +390,7 @@ describe "Subscriber Properties" do
response = "" response = ""
nginx_run_server(config.merge(:header_template => nil, :message_template => '{\"channel\":\"~channel~\", \"id\":\"~id~\", \"message\":\"~text~\"}'), :timeout => 5) do |conf| nginx_run_server(config.merge(:header_template => nil, :message_template => '{\"channel\":\"~channel~\", \"id\":\"~id~\", \"message\":\"~text~\"}'), :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s + '/' + channel_3.to_s + '/' + channel_4.to_s + '/' + channel_5.to_s + '/' + channel_6.to_s).get :head => headers, :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s + '/' + channel_3.to_s + '/' + channel_4.to_s + '/' + channel_5.to_s + '/' + channel_6.to_s).get :head => headers
sub_1.stream do |chunk| sub_1.stream do |chunk|
response += chunk response += chunk
lines = response.split("\r\n") lines = response.split("\r\n")
...@@ -466,7 +466,7 @@ describe "Subscriber Properties" do ...@@ -466,7 +466,7 @@ describe "Subscriber Properties" do
response = "" response = ""
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s + '/' + channel_3.to_s).get :head => sent_headers, :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s + '/' + channel_3.to_s).get :head => sent_headers
sub_1.stream do |chunk| sub_1.stream do |chunk|
response += chunk response += chunk
lines = response.split("\r\n") lines = response.split("\r\n")
...@@ -527,7 +527,7 @@ describe "Subscriber Properties" do ...@@ -527,7 +527,7 @@ describe "Subscriber Properties" do
response = "" response = ""
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s + '.b5' + '/' + channel_3.to_s).get :head => sent_headers, :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s + '.b5' + '/' + channel_3.to_s).get :head => sent_headers
sub_1.stream do |chunk| sub_1.stream do |chunk|
response += chunk response += chunk
lines = response.split("\r\n") lines = response.split("\r\n")
...@@ -577,12 +577,12 @@ describe "Subscriber Properties" do ...@@ -577,12 +577,12 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:max_number_of_channels => 1), :timeout => 5) do |conf| nginx_run_server(config.merge(:max_number_of_channels => 1), :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + 1.to_s).get :head => headers, :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + 1.to_s).get :head => headers
sub_1.stream do sub_1.stream do
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
sub_1.response_header.content_length.should_not eql(0) sub_1.response_header.content_length.should_not eql(0)
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + 2.to_s).get :head => headers, :timeout => 30 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + 2.to_s).get :head => headers
sub_2.callback do sub_2.callback do
sub_2.response_header.status.should eql(403) sub_2.response_header.status.should eql(403)
sub_2.response_header.content_length.should eql(0) sub_2.response_header.content_length.should eql(0)
...@@ -599,12 +599,12 @@ describe "Subscriber Properties" do ...@@ -599,12 +599,12 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:max_number_of_broadcast_channels => 1, :broadcast_channel_prefix => 'bd_', :broadcast_channel_max_qtd => 1), :timeout => 5) do |conf| nginx_run_server(config.merge(:max_number_of_broadcast_channels => 1, :broadcast_channel_prefix => 'bd_', :broadcast_channel_max_qtd => 1), :timeout => 5) do |conf|
EventMachine.run do EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/ch1/' + channel.to_s + 1.to_s).get :head => headers, :timeout => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/ch1/' + channel.to_s + 1.to_s).get :head => headers
sub_1.stream do sub_1.stream do
sub_1.response_header.status.should eql(200) sub_1.response_header.status.should eql(200)
sub_1.response_header.content_length.should_not eql(0) sub_1.response_header.content_length.should_not eql(0)
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/ch1/' + channel.to_s + 2.to_s).get :head => headers, :timeout => 30 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/ch1/' + channel.to_s + 2.to_s).get :head => headers
sub_2.callback do sub_2.callback do
sub_2.response_header.status.should eql(403) sub_2.response_header.status.should eql(403)
sub_2.response_header.content_length.should eql(0) sub_2.response_header.content_length.should eql(0)
...@@ -640,7 +640,7 @@ describe "Subscriber Properties" do ...@@ -640,7 +640,7 @@ describe "Subscriber Properties" do
nginx_run_server(configuration, :timeout => 5) do |conf| nginx_run_server(configuration, :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 => 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 = JSON.parse(chunk) response = JSON.parse(chunk)
response['msg'].should be_nil response['msg'].should be_nil
...@@ -648,7 +648,7 @@ describe "Subscriber Properties" do ...@@ -648,7 +648,7 @@ describe "Subscriber Properties" do
EventMachine.stop EventMachine.stop
end end
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub2/' + channel.to_s + '.b1').get :head => headers, :timeout => 30 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub2/' + channel.to_s + '.b1').get :head => headers
sub_2.stream do |chunk| sub_2.stream do |chunk|
response = JSON.parse(chunk) response = JSON.parse(chunk)
response['text'].should be_nil response['text'].should be_nil
...@@ -661,7 +661,7 @@ describe "Subscriber Properties" do ...@@ -661,7 +661,7 @@ describe "Subscriber Properties" do
end end
EventMachine.run do EventMachine.run do
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers, :timeout => 30 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 = JSON.parse(chunk) response = JSON.parse(chunk)
response['msg'].should be_nil response['msg'].should be_nil
...@@ -671,7 +671,7 @@ describe "Subscriber Properties" do ...@@ -671,7 +671,7 @@ describe "Subscriber Properties" do
end end
EventMachine.run do EventMachine.run do
sub_4 = EventMachine::HttpRequest.new(nginx_address + '/sub2/' + channel.to_s + '.b1').get :head => headers, :timeout => 30 sub_4 = EventMachine::HttpRequest.new(nginx_address + '/sub2/' + channel.to_s + '.b1').get :head => headers
sub_4.stream do |chunk| sub_4.stream do |chunk|
response = JSON.parse(chunk) response = JSON.parse(chunk)
response['text'].should be_nil response['text'].should be_nil
...@@ -688,7 +688,7 @@ describe "Subscriber Properties" do ...@@ -688,7 +688,7 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:message_template => nil, :header_template => nil), :timeout => 5) do |conf| nginx_run_server(config.merge(:message_template => nil, :header_template => nil), :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 => 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|
chunk.should eql("#{body}\r\n") chunk.should eql("#{body}\r\n")
EventMachine.stop EventMachine.stop
...@@ -706,7 +706,7 @@ describe "Subscriber Properties" do ...@@ -706,7 +706,7 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:subscriber_connection_ttl => nil, :message_template => nil, :header_template => nil, :ping_message_interval => '1s', :ping_message_text => nil), :timeout => 5) do |conf| nginx_run_server(config.merge(:subscriber_connection_ttl => nil, :message_template => nil, :header_template => nil, :ping_message_interval => '1s', :ping_message_text => nil), :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 => 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|
chunk.should eql("\r\n") chunk.should eql("\r\n")
EventMachine.stop EventMachine.stop
...@@ -721,7 +721,7 @@ describe "Subscriber Properties" do ...@@ -721,7 +721,7 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:subscriber_connection_ttl => nil, :message_template => nil, :header_template => nil, :ping_message_interval => '1s', :ping_message_text => "pinging you!!!"), :timeout => 5) do |conf| nginx_run_server(config.merge(:subscriber_connection_ttl => nil, :message_template => nil, :header_template => nil, :ping_message_interval => '1s', :ping_message_text => "pinging you!!!"), :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 => 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|
chunk.should eql("#{conf.ping_message_text}\r\n") chunk.should eql("#{conf.ping_message_text}\r\n")
EventMachine.stop EventMachine.stop
...@@ -736,7 +736,7 @@ describe "Subscriber Properties" do ...@@ -736,7 +736,7 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:subscriber_connection_ttl => nil, :message_template => "~id~:~text~", :header_template => nil, :ping_message_interval => '1s', :ping_message_text => nil), :timeout => 5) do |conf| nginx_run_server(config.merge(:subscriber_connection_ttl => nil, :message_template => "~id~:~text~", :header_template => nil, :ping_message_interval => '1s', :ping_message_text => nil), :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 => 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|
chunk.should eql("-1:\r\n") chunk.should eql("-1:\r\n")
EventMachine.stop EventMachine.stop
...@@ -751,7 +751,7 @@ describe "Subscriber Properties" do ...@@ -751,7 +751,7 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:subscriber_connection_ttl => nil, :message_template => "~id~:~text~", :header_template => nil, :ping_message_interval => '1s', :ping_message_text => "pinging you!!!"), :timeout => 5) do |conf| nginx_run_server(config.merge(:subscriber_connection_ttl => nil, :message_template => "~id~:~text~", :header_template => nil, :ping_message_interval => '1s', :ping_message_text => "pinging you!!!"), :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 => 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|
chunk.should eql("-1:#{conf.ping_message_text}\r\n") chunk.should eql("-1:#{conf.ping_message_text}\r\n")
EventMachine.stop EventMachine.stop
...@@ -765,7 +765,7 @@ describe "Subscriber Properties" do ...@@ -765,7 +765,7 @@ describe "Subscriber 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_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|
sub_1.response_header['TRANSFER_ENCODING'].should eql("chunked") sub_1.response_header['TRANSFER_ENCODING'].should eql("chunked")
EventMachine.stop EventMachine.stop
...@@ -780,17 +780,17 @@ describe "Subscriber Properties" do ...@@ -780,17 +780,17 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:max_subscribers_per_channel => 3, :subscriber_connection_ttl => "3s"), :timeout => 5) do |conf| nginx_run_server(config.merge(:max_subscribers_per_channel => 3, :subscriber_connection_ttl => "3s"), :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 => 30 sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 30 sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 30 sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_4 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers, :timeout => 30 sub_4 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_4.callback do sub_4.callback do
sub_4.response_header.status.should eql(403) sub_4.response_header.status.should eql(403)
sub_4.response_header.content_length.should eql(0) sub_4.response_header.content_length.should eql(0)
sub_4.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribers limit per channel has been exceeded.") sub_4.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribers limit per channel has been exceeded.")
end end
sub_5 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + other_channel.to_s).get :head => headers, :timeout => 30 sub_5 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + other_channel.to_s).get :head => headers
sub_5.callback do sub_5.callback do
sub_5.response_header.status.should eql(200) sub_5.response_header.status.should eql(200)
EventMachine.stop EventMachine.stop
...@@ -839,7 +839,7 @@ describe "Subscriber Properties" do ...@@ -839,7 +839,7 @@ describe "Subscriber 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_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|
sub_1.response_header['ACCESS_CONTROL_ALLOW_ORIGIN'].should eql("*") sub_1.response_header['ACCESS_CONTROL_ALLOW_ORIGIN'].should eql("*")
sub_1.response_header['ACCESS_CONTROL_ALLOW_METHODS'].should eql("GET") sub_1.response_header['ACCESS_CONTROL_ALLOW_METHODS'].should eql("GET")
...@@ -856,7 +856,7 @@ describe "Subscriber Properties" do ...@@ -856,7 +856,7 @@ describe "Subscriber 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_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|
sub_1.response_header['ACCESS_CONTROL_ALLOW_ORIGIN'].should eql("*") sub_1.response_header['ACCESS_CONTROL_ALLOW_ORIGIN'].should eql("*")
...@@ -871,7 +871,7 @@ describe "Subscriber Properties" do ...@@ -871,7 +871,7 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:allowed_origins => "custom.domain.com"), :timeout => 5) do |conf| nginx_run_server(config.merge(:allowed_origins => "custom.domain.com"), :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 => 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|
sub_1.response_header['ACCESS_CONTROL_ALLOW_ORIGIN'].should eql("custom.domain.com") sub_1.response_header['ACCESS_CONTROL_ALLOW_ORIGIN'].should eql("custom.domain.com")
EventMachine.stop EventMachine.stop
...@@ -885,7 +885,7 @@ describe "Subscriber Properties" do ...@@ -885,7 +885,7 @@ describe "Subscriber 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
...@@ -899,7 +899,7 @@ describe "Subscriber Properties" do ...@@ -899,7 +899,7 @@ describe "Subscriber 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|
sub.response_header['CONTENT_TYPE'].should eql(conf.content_type) sub.response_header['CONTENT_TYPE'].should eql(conf.content_type)
EventMachine.stop EventMachine.stop
...@@ -916,7 +916,7 @@ describe "Subscriber Properties" do ...@@ -916,7 +916,7 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:subscriber_connection_ttl => nil), :timeout => 10) do |conf| nginx_run_server(config.merge(:subscriber_connection_ttl => nil), :timeout => 10) 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|
chunks_received += 1; chunks_received += 1;
step1 = Time.now if chunks_received == 1 step1 = Time.now if chunks_received == 1
......
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