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