Commit ad816423 authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

refactor sending message in small ranges

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