Commit cbfa6b69 authored by Wandenberg's avatar Wandenberg

make cleanup test more stable and faster using a socket to publish messages

parent c5abed57
This diff is collapsed.
...@@ -61,14 +61,18 @@ def create_channel_by_subscribe(channel, headers, timeout=60, &block) ...@@ -61,14 +61,18 @@ def create_channel_by_subscribe(channel, headers, timeout=60, &block)
end end
end end
def publish_message_inline_with_callbacks(channel, headers, body, callbacks = {}) def publish_messages_until_fill_the_memory(channel, body, &block)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body i = 0
pub.callback do resp_headers, resp_body = nil
if pub.response_header.status == 200 socket = open_socket(nginx_host, nginx_port)
callbacks[:success].call(pub.response_header.status, pub.response) unless callbacks[:success].nil? while (true) do
else socket.print("POST /pub?id=#{channel.to_s % (i)} HTTP/1.1\r\nHost: localhost\r\nContent-Length: #{body.size}\r\n\r\n#{body}")
callbacks[:error].call(pub.response_header.status, pub.response) unless callbacks[:error].nil? resp_headers, resp_body = read_response_on_socket(socket, {:wait_for => "}\r\n"})
end break unless resp_headers.match(/200 OK/)
i += 1
end end
pub socket.close
status = resp_headers.match(/HTTP[^ ]* ([^ ]*)/)[1]
block.call(status, resp_body) unless block.nil?
end end
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