Commit f517ae57 authored by Wandenberg's avatar Wandenberg

tests refactor to be possible execute them with multiple workers on nginx

parent a48ca949
require 'spec_helper'
describe "Cleanup Memory" do
workers = 1
old_cld_trap = nil
before do
workers = ENV['NGINX_WORKERS']
ENV['NGINX_WORKERS'] = '1'
old_cld_trap = Signal.trap("CLD", "IGNORE")
end
after do
ENV['NGINX_WORKERS'] = workers
Signal.trap("CLD", old_cld_trap)
end
......@@ -576,13 +572,13 @@ describe "Cleanup Memory" do
pub.callback do
pub.should be_http_status(200).with_body
resp_1 = JSON.parse(pub.response)
resp_1["by_worker"].count.should eql(1)
pid = resp_1["by_worker"][0]['pid'].to_i
resp_1["by_worker"].count.should eql(conf.workers)
pids = resp_1["by_worker"].map{ |info| info['pid'].to_i }
# send kill signal
`kill -9 #{ pid } > /dev/null 2>&1`
pids.each{ |pid| `kill -9 #{ pid } > /dev/null 2>&1` }
while `ps -p #{ pid } > /dev/null 2>&1; echo $?`.to_i == 0
while pids.all?{ |pid| `ps -p #{ pid } > /dev/null 2>&1; echo $?`.to_i == 0 }
sleep(0.1)
end
......@@ -600,13 +596,13 @@ describe "Cleanup Memory" do
pub.callback do
pub.should be_http_status(200).with_body
resp_1 = JSON.parse(pub.response)
resp_1["by_worker"].count.should eql(1)
pid = resp_1["by_worker"][0]['pid'].to_i
resp_1["by_worker"].count.should eql(conf.workers)
pids = resp_1["by_worker"].map{ |info| info['pid'].to_i }
# send reload signal
`#{ nginx_executable } -c #{ conf.configuration_filename } -s reload > /dev/null 2>&1`
pids.each{ |pid| `#{ nginx_executable } -c #{ conf.configuration_filename } -s reload > /dev/null 2>&1` }
while `ps -p #{ pid } > /dev/null 2>&1; echo $?`.to_i == 0
while pids.all?{ |pid| `ps -p #{ pid } > /dev/null 2>&1; echo $?`.to_i == 0 }
sleep(0.1)
end
......
require 'spec_helper'
describe "Send Signals" do
workers = 1
old_cld_trap = nil
before do
workers = ENV['NGINX_WORKERS']
ENV['NGINX_WORKERS'] = '1'
old_cld_trap = Signal.trap("CLD", "IGNORE")
end
after do
ENV['NGINX_WORKERS'] = workers
Signal.trap("CLD", old_cld_trap)
end
......@@ -18,6 +14,7 @@ describe "Send Signals" do
{
:master_process => 'on',
:daemon => 'on',
:workers => 1,
:header_template => 'HEADER',
:footer_template => 'FOOTER',
:message_ttl => '60s',
......@@ -227,7 +224,7 @@ describe "Send Signals" do
nginx_run_server(config, :timeout => 10) do |conf|
EventMachine.run do
publish_message_inline(channel, {}, body)
publish_message(channel, {}, body)
# check statistics
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_1.callback do
......
......@@ -4,6 +4,7 @@ module NginxConfiguration
:disable_start_stop_server => false,
:master_process => 'on',
:daemon => 'on',
:workers => 2,
:gzip => 'off',
......@@ -67,12 +68,12 @@ module NginxConfiguration
def self.template_configuration
%(
pid <%= pid_file %>;
error_log <%= error_log %> debug;
error_log <%= error_log %> info;
# Development Mode
master_process <%= master_process %>;
daemon <%= daemon %>;
worker_processes <%= nginx_workers %>;
worker_processes <%= workers %>;
worker_rlimit_core 2500M;
working_directory <%= File.join(nginx_tests_tmp_dir, "cores", config_id) %>;
debug_points abort;
......
......@@ -450,20 +450,16 @@ describe "Publisher Properties" do
sub_2.stream do |chunk|
resp_2 += chunk
end
sub_2.callback do
EM.add_timer(2) do
resp_1.should eql("<script>p(1,'channel_id_inside_if_block','published message');</script>")
resp_2.should eql("<script>p(1,'test_channel_id_inside_if_block','published message');</script>")
EventMachine.stop
end
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub2?id=' + channel.to_s).post :head => headers, :body => body
pub_1.callback do
pub_1.should be_http_status(200)
end
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub2?id=' + channel.to_s + '&test=1').post :head => headers, :body => body
pub_2.callback do
pub_2.should be_http_status(200)
EM.add_timer(0.5) do
post_to('/pub2?id=' + channel.to_s, headers, body)
post_to('/pub2?id=' + channel.to_s + '&test=1', headers, body)
end
end
end
......@@ -538,7 +534,7 @@ describe "Publisher Properties" do
nginx_run_server(config.merge(:gzip => "on"), :timeout => 5) do |conf|
EventMachine.run do
#create channel
publish_message_inline(channel, {}, body)
publish_message(channel, {}, body)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel).get :head => headers.merge({'accept' => 'application/json', 'accept-encoding' => 'gzip, compressed'}), :decoding => false
pub.stream do |chunk|
......@@ -610,7 +606,9 @@ describe "Publisher Properties" do
EM.add_periodic_timer(0.5) { EventMachine.stop if messages >= 3 }
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s + '_1/' + channel.to_s + '_2/' + channel.to_s + '_3').post :head => headers, :body => body
EM.add_timer(0.5) do
post_to('/pub?id=' + channel.to_s + '_1/' + channel.to_s + '_2/' + channel.to_s + '_3', headers, body)
end
end
end
end
......@@ -945,24 +943,28 @@ describe "Publisher Properties" do
resp_2.should eql("{\"id\":\"-2\", \"channel\":\"test_delete_channels_whith_subscribers_2\", \"text\":\"Channel deleted\"}FOOTER")
end
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do
stats.should be_http_status(200).with_body
response = JSON.parse(stats.response)
response["subscribers"].to_i.should eql(2)
response["channels"].to_i.should eql(2)
EM.add_timer(0.5) do
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do
stats.should be_http_status(200).with_body
response = JSON.parse(stats.response)
response["subscribers"].to_i.should eql(2)
response["channels"].to_i.should eql(2)
end
end
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1.to_s).delete :head => headers
pub_1.callback do
pub_1.should be_http_status(200).without_body
pub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
end
EM.add_timer(1.5) do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1.to_s).delete :head => headers
pub_1.callback do
pub_1.should be_http_status(200).without_body
pub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
end
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2.to_s).delete :head => headers
pub_2.callback do
pub_2.should be_http_status(200).without_body
pub_2.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2.to_s).delete :head => headers
pub_2.callback do
pub_2.should be_http_status(200).without_body
pub_2.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
end
end
EM.add_timer(5) do
......
......@@ -22,7 +22,7 @@ describe "Publisher Publishing Messages" do
EventMachine.stop
end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
publish_message_inline(channel, headers, body)
end
end
end
......@@ -39,7 +39,9 @@ describe "Publisher Publishing Messages" do
EventMachine.stop
end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).put :head => headers, :body => body, :timeout => 30
EM.add_timer(0.5) do
EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).put :head => headers, :body => body, :timeout => 30
end
end
end
end
......@@ -71,7 +73,7 @@ describe "Publisher Publishing Messages" do
EventMachine.stop
end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
publish_message_inline(channel, headers, body)
end
end
end
......@@ -207,7 +209,7 @@ describe "Publisher Publishing Messages" do
EventMachine.stop
end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-Id' => event_id), :body => body
publish_message_inline(channel, headers.merge('Event-Id' => event_id), body)
end
end
end
......@@ -230,7 +232,7 @@ describe "Publisher Publishing Messages" do
EventMachine.stop
end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-type' => event_type), :body => body
publish_message_inline(channel, headers.merge('Event-type' => event_type), body)
end
end
end
......@@ -253,7 +255,7 @@ describe "Publisher Publishing Messages" do
EventMachine.stop
end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-Ids' => event_id), :body => body
publish_message_inline(channel, headers.merge('Event-Ids' => event_id), body)
end
EventMachine.run do
......@@ -267,7 +269,7 @@ describe "Publisher Publishing Messages" do
EventMachine.stop
end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-I' => event_id), :body => body
publish_message_inline(channel, headers.merge('Event-I' => event_id), body)
end
end
end
......@@ -294,7 +296,7 @@ describe "Publisher Publishing Messages" do
end
now = Time.now
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
publish_message_inline(channel, headers, body)
end
end
end
......@@ -323,8 +325,8 @@ describe "Publisher Publishing Messages" do
EventMachine.stop
end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
publish_message_inline(channel, headers, body)
publish_message_inline(channel, headers, body)
end
end
end
......
......@@ -19,23 +19,34 @@ RSpec.configure do |config|
config.order = "random"
end
def publish_message_inline(channel, headers, body, &block)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub.callback do
pub.should be_http_status(200)
block.call unless block.nil?
def publish_message_inline(channel, headers, body, delay=0.01, &block)
EM.add_timer(delay) do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub.callback do
pub.should be_http_status(200)
block.call(pub) unless block.nil?
end
end
pub
end
def publish_message(channel, headers, body)
EventMachine.run do
pub = publish_message_inline(channel, headers, body) do
response = JSON.parse(pub.response)
response["channel"].to_s.should eql(channel)
EventMachine.stop
end
http = Net::HTTP.new(nginx_host, nginx_port)
req = Net::HTTP::Post.new("/pub?id=#{channel}", headers)
req.body = body
res = http.request(req)
content = res.body
if res.get_fields("content-encoding").to_a.include?("gzip")
content = Zlib::GzipReader.new(StringIO.new(content)).read
end
response = JSON.parse(content)
response["channel"].to_s.should eql(channel)
end
def post_to(path, headers, body)
http = Net::HTTP.new(nginx_host, nginx_port)
req = Net::HTTP::Post.new(path, headers)
req.body = body
http.request(req)
end
def create_channel_by_subscribe(channel, headers, timeout=60, &block)
......
......@@ -43,10 +43,10 @@ describe "Subscriber Properties" do
nginx_run_server(config) do |conf|
EventMachine.run do
publish_message_inline(channel, {'Event-Id' => 'event 1'}, 'msg 1')
publish_message_inline(channel, {'Event-Id' => 'event 2'}, 'msg 2')
publish_message_inline(channel, {}, 'msg 3')
publish_message_inline(channel, {'Event-Id' => 'event 3'}, 'msg 4')
publish_message(channel, {'Event-Id' => 'event 1'}, 'msg 1')
publish_message(channel, {'Event-Id' => 'event 2'}, 'msg 2')
publish_message(channel, {}, 'msg 3')
publish_message(channel, {'Event-Id' => 'event 3'}, 'msg 4')
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge({'Last-Event-Id' => 'event 2'})
sub.stream do |chunk|
......@@ -189,8 +189,10 @@ describe "Subscriber Properties" do
end
end
publish_message_inline(channel_1.to_s, headers, body)
publish_message_inline(channel_2.to_s, headers, body)
EM.add_timer(0.5) do
publish_message(channel_1.to_s, headers, body)
publish_message(channel_2.to_s, headers, body)
end
end
end
end
......@@ -216,10 +218,12 @@ describe "Subscriber Properties" do
EventMachine.stop
end
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
EM.add_timer(0.5) do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
end
end
end
end
......@@ -252,8 +256,8 @@ describe "Subscriber Properties" do
nginx_run_server(config) do |conf|
EventMachine.run do
publish_message_inline(channel, {'Event-Id' => 'event_id'}, body)
publish_message_inline(channel, {}, body + "1")
publish_message(channel, {'Event-Id' => 'event_id'}, body)
publish_message(channel, {}, body + "1")
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b2' + '?callback=' + callback_function_name).get :head => headers
sub_1.callback do
......
......@@ -49,7 +49,7 @@ describe "Subscriber Properties" do
nginx_run_server(config) do |conf|
EventMachine.run do
publish_message_inline(channel, {}, body)
publish_message(channel, {}, body)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge({'If-Modified-Since' => Time.at(0).utc.strftime("%a, %d %b %Y %T %Z")})
sub_1.callback do
......@@ -71,7 +71,7 @@ describe "Subscriber Properties" do
nginx_run_server(config) do |conf|
EventMachine.run do
publish_message_inline(channel, {}, body)
publish_message(channel, {}, body)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?callback=' + callback_function_name).get :head => headers.merge({'If-Modified-Since' => Time.at(0).utc.strftime("%a, %d %b %Y %T %Z")})
sub_1.callback do
sub_1.response.should eql("#{callback_function_name}([#{body}]);")
......@@ -89,8 +89,8 @@ describe "Subscriber Properties" do
nginx_run_server(config) do |conf|
EventMachine.run do
publish_message_inline(channel, {'Event-Id' => 'event_id'}, body)
publish_message_inline(channel, {}, body + "1")
publish_message(channel, {'Event-Id' => 'event_id'}, body)
publish_message(channel, {}, body + "1")
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b2' + '?callback=' + callback_function_name).get :head => headers
sub_1.callback do
......@@ -120,7 +120,7 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge({:content_type => "anything/value"})) do |conf|
EventMachine.run do
publish_message_inline(channel, {}, body)
publish_message(channel, {}, body)
sent_headers = headers.merge({'accept' => 'otherknown/value'})
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?callback=' + callback_function_name).get :head => sent_headers
sub_1.callback do
......@@ -138,7 +138,7 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge({:gzip => "on"})) do |conf|
EventMachine.run do
publish_message_inline(channel, {}, body)
publish_message(channel, {}, body)
sent_headers = headers.merge({'accept-encoding' => 'gzip, compressed', 'If-Modified-Since' => Time.at(0).utc.strftime("%a, %d %b %Y %T %Z")})
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => sent_headers, :decoding => false
......
......@@ -365,12 +365,14 @@ describe "Subscriber Properties" do
end
end
publish_message_inline(channel_1, headers, body + channel_1.to_s)
publish_message_inline(channel_2, headers, body + channel_2.to_s)
publish_message_inline(channel_3, headers, body + channel_3.to_s)
publish_message_inline(channel_4, headers, body + channel_4.to_s)
publish_message_inline(channel_5, headers, body + channel_5.to_s)
publish_message_inline(channel_6, headers, body + channel_6.to_s)
EM.add_timer(0.5) do
publish_message(channel_1, headers, body + channel_1.to_s)
publish_message(channel_2, headers, body + channel_2.to_s)
publish_message(channel_3, headers, body + channel_3.to_s)
publish_message(channel_4, headers, body + channel_4.to_s)
publish_message(channel_5, headers, body + channel_5.to_s)
publish_message(channel_6, headers, body + channel_6.to_s)
end
end
end
end
......@@ -578,19 +580,22 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:max_subscribers_per_channel => 3, :subscriber_connection_ttl => "3s")) do |conf|
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_4 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_4.callback do
sub_4.should be_http_status(403).without_body
sub_4.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribers limit per channel has been exceeded.")
end
sub_5 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + other_channel.to_s).get :head => headers
sub_5.callback do
sub_5.should be_http_status(200)
EventMachine.stop
EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get(:head => headers).stream do
EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get(:head => headers).stream do
EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get(:head => headers).stream do
sub_4 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_4.callback do
sub_4.should be_http_status(403).without_body
sub_4.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribers limit per channel has been exceeded.")
sub_5 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + other_channel.to_s).get :head => headers
sub_5.callback do
sub_5.should be_http_status(200)
EventMachine.stop
end
end
end
end
end
end
end
......@@ -602,10 +607,10 @@ describe "Subscriber Properties" do
nginx_run_server(config.merge(:ping_message_interval => nil, :header_template => nil, :footer_template => nil, :message_template => nil)) do |conf|
EventMachine.run do
publish_message_inline(channel, {'accept' => 'text/html'}, 'msg 1')
publish_message_inline(channel, {'accept' => 'text/html'}, 'msg 2')
publish_message_inline(channel, {'accept' => 'text/html'}, 'msg 3')
publish_message_inline(channel, {'accept' => 'text/html'}, 'msg 4')
publish_message(channel, {'accept' => 'text/html'}, 'msg 1')
publish_message(channel, {'accept' => 'text/html'}, 'msg 2')
publish_message(channel, {'accept' => 'text/html'}, 'msg 3')
publish_message(channel, {'accept' => 'text/html'}, 'msg 4')
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b3').get
sub.stream do |chunk|
......@@ -904,15 +909,8 @@ describe "Subscriber Properties" do
EventMachine.stop
end
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub_1.callback do
pub_1.should be_http_status(200)
end
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + 'test_' + channel.to_s).post :head => headers, :body => body
pub_2.callback do
pub_2.should be_http_status(200)
end
publish_message_inline(channel, {}, body)
publish_message_inline('test_' + channel, {}, body)
end
end
end
......@@ -1024,7 +1022,7 @@ describe "Subscriber Properties" do
sub_2.stream do |chunk|
actual_response_2 += chunk
end
sub_2.callback do
EM.add_timer(1.5) do
sub_1.should be_http_status(200)
sub_2.should be_http_status(200)
......@@ -1033,8 +1031,10 @@ describe "Subscriber Properties" do
EventMachine.stop
end
EventMachine::HttpRequest.new("http://#{nginx_host}:#{nginx_port.to_i}/pub/?id=" + channel.to_s).post :body => "#{body}_1"
EventMachine::HttpRequest.new("http://#{nginx_host}:#{nginx_port.to_i + 1}/pub/?id=" + channel.to_s).post :body => "#{body}_2"
EM.add_timer(0.5) do
EventMachine::HttpRequest.new("http://#{nginx_host}:#{nginx_port.to_i}/pub/?id=" + channel.to_s).post :body => "#{body}_1"
EventMachine::HttpRequest.new("http://#{nginx_host}:#{nginx_port.to_i + 1}/pub/?id=" + channel.to_s).post :body => "#{body}_2"
end
end
end
end
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe "Subscriber WebSocket" do
let(:config) do
{
:workers => 1,
:header_template => nil,
:message_template => nil,
:footer_template => nil,
......@@ -165,7 +166,7 @@ describe "Subscriber WebSocket" do
nginx_run_server(config.merge(:header_template => "HEADER_TEMPLATE")) do |conf|
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}\r\n")
sleep(0.5)
sleep(1)
headers, body = read_response_on_socket(socket, 'TEMPLATE')
body.should eql("\201\017HEADER_TEMPLATE")
socket.close
......@@ -226,7 +227,7 @@ describe "Subscriber WebSocket" do
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket)
#wait for disconnect
sleep(1.5)
sleep(1)
body, dummy = read_response_on_socket(socket, "\210\000")
body.should eql("\201\017FOOTER_TEMPLATE\210\000")
socket.close
......@@ -447,6 +448,8 @@ describe "Subscriber WebSocket" do
headers, body = read_response_on_socket(socket)
socket.print(frame)
sleep(1)
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :timeout => 30
pub.callback do
......@@ -475,6 +478,8 @@ describe "Subscriber WebSocket" do
headers, body = read_response_on_socket(socket)
socket.print(frame)
sleep(1)
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :timeout => 30
pub.callback do
......@@ -562,7 +567,7 @@ describe "Subscriber WebSocket" do
socket.print("WRITE SOMETHING UNKNOWN\r\n")
sleep 1
sleep(1)
error_log = File.read(conf.error_log)
error_log.should_not include("client sent invalid")
......@@ -601,7 +606,7 @@ describe "Subscriber WebSocket" do
socket.print("WRITE SOMETHING UNKNOWN\r\n")
sleep 3
sleep(1)
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get
pub_2.callback do
......
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