Commit ad816423 authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

refactor sending message in small ranges

parent 4e0d8669
...@@ -36,8 +36,10 @@ class TestPublishMessages < Test::Unit::TestCase ...@@ -36,8 +36,10 @@ class TestPublishMessages < Test::Unit::TestCase
headers = {'accept' => 'text/html'} headers = {'accept' => 'text/html'}
channel = 'ch_test_publish_messages_with_different_bytes' channel = 'ch_test_publish_messages_with_different_bytes'
ranges = [1..63, 64..127, 128..191, 192..255]
ranges.each do |range|
bytes = [] bytes = []
1.upto(127) do |i| range.each do |i|
1.upto(255) do |j| 1.upto(255) do |j|
bytes << "%s%s" % [i.chr, j.chr] bytes << "%s%s" % [i.chr, j.chr]
end end
...@@ -59,31 +61,7 @@ class TestPublishMessages < Test::Unit::TestCase ...@@ -59,31 +61,7 @@ class TestPublishMessages < Test::Unit::TestCase
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30 pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30
add_test_timeout add_test_timeout
} }
bytes = []
128.upto(255) do |i|
1.upto(255) do |j|
bytes << "%s%s" % [i.chr, j.chr]
end
end
body = bytes.join('')
response = ''
EventMachine.run {
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub.stream { | chunk |
response += chunk
if response.include?(body)
assert_equal(body + "\r\n", response, "The published message was not received correctly")
EventMachine.stop
end end
}
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body, :timeout => 30
add_test_timeout(5)
}
end end
def config_test_publish_many_messages_in_the_same_channel def config_test_publish_many_messages_in_the_same_channel
......
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