Commit 0a7610f2 authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

updating em-http-request version and making some tests more reliable

parent 25fa8dc2
...@@ -4,7 +4,7 @@ gem 'rake' ...@@ -4,7 +4,7 @@ gem 'rake'
group :test do group :test do
gem 'POpen4', '0.1.4' gem 'POpen4', '0.1.4'
gem 'em-http-request', '0.2.14' gem 'em-http-request', '1.0.3'
gem 'json', '1.4.3' gem 'json', '1.4.3'
gem 'jasmine', '1.0.2.1' gem 'jasmine', '1.0.2.1'
gem 'jshintrb' gem 'jshintrb'
......
...@@ -6,20 +6,27 @@ GEM ...@@ -6,20 +6,27 @@ GEM
open4 open4
Platform (0.4.0) Platform (0.4.0)
RedCloth (4.2.7) RedCloth (4.2.7)
addressable (2.2.2) addressable (2.3.2)
archive-tar-minitar (0.5.2) archive-tar-minitar (0.5.2)
childprocess (0.2.0) childprocess (0.2.0)
ffi (~> 1.0.6) ffi (~> 1.0.6)
columnize (0.3.2) columnize (0.3.2)
cookiejar (0.3.0)
diff-lcs (1.1.2) diff-lcs (1.1.2)
em-http-request (0.2.14) em-http-request (1.0.3)
addressable (>= 2.0.0) addressable (>= 2.2.3)
eventmachine (>= 0.12.9) cookiejar
eventmachine (0.12.10) em-socksify
eventmachine (>= 1.0.0.beta.4)
http_parser.rb (>= 0.5.3)
em-socksify (0.2.1)
eventmachine (>= 1.0.0.beta.4)
eventmachine (1.0.0)
execjs (1.4.0) execjs (1.4.0)
multi_json (~> 1.0) multi_json (~> 1.0)
ffi (1.0.9) ffi (1.0.9)
github-markup (0.7.1) github-markup (0.7.1)
http_parser.rb (0.5.3)
jasmine (1.0.2.1) jasmine (1.0.2.1)
json_pure (>= 1.4.3) json_pure (>= 1.4.3)
rack (>= 1.1) rack (>= 1.1)
...@@ -79,7 +86,7 @@ PLATFORMS ...@@ -79,7 +86,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
POpen4 (= 0.1.4) POpen4 (= 0.1.4)
RedCloth RedCloth
em-http-request (= 0.2.14) em-http-request (= 1.0.3)
github-markup github-markup
jasmine (= 1.0.2.1) jasmine (= 1.0.2.1)
jshintrb jshintrb
......
...@@ -255,29 +255,29 @@ class TestChannelStatistics < Test::Unit::TestCase ...@@ -255,29 +255,29 @@ class TestChannelStatistics < Test::Unit::TestCase
EventMachine.run { EventMachine.run {
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get) multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/channels-stats').put :body => 'body') multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').put(:body => 'body'))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/channels-stats').post) multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').post)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/channels-stats').delete) multi.add(:d, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').delete)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/channels-stats').head) multi.add(:e, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').head)
multi.callback { multi.callback {
assert_equal(5, multi.responses[:succeeded].length) assert_equal(5, multi.responses[:callback].length)
assert_not_equal(405, multi.responses[:succeeded][0].response_header.status, "Statistics does accept GET") assert_not_equal(405, multi.responses[:callback][:a].response_header.status, "Statistics does accept GET")
assert_equal("GET", multi.responses[:succeeded][0].method, "Array is with wrong order") assert_equal("GET", multi.responses[:callback][:a].req.method, "Array is with wrong order")
assert_equal(405, multi.responses[:succeeded][1].response_header.status, "Statistics does not accept PUT") assert_equal(405, multi.responses[:callback][:b].response_header.status, "Statistics does not accept PUT")
assert_equal("PUT", multi.responses[:succeeded][1].method, "Array is with wrong order") assert_equal("PUT", multi.responses[:callback][:b].req.method, "Array is with wrong order")
assert_equal(405, multi.responses[:succeeded][2].response_header.status, "Statistics does not accept POST") assert_equal(405, multi.responses[:callback][:c].response_header.status, "Statistics does not accept POST")
assert_equal("POST", multi.responses[:succeeded][2].method, "Array is with wrong order") assert_equal("POST", multi.responses[:callback][:c].req.method, "Array is with wrong order")
assert_equal(405, multi.responses[:succeeded][3].response_header.status, "Statistics does not accept DELETE") assert_equal(405, multi.responses[:callback][:d].response_header.status, "Statistics does not accept DELETE")
assert_equal("DELETE", multi.responses[:succeeded][3].method, "Array is with wrong order") assert_equal("DELETE", multi.responses[:callback][:d].req.method, "Array is with wrong order")
assert_equal(405, multi.responses[:succeeded][4].response_header.status, "Statistics does not accept HEAD") assert_equal(405, multi.responses[:callback][:e].response_header.status, "Statistics does not accept HEAD")
assert_equal("HEAD", multi.responses[:succeeded][4].method, "Array is with wrong order") assert_equal("HEAD", multi.responses[:callback][:e].req.method, "Array is with wrong order")
EventMachine.stop EventMachine.stop
} }
...@@ -296,51 +296,44 @@ class TestChannelStatistics < Test::Unit::TestCase ...@@ -296,51 +296,44 @@ class TestChannelStatistics < Test::Unit::TestCase
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get) # default content_type multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get) # default content_type
multi.add(EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'text/plain'}) multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get(:head => {'accept' => 'text/plain'}))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}) multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get(:head => {'accept' => 'application/json'}))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/yaml'}) multi.add(:d, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get(:head => {'accept' => 'application/yaml'}))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/xml'}) multi.add(:e, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get(:head => {'accept' => 'application/xml'}))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'text/x-json'}) multi.add(:f, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get(:head => {'accept' => 'text/x-json'}))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'text/x-yaml'}) multi.add(:g, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get(:head => {'accept' => 'text/x-yaml'}))
multi.callback { multi.callback {
assert_equal(7, multi.responses[:succeeded].length) assert_equal(7, multi.responses[:callback].length)
i = 0 assert_equal(200, multi.responses[:callback][:a].response_header.status, "Statistics does accept GET")
assert_equal(200, multi.responses[:succeeded][i].response_header.status, "Statistics does accept GET") assert_equal("GET", multi.responses[:callback][:a].req.method, "Array is with wrong order")
assert_equal("GET", multi.responses[:succeeded][i].method, "Array is with wrong order") assert_equal("application/json", multi.responses[:callback][:a].response_header["CONTENT_TYPE"], "wrong content-type")
assert_equal("application/json", multi.responses[:succeeded][i].response_header["CONTENT_TYPE"], "wrong content-type")
assert_equal(200, multi.responses[:callback][:b].response_header.status, "Statistics does accept GET")
i+=1 assert_equal("GET", multi.responses[:callback][:b].req.method, "Array is with wrong order")
assert_equal(200, multi.responses[:succeeded][i].response_header.status, "Statistics does accept GET") assert_equal("text/plain", multi.responses[:callback][:b].response_header["CONTENT_TYPE"], "wrong content-type")
assert_equal("GET", multi.responses[:succeeded][i].method, "Array is with wrong order")
assert_equal("text/plain", multi.responses[:succeeded][i].response_header["CONTENT_TYPE"], "wrong content-type") assert_equal(200, multi.responses[:callback][:c].response_header.status, "Statistics does accept GET")
assert_equal("GET", multi.responses[:callback][:c].req.method, "Array is with wrong order")
i+=1 assert_equal("application/json", multi.responses[:callback][:c].response_header["CONTENT_TYPE"], "wrong content-type")
assert_equal(200, multi.responses[:succeeded][i].response_header.status, "Statistics does accept GET")
assert_equal("GET", multi.responses[:succeeded][i].method, "Array is with wrong order") assert_equal(200, multi.responses[:callback][:d].response_header.status, "Statistics does accept GET")
assert_equal("application/json", multi.responses[:succeeded][i].response_header["CONTENT_TYPE"], "wrong content-type") assert_equal("GET", multi.responses[:callback][:d].req.method, "Array is with wrong order")
assert_equal("application/yaml", multi.responses[:callback][:d].response_header["CONTENT_TYPE"], "wrong content-type")
i+=1
assert_equal(200, multi.responses[:succeeded][i].response_header.status, "Statistics does accept GET") assert_equal(200, multi.responses[:callback][:e].response_header.status, "Statistics does accept GET")
assert_equal("GET", multi.responses[:succeeded][i].method, "Array is with wrong order") assert_equal("GET", multi.responses[:callback][:e].req.method, "Array is with wrong order")
assert_equal("application/yaml", multi.responses[:succeeded][i].response_header["CONTENT_TYPE"], "wrong content-type") assert_equal("application/xml", multi.responses[:callback][:e].response_header["CONTENT_TYPE"], "wrong content-type")
i+=1 assert_equal(200, multi.responses[:callback][:f].response_header.status, "Statistics does accept GET")
assert_equal(200, multi.responses[:succeeded][i].response_header.status, "Statistics does accept GET") assert_equal("GET", multi.responses[:callback][:f].req.method, "Array is with wrong order")
assert_equal("GET", multi.responses[:succeeded][i].method, "Array is with wrong order") assert_equal("text/x-json", multi.responses[:callback][:f].response_header["CONTENT_TYPE"], "wrong content-type")
assert_equal("application/xml", multi.responses[:succeeded][i].response_header["CONTENT_TYPE"], "wrong content-type")
assert_equal(200, multi.responses[:callback][:g].response_header.status, "Statistics does accept GET")
i+=1 assert_equal("GET", multi.responses[:callback][:g].req.method, "Array is with wrong order")
assert_equal(200, multi.responses[:succeeded][i].response_header.status, "Statistics does accept GET") assert_equal("text/x-yaml", multi.responses[:callback][:g].response_header["CONTENT_TYPE"], "wrong content-type")
assert_equal("GET", multi.responses[:succeeded][i].method, "Array is with wrong order")
assert_equal("text/x-json", multi.responses[:succeeded][i].response_header["CONTENT_TYPE"], "wrong content-type")
i+=1
assert_equal(200, multi.responses[:succeeded][i].response_header.status, "Statistics does accept GET")
assert_equal("GET", multi.responses[:succeeded][i].method, "Array is with wrong order")
assert_equal("text/x-yaml", multi.responses[:succeeded][i].response_header["CONTENT_TYPE"], "wrong content-type")
EventMachine.stop EventMachine.stop
} }
......
...@@ -41,30 +41,31 @@ class TestCleanupMemory < Test::Unit::TestCase ...@@ -41,30 +41,31 @@ class TestCleanupMemory < Test::Unit::TestCase
result = JSON.parse(pub_2.response) result = JSON.parse(pub_2.response)
published_messages_setp_1 = result["published_messages"].to_i published_messages_setp_1 = result["published_messages"].to_i
fail("Don't create any message") if published_messages_setp_1 == 0 fail("Don't create any message") if published_messages_setp_1 == 0
end
end
end
i += 1
end
EM.add_timer(40) do EM.add_timer(35) 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, :timeout => 30
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, :timeout => 60
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)
assert_equal(published_messages_setp_1, result["published_messages"].to_i / 2, "Don't cleaned all memory") assert_equal(published_messages_setp_1, result["published_messages"].to_i / 2, "Don't cleaned all memory")
EventMachine.stop EventMachine.stop
end
end
end
i += 1
end
end end
end end
end end
i += 1
end end
i += 1
end end
add_test_timeout(45) add_test_timeout(45)
end end
...@@ -84,9 +85,15 @@ class TestCleanupMemory < Test::Unit::TestCase ...@@ -84,9 +85,15 @@ class TestCleanupMemory < Test::Unit::TestCase
end end
end end
def create_and_delete_channel_in_loop(channel, body, headers) def create_and_delete_channel_in_loop(channel, body, headers, &block)
create_and_delete_channel(channel, body, headers) do |status| create_and_delete_channel(channel, body, headers) do |status|
create_and_delete_channel_in_loop(channel, body, headers) if status == :success if status == :success
create_and_delete_channel_in_loop(channel, body, headers) do
yield
end
else
block.call unless block.nil?
end
end end
end end
...@@ -106,28 +113,24 @@ class TestCleanupMemory < Test::Unit::TestCase ...@@ -106,28 +113,24 @@ class TestCleanupMemory < Test::Unit::TestCase
published_messages_setp_1 = 0 published_messages_setp_1 = 0
EventMachine.run do EventMachine.run do
create_and_delete_channel_in_loop(channel, body, headers) create_and_delete_channel_in_loop(channel, body, headers) do
EM.add_timer(5) 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, :timeout => 60
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)
published_messages_setp_1 = result["published_messages"].to_i published_messages_setp_1 = result["published_messages"].to_i
fail("Don't create any message") if published_messages_setp_1 == 0 fail("Don't create any message") if published_messages_setp_1 == 0
end
end
EM.add_timer(40) do
create_and_delete_channel_in_loop(channel, body, headers)
EM.add_timer(5) do EM.add_timer(40) do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 create_and_delete_channel_in_loop(channel, body, headers) do
pub_2.callback do pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) pub_2.callback do
result = JSON.parse(pub_2.response) fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
assert_equal(published_messages_setp_1, result["published_messages"].to_i / 2, "Don't cleaned all memory") result = JSON.parse(pub_2.response)
EventMachine.stop assert_equal(published_messages_setp_1, result["published_messages"].to_i / 2, "Don't cleaned all memory")
EventMachine.stop
end
end
end end
end end
end end
...@@ -167,34 +170,33 @@ class TestCleanupMemory < Test::Unit::TestCase ...@@ -167,34 +170,33 @@ class TestCleanupMemory < Test::Unit::TestCase
assert_equal(@max_message_buffer_length, stored_messages_setp_1, "Don't limit stored messages") assert_equal(@max_message_buffer_length, stored_messages_setp_1, "Don't limit stored messages")
fail("Don't reached the limit of stored messages") if result["published_messages"].to_i <= @max_message_buffer_length fail("Don't reached the limit of stored messages") if result["published_messages"].to_i <= @max_message_buffer_length
fail("Don't create any message") if stored_messages_setp_1 == 0 fail("Don't create any message") if stored_messages_setp_1 == 0
end EM.add_timer(45) do
end pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
}) pub_3.callback do
end fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
assert_equal(0, JSON.parse(pub_3.response)["stored_messages"].to_i, "Don't cleaned all messages")
EM.add_timer(50) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
pub_3.callback do publish_message_inline_with_callbacks(channel, headers, body, {
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) :error => Proc.new do |status2, content2|
assert_equal(0, JSON.parse(pub_3.response)["stored_messages"].to_i, "Don't cleaned all messages") pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
pub_4.callback do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0)
publish_message_inline_with_callbacks(channel, headers, body, { result = JSON.parse(pub_4.response)
:error => Proc.new do |status, content| assert_equal(stored_messages_setp_1, result["stored_messages"].to_i, "Don't cleaned all messages")
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 assert_equal(published_messages_setp_1, result["published_messages"].to_i / 2, "Don't cleaned all memory")
pub_4.callback do EventMachine.stop
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) end
result = JSON.parse(pub_4.response) end
assert_equal(stored_messages_setp_1, result["stored_messages"].to_i, "Don't cleaned all messages") })
assert_equal(published_messages_setp_1, result["published_messages"].to_i / 2, "Don't cleaned all memory") end
EventMachine.stop
end end
end end
}) end
end end
end })
end end
add_test_timeout(60) add_test_timeout(55)
end end
end end
...@@ -225,23 +227,22 @@ class TestCleanupMemory < Test::Unit::TestCase ...@@ -225,23 +227,22 @@ class TestCleanupMemory < Test::Unit::TestCase
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)
stored_messages_setp_1 = JSON.parse(pub_1.response)["stored_messages"].to_i stored_messages_setp_1 = JSON.parse(pub_1.response)["stored_messages"].to_i
assert_equal(messages_to_publish, stored_messages_setp_1, "Don't store messages") assert_equal(messages_to_publish, stored_messages_setp_1, "Don't store messages")
end
end
count += 1
end
EM.add_timer(15) 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, :timeout => 60
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
assert(stored_messages_setp_1 > stored_messages_setp_2, "Don't clear messages") assert(stored_messages_setp_1 > stored_messages_setp_2, "Don't clear messages")
assert(stored_messages_setp_2 >= (messages_to_publish / 2), "Cleared all messages") assert(stored_messages_setp_2 > 0, "Cleared all messages")
EventMachine.stop EventMachine.stop
end
end
end
end end
count += 1
end end
add_test_timeout(20) add_test_timeout(20)
end end
end end
...@@ -277,34 +278,35 @@ class TestCleanupMemory < Test::Unit::TestCase ...@@ -277,34 +278,35 @@ class TestCleanupMemory < Test::Unit::TestCase
published_messages_setp_1 = result["published_messages"].to_i published_messages_setp_1 = result["published_messages"].to_i
fail("Limited the number of stored messages") if stored_messages_setp_1 <= 100 fail("Limited the number of stored messages") if stored_messages_setp_1 <= 100
fail("Don't create any message") if stored_messages_setp_1 == 0 fail("Don't create any message") if stored_messages_setp_1 == 0
end
end
})
end
EM.add_timer(50) 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, :timeout => 60
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)
assert_equal(0, JSON.parse(pub_3.response)["stored_messages"].to_i, "Don't cleaned all messages") assert_equal(0, JSON.parse(pub_3.response)["stored_messages"].to_i, "Don't cleaned all messages")
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 |status2, content2|
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, :timeout => 60
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)
assert_equal(stored_messages_setp_1, result["stored_messages"].to_i, "Don't cleaned all messages") assert_equal(stored_messages_setp_1, result["stored_messages"].to_i, "Don't cleaned all messages")
assert_equal(published_messages_setp_1, result["published_messages"].to_i / 2, "Don't cleaned all memory") assert_equal(published_messages_setp_1, result["published_messages"].to_i / 2, "Don't cleaned all memory")
EventMachine.stop EventMachine.stop
end
end
})
end
end end
end end
}) end
end end
end })
end end
add_test_timeout(60)
add_test_timeout(55)
end end
end end
...@@ -334,43 +336,44 @@ class TestCleanupMemory < Test::Unit::TestCase ...@@ -334,43 +336,44 @@ class TestCleanupMemory < Test::Unit::TestCase
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
fail("Don't create any channel") if channels_setp_1 == 0 fail("Don't create any channel") if channels_setp_1 == 0
end
end
})
i += 1
end
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, :timeout => 60
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
assert_equal(0, channels, "Don't removed all channels") assert_equal(0, channels, "Don't removed all channels")
EventMachine.stop unless (channels == 0) EventMachine.stop unless (channels == 0)
EM.add_timer(35) do EM.add_timer(35) do
i = 0 i = 0
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 |status, content| :error => Proc.new do |status2, content2|
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, :timeout => 60
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
assert_equal(channels_setp_1, channels_setp_2, "Don't released all memory") assert_equal(channels_setp_1, channels_setp_2, "Don't released all memory")
EventMachine.stop EventMachine.stop
end
end
})
i += 1
end
end end
end end
}) end
i += 1
end end
end end
end })
i += 1
end end
add_test_timeout(110)
add_test_timeout(85)
end end
end end
...@@ -402,33 +405,34 @@ class TestCleanupMemory < Test::Unit::TestCase ...@@ -402,33 +405,34 @@ class TestCleanupMemory < Test::Unit::TestCase
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)
published_messages_setp_1 = result["published_messages"].to_i published_messages_setp_1 = result["published_messages"].to_i
end
end
})
end
EM.add_timer(40) do EM.add_timer(40) 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, :timeout => 60
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)
assert_equal(0, JSON.parse(pub_3.response)["channels"].to_i, "Don't cleaned all messages/channels") assert_equal(0, JSON.parse(pub_3.response)["channels"].to_i, "Don't cleaned all messages/channels")
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 |status2, content2|
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, :timeout => 60
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)
assert_equal(published_messages_setp_1, result["published_messages"].to_i / 2, "Don't cleaned all memory") assert_equal(published_messages_setp_1, result["published_messages"].to_i / 2, "Don't cleaned all memory")
EventMachine.stop EventMachine.stop
end
end
})
end
end end
end end
}) end
end end
end })
end end
add_test_timeout(50)
add_test_timeout(45)
end end
end end
...@@ -458,37 +462,37 @@ class TestCleanupMemory < Test::Unit::TestCase ...@@ -458,37 +462,37 @@ class TestCleanupMemory < Test::Unit::TestCase
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)
published_messages_setp_1 = result["published_messages"].to_i published_messages_setp_1 = result["published_messages"].to_i
end
end
})
i += 1
end
EM.add_timer(40) 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, :timeout => 60
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)
assert_equal(0, JSON.parse(pub_3.response)["channels"].to_i, "Don't cleaned all messages/channels") assert_equal(0, JSON.parse(pub_3.response)["channels"].to_i, "Don't cleaned all messages/channels")
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 + 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 |status2, content2|
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, :timeout => 60
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)
assert_equal(published_messages_setp_1, result["published_messages"].to_i / 2, "Don't cleaned all memory") assert_equal(published_messages_setp_1, result["published_messages"].to_i / 2, "Don't cleaned all memory")
EventMachine.stop EventMachine.stop
end
end
})
i += 1
end
end end
end end
}) end
i += 1
end end
end end
end })
i += 1
end end
add_test_timeout(110) add_test_timeout(85)
end end
end end
......
...@@ -2,7 +2,6 @@ require File.expand_path('base_test_case', File.dirname(__FILE__)) ...@@ -2,7 +2,6 @@ require File.expand_path('base_test_case', File.dirname(__FILE__))
class TestCleanupMemoryAfterKill < Test::Unit::TestCase class TestCleanupMemoryAfterKill < Test::Unit::TestCase
include BaseTestCase include BaseTestCase
@@second_step_timer = 90
@@timeout = 130 @@timeout = 130
def global_configuration def global_configuration
...@@ -66,49 +65,49 @@ class TestCleanupMemoryAfterKill < Test::Unit::TestCase ...@@ -66,49 +65,49 @@ class TestCleanupMemoryAfterKill < Test::Unit::TestCase
sleep(1) sleep(1)
# 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, :timeout => 60
end
end
end
})
end
EM.add_timer(40) do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status, content|
fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
pub_2.callback do
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
fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
end
end
})
end
end
EM.add_timer(@@second_step_timer) do EM.add_timer(35) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
pub_3.callback do publish_message_inline_with_callbacks(channel, headers, body, {
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) :error => Proc.new do |status2, content2|
assert_equal(0, JSON.parse(pub_3.response)["stored_messages"].to_i, "Don't cleaned all messages") fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do pub_2.callback do
publish_message_inline_with_callbacks(channel, headers, body, { fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
:error => Proc.new do |status, content| published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) EM.add_timer(50) do
result = JSON.parse(pub_4.response) pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
assert_equal(stored_messages_setp_1, result["stored_messages"].to_i, "Don't cleaned all messages") pub_3.callback do
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory") fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
EventMachine.stop assert_equal(0, JSON.parse(pub_3.response)["stored_messages"].to_i, "Don't cleaned all messages")
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, {
: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.callback do
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)
assert_equal(stored_messages_setp_1, result["stored_messages"].to_i, "Don't cleaned all messages")
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory")
EventMachine.stop
end
end
})
end
end
end
end
end
})
end
end end
end end
}) end
end end
end })
end end
add_test_timeout(@@timeout) add_test_timeout(@@timeout)
end end
...@@ -142,24 +141,23 @@ class TestCleanupMemoryAfterKill < Test::Unit::TestCase ...@@ -142,24 +141,23 @@ class TestCleanupMemoryAfterKill < Test::Unit::TestCase
stored_messages_setp_1 = JSON.parse(pub_1.response)["stored_messages"].to_i stored_messages_setp_1 = JSON.parse(pub_1.response)["stored_messages"].to_i
assert_equal(messages_to_publish, stored_messages_setp_1, "Don't store messages") assert_equal(messages_to_publish, stored_messages_setp_1, "Don't store messages")
kill_worker kill_worker do
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.callback do
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
assert(stored_messages_setp_1 > stored_messages_setp_2, "Don't clear messages")
assert(stored_messages_setp_2 > 0, "Cleared all messages")
EventMachine.stop
end
end
end
end end
end end
count += 1 count += 1
end end
EM.add_timer(14) 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.callback do
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
assert(stored_messages_setp_1 > stored_messages_setp_2, "Don't clear messages")
assert(stored_messages_setp_2 >= (messages_to_publish / 2), "Cleared all messages")
EventMachine.stop
end
end
add_test_timeout(20) add_test_timeout(20)
end end
end end
...@@ -201,49 +199,49 @@ class TestCleanupMemoryAfterKill < Test::Unit::TestCase ...@@ -201,49 +199,49 @@ class TestCleanupMemoryAfterKill < Test::Unit::TestCase
sleep(1) sleep(1)
# 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, :timeout => 60
end
end
end
})
end
EM.add_timer(45) do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status, content|
fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
pub_2.callback do
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
fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
end
end
})
end
end
EM.add_timer(@@second_step_timer) do EM.add_timer(40) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
pub_3.callback do publish_message_inline_with_callbacks(channel, headers, body, {
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) :error => Proc.new do |status2, content2|
assert_equal(0, JSON.parse(pub_3.response)["stored_messages"].to_i, "Don't cleaned all messages") fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do pub_2.callback do
publish_message_inline_with_callbacks(channel, headers, body, { fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
:error => Proc.new do |status, content| published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) EM.add_timer(50) do
result = JSON.parse(pub_4.response) pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
assert_equal(stored_messages_setp_1, result["stored_messages"].to_i, "Don't cleaned all messages") pub_3.callback do
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory") fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
EventMachine.stop assert_equal(0, JSON.parse(pub_3.response)["stored_messages"].to_i, "Don't cleaned all messages")
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, {
: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.callback do
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)
assert_equal(stored_messages_setp_1, result["stored_messages"].to_i, "Don't cleaned all messages")
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory")
EventMachine.stop
end
end
})
end
end
end
end
end
})
end
end end
end end
}) end
end end
end })
end end
add_test_timeout(@@timeout) add_test_timeout(@@timeout)
end end
...@@ -279,62 +277,62 @@ class TestCleanupMemoryAfterKill < Test::Unit::TestCase ...@@ -279,62 +277,62 @@ class TestCleanupMemoryAfterKill < Test::Unit::TestCase
published_messages_setp_1 = result["published_messages"].to_i published_messages_setp_1 = result["published_messages"].to_i
fail("Don't create any channel") if channels_setp_1 == 0 fail("Don't create any channel") if channels_setp_1 == 0
kill_worker kill_worker do
end
end
})
i += 1
end
EM.add_timer(40) do
j = 0
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel + j.to_s, headers, body, {
:error => Proc.new do |status, content|
fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
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 create more channel") if published_messages_setp_1 == JSON.parse(pub_2.response)["published_messages"].to_i
end
end
})
j += 1
end
end
EM.add_timer(@@second_step_timer) do EM.add_timer(35) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 j = 0
pub_3.callback do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) publish_message_inline_with_callbacks(channel + j.to_s, headers, body, {
channels = JSON.parse(pub_3.response)["channels"].to_i :error => Proc.new do |status2, content2|
fill_memory_timer.cancel
assert_equal(0, channels, "Don't removed all channels") pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
EventMachine.stop unless (channels == 0) pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
EM.add_timer(35) do fail("Don't create more channel") if published_messages_setp_1 == JSON.parse(pub_2.response)["published_messages"].to_i
i = 0
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do EM.add_timer(40) do
publish_message_inline_with_callbacks(channel + i.to_s, headers, body, { pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
:error => Proc.new do |status, content| pub_3.callback do
fill_memory_timer.cancel fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 channels = JSON.parse(pub_3.response)["channels"].to_i
pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) assert_equal(0, channels, "Don't removed all channels")
channels_setp_2 = JSON.parse(pub_4.response)["channels"].to_i EventMachine.stop unless (channels == 0)
assert_equal(channels_setp_1, channels_setp_2, "Don't released all memory") EM.add_timer(35) do
EventMachine.stop i = 0
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel + i.to_s, headers, body, {
:error => Proc.new do |status3, content3|
fill_memory_timer.cancel
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
pub_4.callback do
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
assert_equal(channels_setp_1, channels_setp_2, "Don't released all memory")
EventMachine.stop
end
end
})
i += 1
end
end
end
end
end
end
})
j += 1
end end
end end
}) end
i += 1
end end
end end
end })
i += 1
end end
add_test_timeout(@@timeout + 35) add_test_timeout(@@timeout)
end end
end end
...@@ -372,48 +370,48 @@ class TestCleanupMemoryAfterKill < Test::Unit::TestCase ...@@ -372,48 +370,48 @@ class TestCleanupMemoryAfterKill < Test::Unit::TestCase
sleep(1) sleep(1)
# 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, :timeout => 60
end
end
end
})
end
EM.add_timer(40) do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status, content|
fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
pub_2.callback do
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
fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
end
end
})
end
end
EM.add_timer(@@second_step_timer) do EM.add_timer(35) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
pub_3.callback do publish_message_inline_with_callbacks(channel, headers, body, {
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) :error => Proc.new do |status2, content2|
assert_equal(0, JSON.parse(pub_3.response)["channels"].to_i, "Don't cleaned all messages/channels") fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do pub_2.callback do
publish_message_inline_with_callbacks(channel, headers, body, { fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
:error => Proc.new do |status, content| published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) EM.add_timer(35) do
result = JSON.parse(pub_4.response) pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory") pub_3.callback do
EventMachine.stop fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
assert_equal(0, JSON.parse(pub_3.response)["channels"].to_i, "Don't cleaned all messages/channels")
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, {
: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.callback do
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)
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory")
EventMachine.stop
end
end
})
end
end
end
end
end
})
end
end end
end end
}) end
end end
end })
end end
add_test_timeout(@@timeout) add_test_timeout(@@timeout)
end end
...@@ -447,57 +445,57 @@ class TestCleanupMemoryAfterKill < Test::Unit::TestCase ...@@ -447,57 +445,57 @@ class TestCleanupMemoryAfterKill < Test::Unit::TestCase
result = JSON.parse(pub_2.response) result = JSON.parse(pub_2.response)
published_messages_setp_1 = result["published_messages"].to_i published_messages_setp_1 = result["published_messages"].to_i
kill_worker kill_worker do
end
end
})
i += 1
end
EM.add_timer(40) do
j = 0
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel + j.to_s, headers, body, {
:error => Proc.new do |status, content|
fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
pub_2.callback do
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
fail("Don't create more channel") if published_messages_setp_1 == published_messages_setp_2
end
end
})
j += 1
end
end
EM.add_timer(@@second_step_timer) do EM.add_timer(35) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 j = 0
pub_3.callback do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) publish_message_inline_with_callbacks(channel + j.to_s, headers, body, {
assert_equal(0, JSON.parse(pub_3.response)["channels"].to_i, "Don't cleaned all messages/channels") :error => Proc.new do |status2, content2|
fill_memory_timer.cancel
EM.add_timer(35) do pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do pub_2.callback do
publish_message_inline_with_callbacks(channel + i.to_s, headers, body, { fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
:error => Proc.new do |status, content| published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 fail("Don't create more channel") if published_messages_setp_1 == published_messages_setp_2
pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) EM.add_timer(35) do
result = JSON.parse(pub_4.response) pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory") pub_3.callback do
EventMachine.stop fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
assert_equal(0, JSON.parse(pub_3.response)["channels"].to_i, "Don't cleaned all messages/channels")
EM.add_timer(35) do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel + i.to_s, headers, body, {
:error => Proc.new do |status3, content3|
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
pub_4.callback do
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)
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory")
EventMachine.stop
end
end
})
i += 1
end
end
end
end
end
end
})
j += 1
end end
end end
}) end
i += 1
end end
end end
end })
i += 1
end end
add_test_timeout(@@timeout + 35) add_test_timeout(@@timeout)
end end
end end
......
...@@ -2,7 +2,6 @@ require File.expand_path('base_test_case', File.dirname(__FILE__)) ...@@ -2,7 +2,6 @@ require File.expand_path('base_test_case', File.dirname(__FILE__))
class TestCleanupMemoryAfterReload < Test::Unit::TestCase class TestCleanupMemoryAfterReload < Test::Unit::TestCase
include BaseTestCase include BaseTestCase
@@second_step_timer = 90
@@timeout = 130 @@timeout = 130
def global_configuration def global_configuration
...@@ -57,48 +56,48 @@ class TestCleanupMemoryAfterReload < Test::Unit::TestCase ...@@ -57,48 +56,48 @@ class TestCleanupMemoryAfterReload < Test::Unit::TestCase
sleep(1) sleep(1)
# 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, :timeout => 60
end
end
})
end
EM.add_timer(40) do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, {
:error => Proc.new do |status, content|
fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
pub_2.callback do
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
fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
end
end
})
end
end
EM.add_timer(@@second_step_timer) do EM.add_timer(35) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
pub_3.callback do publish_message_inline_with_callbacks(channel, headers, body, {
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) :error => Proc.new do |status2, content2|
assert_equal(0, JSON.parse(pub_3.response)["stored_messages"].to_i, "Don't cleaned all messages") fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do pub_2.callback do
publish_message_inline_with_callbacks(channel, headers, body, { fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
:error => Proc.new do |status, content| published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) EM.add_timer(50) do
result = JSON.parse(pub_4.response) pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
assert_equal(stored_messages_setp_1, result["stored_messages"].to_i, "Don't cleaned all messages") pub_3.callback do
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory") fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
EventMachine.stop assert_equal(0, JSON.parse(pub_3.response)["stored_messages"].to_i, "Don't cleaned all messages")
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel, headers, body, {
: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.callback do
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)
assert_equal(stored_messages_setp_1, result["stored_messages"].to_i, "Don't cleaned all messages")
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory")
EventMachine.stop
end
end
})
end
end
end
end
end
})
end end
end end
}) end
end end
end })
end end
add_test_timeout(@@timeout) add_test_timeout(@@timeout)
end end
...@@ -133,23 +132,22 @@ class TestCleanupMemoryAfterReload < Test::Unit::TestCase ...@@ -133,23 +132,22 @@ class TestCleanupMemoryAfterReload < Test::Unit::TestCase
assert_equal(messages_to_publish, stored_messages_setp_1, "Don't store messages") assert_equal(messages_to_publish, stored_messages_setp_1, "Don't store messages")
reload_worker reload_worker
end
end
count += 1
end
EM.add_timer(14) 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, :timeout => 60
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
assert(stored_messages_setp_1 > stored_messages_setp_2, "Don't clear messages") assert(stored_messages_setp_1 > stored_messages_setp_2, "Don't clear messages")
assert(stored_messages_setp_2 >= (messages_to_publish / 2), "Cleared all messages") assert(stored_messages_setp_2 > 0, "Cleared all messages")
EventMachine.stop EventMachine.stop
end
end
end
end end
count += 1
end end
add_test_timeout(20) add_test_timeout(20)
end end
end end
...@@ -191,48 +189,47 @@ class TestCleanupMemoryAfterReload < Test::Unit::TestCase ...@@ -191,48 +189,47 @@ class TestCleanupMemoryAfterReload < Test::Unit::TestCase
sleep(1) sleep(1)
# 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, :timeout => 60
end EM.add_timer(40) do
end fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
}) publish_message_inline_with_callbacks(channel, headers, body, {
end :error => Proc.new do |status2, content2|
fill_memory_timer.cancel
EM.add_timer(45) do pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do pub_2.callback do
publish_message_inline_with_callbacks(channel, headers, body, { fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
:error => Proc.new do |status, content| published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
fill_memory_timer.cancel fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
pub_2.callback do EM.add_timer(50) do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0) pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i pub_3.callback do
fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2 fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
end assert_equal(0, JSON.parse(pub_3.response)["stored_messages"].to_i, "Don't cleaned all messages")
end
}) fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
end publish_message_inline_with_callbacks(channel, headers, body, {
end :error => Proc.new do |status3, content3|
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
EM.add_timer(@@second_step_timer) do pub_4.callback do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0)
pub_3.callback do result = JSON.parse(pub_4.response)
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) assert_equal(stored_messages_setp_1, result["stored_messages"].to_i, "Don't cleaned all messages")
assert_equal(0, JSON.parse(pub_3.response)["stored_messages"].to_i, "Don't cleaned all messages") assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory")
EventMachine.stop
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do end
publish_message_inline_with_callbacks(channel, headers, body, { end
:error => Proc.new do |status, content| })
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 end
pub_4.callback do end
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) end
result = JSON.parse(pub_4.response) end
assert_equal(stored_messages_setp_1, result["stored_messages"].to_i, "Don't cleaned all messages") end
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory") })
EventMachine.stop
end end
end end
}) end
end end
end })
end end
add_test_timeout(@@timeout) add_test_timeout(@@timeout)
end end
...@@ -269,61 +266,60 @@ class TestCleanupMemoryAfterReload < Test::Unit::TestCase ...@@ -269,61 +266,60 @@ class TestCleanupMemoryAfterReload < Test::Unit::TestCase
fail("Don't create any channel") if channels_setp_1 == 0 fail("Don't create any channel") if channels_setp_1 == 0
reload_worker reload_worker
end
end
})
i += 1
end
EM.add_timer(40) do
j = 0
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel + j.to_s, headers, body, {
:error => Proc.new do |status, content|
fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
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 create more channel") if published_messages_setp_1 == JSON.parse(pub_2.response)["published_messages"].to_i
end
end
})
j += 1
end
end
EM.add_timer(@@second_step_timer) do EM.add_timer(35) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 j = 0
pub_3.callback do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) publish_message_inline_with_callbacks(channel + j.to_s, headers, body, {
channels = JSON.parse(pub_3.response)["channels"].to_i :error => Proc.new do |status2, content2|
fill_memory_timer.cancel
assert_equal(0, channels, "Don't removed all channels") pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
EventMachine.stop unless (channels == 0) pub_2.callback do
fail("Don't received the stats") if (pub_2.response_header.status != 200) || (pub_2.response_header.content_length == 0)
EM.add_timer(35) do fail("Don't create more channel") if published_messages_setp_1 == JSON.parse(pub_2.response)["published_messages"].to_i
i = 0
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do EM.add_timer(40) do
publish_message_inline_with_callbacks(channel + i.to_s, headers, body, { pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
:error => Proc.new do |status, content| pub_3.callback do
fill_memory_timer.cancel fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 channels = JSON.parse(pub_3.response)["channels"].to_i
pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) assert_equal(0, channels, "Don't removed all channels")
channels_setp_2 = JSON.parse(pub_4.response)["channels"].to_i EventMachine.stop unless (channels == 0)
assert_equal(channels_setp_1, channels_setp_2, "Don't released all memory") EM.add_timer(35) do
EventMachine.stop i = 0
end fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
publish_message_inline_with_callbacks(channel + i.to_s, headers, body, {
:error => Proc.new do |status3, content3|
fill_memory_timer.cancel
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
pub_4.callback do
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
assert_equal(channels_setp_1, channels_setp_2, "Don't released all memory")
EventMachine.stop
end
end
})
i += 1
end
end
end
end
end
end
})
j += 1
end end
}) end
i += 1
end end
end end
end })
i += 1
end end
add_test_timeout(@@timeout + 35) add_test_timeout(@@timeout)
end end
end end
...@@ -361,47 +357,47 @@ class TestCleanupMemoryAfterReload < Test::Unit::TestCase ...@@ -361,47 +357,47 @@ class TestCleanupMemoryAfterReload < Test::Unit::TestCase
sleep(1) sleep(1)
# 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, :timeout => 60
end
end
})
end
EM.add_timer(40) 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 |status, content| :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, :timeout => 60
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
end
end EM.add_timer(35) do
}) pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
end pub_3.callback do
end fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
assert_equal(0, JSON.parse(pub_3.response)["channels"].to_i, "Don't cleaned all messages/channels")
EM.add_timer(@@second_step_timer) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
pub_3.callback do publish_message_inline_with_callbacks(channel, headers, body, {
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) :error => Proc.new do |status3, content3|
assert_equal(0, JSON.parse(pub_3.response)["channels"].to_i, "Don't cleaned all messages/channels") pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60
pub_4.callback do
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0)
publish_message_inline_with_callbacks(channel, headers, body, { result = JSON.parse(pub_4.response)
:error => Proc.new do |status, content| assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory")
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers, :timeout => 60 EventMachine.stop
pub_4.callback do end
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) end
result = JSON.parse(pub_4.response) })
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory") end
EventMachine.stop end
end
end
end
})
end end
end end
}) end
end end
end })
end end
add_test_timeout(@@timeout) add_test_timeout(@@timeout)
end end
...@@ -436,56 +432,55 @@ class TestCleanupMemoryAfterReload < Test::Unit::TestCase ...@@ -436,56 +432,55 @@ class TestCleanupMemoryAfterReload < Test::Unit::TestCase
published_messages_setp_1 = result["published_messages"].to_i published_messages_setp_1 = result["published_messages"].to_i
reload_worker reload_worker
end
end
})
i += 1
end
EM.add_timer(40) do EM.add_timer(35) do
j = 0 j = 0
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) 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 |status, content| :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, :timeout => 60
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
end EM.add_timer(35) do
end pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
}) pub_3.callback do
j += 1 fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0)
end assert_equal(0, JSON.parse(pub_3.response)["channels"].to_i, "Don't cleaned all messages/channels")
end
EM.add_timer(35) do
EM.add_timer(@@second_step_timer) do fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 publish_message_inline_with_callbacks(channel + i.to_s, headers, body, {
pub_3.callback do :error => Proc.new do |status3, content3|
fail("Don't received the stats") if (pub_3.response_header.status != 200) || (pub_3.response_header.content_length == 0) pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60
assert_equal(0, JSON.parse(pub_3.response)["channels"].to_i, "Don't cleaned all messages/channels") pub_4.callback do
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0)
EM.add_timer(35) do result = JSON.parse(pub_4.response)
fill_memory_timer = EventMachine::PeriodicTimer.new(0.001) do assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory")
publish_message_inline_with_callbacks(channel + i.to_s, headers, body, { EventMachine.stop
:error => Proc.new do |status, content| end
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers, :timeout => 60 end
pub_4.callback do })
fail("Don't received the stats") if (pub_4.response_header.status != 200) || (pub_4.response_header.content_length == 0) i += 1
result = JSON.parse(pub_4.response) end
assert_equal(published_messages_setp_1, (result["published_messages"].to_i - published_messages_setp_2), "Don't cleaned all memory") end
EventMachine.stop end
end end
end
end
})
j += 1
end end
}) end
i += 1
end end
end end
end })
i += 1
end end
add_test_timeout(@@timeout + 35) add_test_timeout(@@timeout)
end end
end end
......
...@@ -41,8 +41,8 @@ class TestComunicationProperties < Test::Unit::TestCase ...@@ -41,8 +41,8 @@ class TestComunicationProperties < Test::Unit::TestCase
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, :timeout => 30
pub.callback { pub.callback {
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, :timeout => 60
sub_2.stream { |chunk| sub_2.stream { |chunk2|
assert_equal("#{@header_template}\r\n", chunk, "Didn't received header template") assert_equal("#{@header_template}\r\n", chunk2, "Didn't received header template")
EventMachine.stop EventMachine.stop
} }
} }
...@@ -70,7 +70,7 @@ class TestComunicationProperties < Test::Unit::TestCase ...@@ -70,7 +70,7 @@ class TestComunicationProperties < Test::Unit::TestCase
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, :timeout => 60
sub_1.stream { |chunk| sub_1.stream { |chunk|
response_1 += chunk response_1 += chunk
sub_1.close_connection if response_1.include?(body) sub_1.close if response_1.include?(body)
} }
end end
...@@ -78,7 +78,7 @@ class TestComunicationProperties < Test::Unit::TestCase ...@@ -78,7 +78,7 @@ class TestComunicationProperties < Test::Unit::TestCase
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, :timeout => 60
sub_2.stream { |chunk| sub_2.stream { |chunk|
response_2 += chunk response_2 += chunk
sub_2.close_connection if response_2.include?(body) sub_2.close if response_2.include?(body)
} }
end end
...@@ -87,13 +87,13 @@ class TestComunicationProperties < Test::Unit::TestCase ...@@ -87,13 +87,13 @@ class TestComunicationProperties < Test::Unit::TestCase
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, :timeout => 60
sub_3.stream { |chunk| sub_3.stream { |chunk|
response_3 += chunk response_3 += chunk
sub_3.close_connection if response_3.include?(body) sub_3.close if response_3.include?(body)
} }
end end
EM.add_timer(17) do EM.add_timer(17) do
assert_equal("#{@header_template}\r\n#{body}\r\n", response_1, "Didn't received header and message") assert_equal("#{@header_template}\r\n#{body}\r\n\r\n", response_1, "Didn't received header and message")
assert_equal("#{@header_template}\r\n#{body}\r\n", response_2, "Didn't received header and message") assert_equal("#{@header_template}\r\n#{body}\r\n\r\n", response_2, "Didn't received header and message")
assert_equal("#{@header_template}\r\n", response_3, "Didn't received header") assert_equal("#{@header_template}\r\n", response_3, "Didn't received header")
EventMachine.stop EventMachine.stop
end end
......
...@@ -6,7 +6,7 @@ class TestMeasureMemory < Test::Unit::TestCase ...@@ -6,7 +6,7 @@ class TestMeasureMemory < Test::Unit::TestCase
@@message_estimate_size = 174 @@message_estimate_size = 174
@@channel_estimate_size = 536 @@channel_estimate_size = 536
@@subscriber_estimate_size = 230 @@subscriber_estimate_size = 230
@@subscriber_estimate_system_size = 6890 @@subscriber_estimate_system_size = 6860
def global_configuration def global_configuration
@max_reserved_memory = "2m" @max_reserved_memory = "2m"
...@@ -61,7 +61,7 @@ class TestMeasureMemory < Test::Unit::TestCase ...@@ -61,7 +61,7 @@ class TestMeasureMemory < Test::Unit::TestCase
EventMachine.run { EventMachine.run {
publish_message_in_loop(1000, headers, body) publish_message_in_loop(1000, headers, body)
add_test_timeout(20) add_test_timeout(25)
} }
EventMachine.run { EventMachine.run {
......
...@@ -77,32 +77,32 @@ class TestPublisher < Test::Unit::TestCase ...@@ -77,32 +77,32 @@ class TestPublisher < Test::Unit::TestCase
EventMachine.run { EventMachine.run {
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_accepted_methods_1').get) multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_accepted_methods_1').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_accepted_methods_2').put :body => 'body') multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_accepted_methods_2').put(:body => 'body'))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_accepted_methods_3').post) multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_accepted_methods_3').post)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_accepted_methods_4').delete) multi.add(:d, EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_accepted_methods_4').delete)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_accepted_methods_5').head) multi.add(:e, EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_accepted_methods_5').head)
multi.callback { multi.callback {
assert_equal(5, multi.responses[:succeeded].length) assert_equal(5, multi.responses[:callback].length)
assert_not_equal(405, multi.responses[:succeeded][0].response_header.status, "Publisher does accept GET") assert_not_equal(405, multi.responses[:callback][:a].response_header.status, "Publisher does accept GET")
assert_equal("GET", multi.responses[:succeeded][0].method, "Array is with wrong order") assert_equal("GET", multi.responses[:callback][:a].req.method, "Array is with wrong order")
assert_equal(405, multi.responses[:succeeded][1].response_header.status, "Publisher does not accept PUT") assert_equal(405, multi.responses[:callback][:b].response_header.status, "Publisher does not accept PUT")
assert_equal("GET, POST", multi.responses[:succeeded][1].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET, POST", multi.responses[:callback][:b].response_header['ALLOW'], "Didn't receive the right error message")
assert_equal("PUT", multi.responses[:succeeded][1].method, "Array is with wrong order") assert_equal("PUT", multi.responses[:callback][:b].req.method, "Array is with wrong order")
assert_not_equal(405, multi.responses[:succeeded][2].response_header.status, "Publisher does accept POST") assert_not_equal(405, multi.responses[:callback][:c].response_header.status, "Publisher does accept POST")
assert_equal("POST", multi.responses[:succeeded][2].method, "Array is with wrong order") assert_equal("POST", multi.responses[:callback][:c].req.method, "Array is with wrong order")
assert_equal(405, multi.responses[:succeeded][3].response_header.status, "Publisher does not accept DELETE") assert_equal(405, multi.responses[:callback][:d].response_header.status, "Publisher does not accept DELETE")
assert_equal("DELETE", multi.responses[:succeeded][3].method, "Array is with wrong order") assert_equal("DELETE", multi.responses[:callback][:d].req.method, "Array is with wrong order")
assert_equal("GET, POST", multi.responses[:succeeded][3].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET, POST", multi.responses[:callback][:d].response_header['ALLOW'], "Didn't receive the right error message")
assert_equal(405, multi.responses[:succeeded][4].response_header.status, "Publisher does not accept HEAD") assert_equal(405, multi.responses[:callback][:e].response_header.status, "Publisher does not accept HEAD")
assert_equal("HEAD", multi.responses[:succeeded][4].method, "Array is with wrong order") assert_equal("HEAD", multi.responses[:callback][:e].req.method, "Array is with wrong order")
assert_equal("GET, POST", multi.responses[:succeeded][4].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET, POST", multi.responses[:callback][:e].response_header['ALLOW'], "Didn't receive the right error message")
EventMachine.stop EventMachine.stop
} }
...@@ -135,15 +135,15 @@ class TestPublisher < Test::Unit::TestCase ...@@ -135,15 +135,15 @@ class TestPublisher < Test::Unit::TestCase
EventMachine.run { EventMachine.run {
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1).post :head => headers, :body => body, :timeout => 30) multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1).post(:head => headers, :body => body, :timeout => 30))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2).post :head => headers, :body => body, :timeout => 30) multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2).post(:head => headers, :body => body, :timeout => 30))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_3).post :head => headers, :body => body, :timeout => 30) multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_3).post(:head => headers, :body => body, :timeout => 30))
multi.callback { multi.callback {
assert_equal(3, multi.responses[:succeeded].length) assert_equal(3, multi.responses[:callback].length)
0.upto(2) do |i| multi.responses[:callback].each do |name, response|
assert_equal(403, multi.responses[:succeeded][i].response_header.status, "Channel was created") assert_equal(403, response.response_header.status, "Channel was created")
assert_equal(0, multi.responses[:succeeded][i].response_header.content_length, "Received response for creating channel with id containing wildcard") assert_equal(0, response.response_header.content_length, "Received response for creating channel with id containing wildcard")
assert_equal("Channel id not authorized for this method.", multi.responses[:succeeded][i].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'], "Didn't receive the right error message") assert_equal("Channel id not authorized for this method.", response.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'], "Didn't receive the right error message")
end end
EventMachine.stop EventMachine.stop
......
...@@ -81,31 +81,31 @@ class TestPublisherAdmin < Test::Unit::TestCase ...@@ -81,31 +81,31 @@ class TestPublisherAdmin < Test::Unit::TestCase
EventMachine.run { EventMachine.run {
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_admin_accepted_methods_1').get) multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_admin_accepted_methods_1').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_admin_accepted_methods_2').put :body => 'body') multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_admin_accepted_methods_2').put(:body => 'body'))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_admin_accepted_methods_3').post) multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_admin_accepted_methods_3').post)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_admin_accepted_methods_4').delete) multi.add(:d, EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_admin_accepted_methods_4').delete)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_admin_accepted_methods_5').head) multi.add(:e, EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_admin_accepted_methods_5').head)
multi.callback { multi.callback {
assert_equal(5, multi.responses[:succeeded].length) assert_equal(5, multi.responses[:callback].length)
assert_not_equal(405, multi.responses[:succeeded][0].response_header.status, "Publisher does accept GET") assert_not_equal(405, multi.responses[:callback][:a].response_header.status, "Publisher does accept GET")
assert_equal("GET", multi.responses[:succeeded][0].method, "Array is with wrong order") assert_equal("GET", multi.responses[:callback][:a].req.method, "Array is with wrong order")
assert_equal(405, multi.responses[:succeeded][1].response_header.status, "Publisher does not accept PUT") assert_equal(405, multi.responses[:callback][:b].response_header.status, "Publisher does not accept PUT")
assert_equal("GET, POST, DELETE", multi.responses[:succeeded][1].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET, POST, DELETE", multi.responses[:callback][:b].response_header['ALLOW'], "Didn't receive the right error message")
assert_equal("PUT", multi.responses[:succeeded][1].method, "Array is with wrong order") assert_equal("PUT", multi.responses[:callback][:b].req.method, "Array is with wrong order")
assert_not_equal(405, multi.responses[:succeeded][2].response_header.status, "Publisher does accept POST") assert_not_equal(405, multi.responses[:callback][:c].response_header.status, "Publisher does accept POST")
assert_equal("POST", multi.responses[:succeeded][2].method, "Array is with wrong order") assert_equal("POST", multi.responses[:callback][:c].req.method, "Array is with wrong order")
assert_not_equal(405, multi.responses[:succeeded][3].response_header.status, "Publisher does accept DELETE") assert_not_equal(405, multi.responses[:callback][:d].response_header.status, "Publisher does accept DELETE")
assert_equal("DELETE", multi.responses[:succeeded][3].method, "Array is with wrong order") assert_equal("DELETE", multi.responses[:callback][:d].req.method, "Array is with wrong order")
assert_equal(405, multi.responses[:succeeded][4].response_header.status, "Publisher does not accept HEAD") assert_equal(405, multi.responses[:callback][:e].response_header.status, "Publisher does not accept HEAD")
assert_equal("HEAD", multi.responses[:succeeded][4].method, "Array is with wrong order") assert_equal("HEAD", multi.responses[:callback][:e].req.method, "Array is with wrong order")
assert_equal("GET, POST, DELETE", multi.responses[:succeeded][4].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET, POST, DELETE", multi.responses[:callback][:e].response_header['ALLOW'], "Didn't receive the right error message")
EventMachine.stop EventMachine.stop
} }
...@@ -138,15 +138,15 @@ class TestPublisherAdmin < Test::Unit::TestCase ...@@ -138,15 +138,15 @@ class TestPublisherAdmin < Test::Unit::TestCase
EventMachine.run { EventMachine.run {
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1).post :head => headers, :body => body, :timeout => 30) multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1).post(:head => headers, :body => body, :timeout => 30))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2).post :head => headers, :body => body, :timeout => 30) multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2).post(:head => headers, :body => body, :timeout => 30))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_3).post :head => headers, :body => body, :timeout => 30) multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_3).post(:head => headers, :body => body, :timeout => 30))
multi.callback { multi.callback {
assert_equal(3, multi.responses[:succeeded].length) assert_equal(3, multi.responses[:callback].length)
0.upto(2) do |i| multi.responses[:callback].each do |name, response|
assert_equal(403, multi.responses[:succeeded][i].response_header.status, "Channel was created") assert_equal(403, response.response_header.status, "Channel was created")
assert_equal(0, multi.responses[:succeeded][i].response_header.content_length, "Received response for creating channel with id containing wildcard") assert_equal(0, response.response_header.content_length, "Received response for creating channel with id containing wildcard")
assert_equal("Channel id not authorized for this method.", multi.responses[:succeeded][i].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'], "Didn't receive the right error message") assert_equal("Channel id not authorized for this method.", response.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'], "Didn't receive the right error message")
end end
EventMachine.stop EventMachine.stop
......
...@@ -18,33 +18,33 @@ class TestSubscriber < Test::Unit::TestCase ...@@ -18,33 +18,33 @@ class TestSubscriber < Test::Unit::TestCase
EventMachine.run { EventMachine.run {
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/ch_test_accepted_methods_1').head) multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_test_accepted_methods_1').head)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/ch_test_accepted_methods_2').put :body => 'body') multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_test_accepted_methods_2').put(:body => 'body'))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/ch_test_accepted_methods_3').post) multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_test_accepted_methods_3').post)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/ch_test_accepted_methods_4').delete) multi.add(:d, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_test_accepted_methods_4').delete)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/ch_test_accepted_methods_5').get) multi.add(:e, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_test_accepted_methods_5').get)
multi.callback { multi.callback {
assert_equal(5, multi.responses[:succeeded].length) assert_equal(5, multi.responses[:callback].length)
assert_equal(405, multi.responses[:succeeded][0].response_header.status, "Publisher does not accept HEAD") assert_equal(405, multi.responses[:callback][:a].response_header.status, "Publisher does not accept HEAD")
assert_equal("HEAD", multi.responses[:succeeded][0].method, "Array is with wrong order") assert_equal("HEAD", multi.responses[:callback][:a].req.method, "Array is with wrong order")
assert_equal("GET", multi.responses[:succeeded][0].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET", multi.responses[:callback][:a].response_header['ALLOW'], "Didn't receive the right error message")
assert_equal(405, multi.responses[:succeeded][1].response_header.status, "Publisher does not accept PUT") assert_equal(405, multi.responses[:callback][:b].response_header.status, "Publisher does not accept PUT")
assert_equal("PUT", multi.responses[:succeeded][1].method, "Array is with wrong order") assert_equal("PUT", multi.responses[:callback][:b].req.method, "Array is with wrong order")
assert_equal("GET", multi.responses[:succeeded][1].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET", multi.responses[:callback][:b].response_header['ALLOW'], "Didn't receive the right error message")
assert_equal(405, multi.responses[:succeeded][2].response_header.status, "Publisher does accept POST") assert_equal(405, multi.responses[:callback][:c].response_header.status, "Publisher does accept POST")
assert_equal("POST", multi.responses[:succeeded][2].method, "Array is with wrong order") assert_equal("POST", multi.responses[:callback][:c].req.method, "Array is with wrong order")
assert_equal("GET", multi.responses[:succeeded][1].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET", multi.responses[:callback][:b].response_header['ALLOW'], "Didn't receive the right error message")
assert_equal(405, multi.responses[:succeeded][3].response_header.status, "Publisher does not accept DELETE") assert_equal(405, multi.responses[:callback][:d].response_header.status, "Publisher does not accept DELETE")
assert_equal("DELETE", multi.responses[:succeeded][3].method, "Array is with wrong order") assert_equal("DELETE", multi.responses[:callback][:d].req.method, "Array is with wrong order")
assert_equal("GET", multi.responses[:succeeded][3].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET", multi.responses[:callback][:d].response_header['ALLOW'], "Didn't receive the right error message")
assert_not_equal(405, multi.responses[:succeeded][4].response_header.status, "Publisher does accept GET") assert_not_equal(405, multi.responses[:callback][:e].response_header.status, "Publisher does accept GET")
assert_equal("GET", multi.responses[:succeeded][4].method, "Array is with wrong order") assert_equal("GET", multi.responses[:callback][:e].req.method, "Array is with wrong order")
EventMachine.stop EventMachine.stop
} }
...@@ -73,18 +73,18 @@ class TestSubscriber < Test::Unit::TestCase ...@@ -73,18 +73,18 @@ class TestSubscriber < Test::Unit::TestCase
EventMachine.run { EventMachine.run {
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_1').get) multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_1').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_1.b10').get) multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_1.b10').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_2/ch_multi_channels_3').get) multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_2/ch_multi_channels_3').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_2.b2/ch_multi_channels_3').get) multi.add(:d, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_2.b2/ch_multi_channels_3').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_2/ch_multi_channels_3.b3').get) multi.add(:e, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_2/ch_multi_channels_3.b3').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_2.b2/ch_multi_channels_3.b3').get) multi.add(:f, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_2.b2/ch_multi_channels_3.b3').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_4.b').get) multi.add(:g, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_4.b').get)
multi.callback { multi.callback {
assert_equal(7, multi.responses[:succeeded].length) assert_equal(7, multi.responses[:callback].length)
0.upto(6) do |i| multi.responses[:callback].each do |name, response|
assert_equal(200, multi.responses[:succeeded][i].response_header.status, "Subscriber not accepted") assert_equal(200, response.response_header.status, "Subscriber not accepted")
end end
EventMachine.stop EventMachine.stop
...@@ -135,15 +135,15 @@ class TestSubscriber < Test::Unit::TestCase ...@@ -135,15 +135,15 @@ class TestSubscriber < Test::Unit::TestCase
EventMachine.run { EventMachine.run {
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(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, :timeout => 30))
multi.add(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, :timeout => 30))
multi.add(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, :timeout => 30))
multi.callback { multi.callback {
assert_equal(3, multi.responses[:succeeded].length) assert_equal(3, multi.responses[:callback].length)
0.upto(2) do |i| multi.responses[:callback].each do |name, response|
assert_equal(403, multi.responses[:succeeded][i].response_header.status, "Channel was created") assert_equal(403, response.response_header.status, "Channel was created")
assert_equal(0, multi.responses[:succeeded][i].response_header.content_length, "Received response for creating channel with id containing wildcard") assert_equal(0, response.response_header.content_length, "Received response for creating channel with id containing wildcard")
assert_equal("Channel id not authorized for this method.", multi.responses[:succeeded][i].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'], "Didn't receive the right error message") assert_equal("Channel id not authorized for this method.", response.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'], "Didn't receive the right error message")
end end
EventMachine.stop EventMachine.stop
...@@ -167,29 +167,29 @@ class TestSubscriber < Test::Unit::TestCase ...@@ -167,29 +167,29 @@ class TestSubscriber < Test::Unit::TestCase
EventMachine.run { EventMachine.run {
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/bd_test_broadcast_channels_without_common_channel').get) multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/sub/bd_test_broadcast_channels_without_common_channel').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/bd_').get) multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/sub/bd_').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/bd1').get) multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/sub/bd1').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/bd').get) multi.add(:d, EventMachine::HttpRequest.new(nginx_address + '/sub/bd').get)
multi.callback { multi.callback {
assert_equal(4, multi.responses[:succeeded].length) assert_equal(4, multi.responses[:callback].length)
assert_equal(0, multi.responses[:succeeded][0].response_header.content_length, "Should response only with headers") assert_equal(0, multi.responses[:callback][:a].response_header.content_length, "Should response only with headers")
assert_equal(403, multi.responses[:succeeded][0].response_header.status, "Request was not understood as a bad request") assert_equal(403, multi.responses[:callback][:a].response_header.status, "Request was not understood as a bad request")
assert_equal("Subscribed too much broadcast channels.", multi.responses[:succeeded][0].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'], "Didn't receive the right error message") assert_equal("Subscribed too much broadcast channels.", multi.responses[:callback][:a].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'], "Didn't receive the right error message")
assert_equal(nginx_address + '/sub/bd_test_broadcast_channels_without_common_channel', multi.responses[:succeeded][0].uri.to_s, "Array is with wrong order") assert_equal(nginx_address + '/sub/bd_test_broadcast_channels_without_common_channel', multi.responses[:callback][:a].req.uri.to_s, "Array is with wrong order")
assert_equal(0, multi.responses[:succeeded][1].response_header.content_length, "Should response only with headers") assert_equal(0, multi.responses[:callback][:b].response_header.content_length, "Should response only with headers")
assert_equal(403, multi.responses[:succeeded][1].response_header.status, "Request was not understood as a bad request") assert_equal(403, multi.responses[:callback][:b].response_header.status, "Request was not understood as a bad request")
assert_equal("Subscribed too much broadcast channels.", multi.responses[:succeeded][1].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'], "Didn't receive the right error message") assert_equal("Subscribed too much broadcast channels.", multi.responses[:callback][:b].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'], "Didn't receive the right error message")
assert_equal(nginx_address + '/sub/bd_', multi.responses[:succeeded][1].uri.to_s, "Array is with wrong order") assert_equal(nginx_address + '/sub/bd_', multi.responses[:callback][:b].req.uri.to_s, "Array is with wrong order")
assert_equal(200, multi.responses[:succeeded][2].response_header.status, "Channel id starting with different prefix from broadcast was not accept") assert_equal(200, multi.responses[:callback][:c].response_header.status, "Channel id starting with different prefix from broadcast was not accept")
assert_equal(nginx_address + '/sub/bd1', multi.responses[:succeeded][2].uri.to_s, "Array is with wrong order") assert_equal(nginx_address + '/sub/bd1', multi.responses[:callback][:c].req.uri.to_s, "Array is with wrong order")
assert_equal(200, multi.responses[:succeeded][3].response_header.status, "Channel id starting with different prefix from broadcast was not accept") assert_equal(200, multi.responses[:callback][:d].response_header.status, "Channel id starting with different prefix from broadcast was not accept")
assert_equal(nginx_address + '/sub/bd', multi.responses[:succeeded][3].uri.to_s, "Array is with wrong order") assert_equal(nginx_address + '/sub/bd', multi.responses[:callback][:d].req.uri.to_s, "Array is with wrong order")
EventMachine.stop EventMachine.stop
} }
...@@ -209,27 +209,27 @@ class TestSubscriber < Test::Unit::TestCase ...@@ -209,27 +209,27 @@ class TestSubscriber < Test::Unit::TestCase
EventMachine.run { EventMachine.run {
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/bd1/bd2/bd3/bd4/bd_1/bd_2/bd_3').get) multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/sub/bd1/bd2/bd3/bd4/bd_1/bd_2/bd_3').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/bd1/bd2/bd_1/bd_2').get) multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/sub/bd1/bd2/bd_1/bd_2').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/bd1/bd_1').get) multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/sub/bd1/bd_1').get)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/sub/bd1/bd2').get) multi.add(:d, EventMachine::HttpRequest.new(nginx_address + '/sub/bd1/bd2').get)
multi.callback { multi.callback {
assert_equal(4, multi.responses[:succeeded].length) assert_equal(4, multi.responses[:callback].length)
assert_equal(0, multi.responses[:succeeded][0].response_header.content_length, "Should response only with headers") assert_equal(0, multi.responses[:callback][:a].response_header.content_length, "Should response only with headers")
assert_equal(403, multi.responses[:succeeded][0].response_header.status, "Request was not understood as a bad request") assert_equal(403, multi.responses[:callback][:a].response_header.status, "Request was not understood as a bad request")
assert_equal("Subscribed too much broadcast channels.", multi.responses[:succeeded][0].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'], "Didn't receive the right error message") assert_equal("Subscribed too much broadcast channels.", multi.responses[:callback][:a].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'], "Didn't receive the right error message")
assert_equal(nginx_address + '/sub/bd1/bd2/bd3/bd4/bd_1/bd_2/bd_3', multi.responses[:succeeded][0].uri.to_s, "Array is with wrong order") assert_equal(nginx_address + '/sub/bd1/bd2/bd3/bd4/bd_1/bd_2/bd_3', multi.responses[:callback][:a].req.uri.to_s, "Array is with wrong order")
assert_equal(200, multi.responses[:succeeded][1].response_header.status, "Request was not understood as a bad request") assert_equal(200, multi.responses[:callback][:b].response_header.status, "Request was not understood as a bad request")
assert_equal(nginx_address + '/sub/bd1/bd2/bd_1/bd_2', multi.responses[:succeeded][1].uri.to_s, "Array is with wrong order") assert_equal(nginx_address + '/sub/bd1/bd2/bd_1/bd_2', multi.responses[:callback][:b].req.uri.to_s, "Array is with wrong order")
assert_equal(200, multi.responses[:succeeded][2].response_header.status, "Channel id starting with different prefix from broadcast was not accept") assert_equal(200, multi.responses[:callback][:c].response_header.status, "Channel id starting with different prefix from broadcast was not accept")
assert_equal(nginx_address + '/sub/bd1/bd_1', multi.responses[:succeeded][2].uri.to_s, "Array is with wrong order") assert_equal(nginx_address + '/sub/bd1/bd_1', multi.responses[:callback][:c].req.uri.to_s, "Array is with wrong order")
assert_equal(200, multi.responses[:succeeded][3].response_header.status, "Channel id starting with different prefix from broadcast was not accept") assert_equal(200, multi.responses[:callback][:d].response_header.status, "Channel id starting with different prefix from broadcast was not accept")
assert_equal(nginx_address + '/sub/bd1/bd2', multi.responses[:succeeded][3].uri.to_s, "Array is with wrong order") assert_equal(nginx_address + '/sub/bd1/bd2', multi.responses[:callback][:d].req.uri.to_s, "Array is with wrong order")
EventMachine.stop EventMachine.stop
} }
......
...@@ -18,7 +18,7 @@ class TestSubscriberConnectionCleanup < Test::Unit::TestCase ...@@ -18,7 +18,7 @@ class TestSubscriberConnectionCleanup < Test::Unit::TestCase
response = '' response = ''
EventMachine.run { EventMachine.run {
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, :inactivity_timeout => 60).get :head => headers, :timeout => 60
sub.stream { |chunk| sub.stream { |chunk|
response += chunk response += chunk
assert(response.include?(@header_template), "Didn't received header template") assert(response.include?(@header_template), "Didn't received header template")
...@@ -50,7 +50,7 @@ class TestSubscriberConnectionCleanup < Test::Unit::TestCase ...@@ -50,7 +50,7 @@ class TestSubscriberConnectionCleanup < Test::Unit::TestCase
chunksReceived = 0 chunksReceived = 0
EventMachine.run { EventMachine.run {
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, :inactivity_timeout => 15).get :head => headers, :timeout => 60
sub.stream { |chunk| sub.stream { |chunk|
chunksReceived += 1; chunksReceived += 1;
} }
......
...@@ -325,7 +325,7 @@ class TestSubscriberLongPolling < Test::Unit::TestCase ...@@ -325,7 +325,7 @@ class TestSubscriberLongPolling < Test::Unit::TestCase
start = Time.now start = Time.now
EventMachine.run { EventMachine.run {
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :timeout => 30 sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s, :inactivity_timeout => 30).get :timeout => 30
sub.callback { sub.callback {
stop = Time.now stop = Time.now
elapsed = time_diff_sec(start, stop) elapsed = time_diff_sec(start, stop)
......
...@@ -23,33 +23,33 @@ class TestWebSocket < Test::Unit::TestCase ...@@ -23,33 +23,33 @@ class TestWebSocket < Test::Unit::TestCase
EventMachine.run { EventMachine.run {
multi = EventMachine::MultiRequest.new multi = EventMachine::MultiRequest.new
multi.add(EventMachine::HttpRequest.new(nginx_address + '/ws/ch_test_accepted_methods_1').head) multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/ws/ch_test_accepted_methods_1').head)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/ws/ch_test_accepted_methods_2').put :body => 'body') multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/ws/ch_test_accepted_methods_2').put(:body => 'body'))
multi.add(EventMachine::HttpRequest.new(nginx_address + '/ws/ch_test_accepted_methods_3').post) multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/ws/ch_test_accepted_methods_3').post)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/ws/ch_test_accepted_methods_4').delete) multi.add(:d, EventMachine::HttpRequest.new(nginx_address + '/ws/ch_test_accepted_methods_4').delete)
multi.add(EventMachine::HttpRequest.new(nginx_address + '/ws/ch_test_accepted_methods_5').get) multi.add(:e, EventMachine::HttpRequest.new(nginx_address + '/ws/ch_test_accepted_methods_5').get)
multi.callback { multi.callback {
assert_equal(5, multi.responses[:succeeded].length) assert_equal(5, multi.responses[:callback].length)
assert_equal(405, multi.responses[:succeeded][0].response_header.status, "Publisher does not accept HEAD") assert_equal(405, multi.responses[:callback][:a].response_header.status, "Publisher does not accept HEAD")
assert_equal("HEAD", multi.responses[:succeeded][0].method, "Array is with wrong order") assert_equal("HEAD", multi.responses[:callback][:a].req.method, "Array is with wrong order")
assert_equal("GET", multi.responses[:succeeded][0].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET", multi.responses[:callback][:a].response_header['ALLOW'], "Didn't receive the right error message")
assert_equal(405, multi.responses[:succeeded][1].response_header.status, "Publisher does not accept PUT") assert_equal(405, multi.responses[:callback][:b].response_header.status, "Publisher does not accept PUT")
assert_equal("PUT", multi.responses[:succeeded][1].method, "Array is with wrong order") assert_equal("PUT", multi.responses[:callback][:b].req.method, "Array is with wrong order")
assert_equal("GET", multi.responses[:succeeded][1].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET", multi.responses[:callback][:b].response_header['ALLOW'], "Didn't receive the right error message")
assert_equal(405, multi.responses[:succeeded][2].response_header.status, "Publisher does accept POST") assert_equal(405, multi.responses[:callback][:c].response_header.status, "Publisher does accept POST")
assert_equal("POST", multi.responses[:succeeded][2].method, "Array is with wrong order") assert_equal("POST", multi.responses[:callback][:c].req.method, "Array is with wrong order")
assert_equal("GET", multi.responses[:succeeded][1].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET", multi.responses[:callback][:b].response_header['ALLOW'], "Didn't receive the right error message")
assert_equal(405, multi.responses[:succeeded][3].response_header.status, "Publisher does not accept DELETE") assert_equal(405, multi.responses[:callback][:d].response_header.status, "Publisher does not accept DELETE")
assert_equal("DELETE", multi.responses[:succeeded][3].method, "Array is with wrong order") assert_equal("DELETE", multi.responses[:callback][:d].req.method, "Array is with wrong order")
assert_equal("GET", multi.responses[:succeeded][3].response_header['ALLOW'], "Didn't receive the right error message") assert_equal("GET", multi.responses[:callback][:d].response_header['ALLOW'], "Didn't receive the right error message")
assert_not_equal(405, multi.responses[:succeeded][4].response_header.status, "Publisher does accept GET") assert_not_equal(405, multi.responses[:callback][:e].response_header.status, "Publisher does accept GET")
assert_equal("GET", multi.responses[:succeeded][4].method, "Array is with wrong order") assert_equal("GET", multi.responses[:callback][:e].req.method, "Array is with wrong order")
EventMachine.stop EventMachine.stop
} }
......
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