Commit 800ef8ac authored by Wandenberg's avatar Wandenberg

small tests improvement

parent 3bd35e64
...@@ -3,19 +3,20 @@ source "https://rubygems.org" ...@@ -3,19 +3,20 @@ source "https://rubygems.org"
gem 'rake', '~> 10.0.3' gem 'rake', '~> 10.0.3'
group :test do group :test do
gem 'rspec', '~> 2.12.0' gem 'rspec', '~> 2.14.1'
gem 'em-http-request', '~> 1.0.3' gem 'em-http-request', '~> 1.0.3'
gem 'nginx_test_helper', '~> 0.1.0' gem 'nginx_test_helper', '~> 0.3.0'
gem 'jshintrb', '~> 0.2.1' gem 'jshintrb', '~> 0.2.1'
gem 'therubyracer', '~> 0.11.3' gem 'therubyracer'
gem 'jasmine', '~> 1.3.1' gem 'jasmine', '~> 1.3.1'
gem 'listen', '~> 0.7.2' gem 'listen', '~> 0.7.2'
gem 'rb-inotify', '~> 0.8.8' gem 'rb-inotify', '~> 0.9.4', :require => RUBY_PLATFORM.include?('linux') && 'rb-inotify'
gem 'json', '~> 1.7.6' gem 'rb-fsevent', '~> 0.9', :require => RUBY_PLATFORM.include?('darwin') && 'rb-fsevent'
gem 'json', '~> 1.8.1'
gem 'thin', '~> 1.5.1' gem 'thin', '~> 1.5.1'
gem 'net-http-persistent', '~> 2.9', :require => 'net/http/persistent' gem 'net-http-persistent', '~> 2.9', :require => 'net/http/persistent'
gem 'debugger', '~> 1.3.1' gem 'debugger'
end end
group :docs do group :docs do
......
...@@ -3,77 +3,76 @@ GEM ...@@ -3,77 +3,76 @@ GEM
specs: specs:
Platform (0.4.0) Platform (0.4.0)
RedCloth (4.2.9) RedCloth (4.2.9)
addressable (2.3.2) addressable (2.3.6)
childprocess (0.3.8) childprocess (0.5.3)
ffi (~> 1.0, >= 1.0.11) ffi (~> 1.0, >= 1.0.11)
columnize (0.3.6) columnize (0.8.9)
cookiejar (0.3.0) cookiejar (0.3.2)
daemons (1.1.9) daemons (1.1.9)
debugger (1.3.1) debugger (1.6.6)
columnize (>= 0.3.1) columnize (>= 0.3.1)
debugger-linecache (~> 1.1.1) debugger-linecache (~> 1.2.0)
debugger-ruby_core_source (~> 1.1.8) debugger-ruby_core_source (~> 1.3.2)
debugger-linecache (1.1.2) debugger-linecache (1.2.0)
debugger-ruby_core_source (>= 1.1.1) debugger-ruby_core_source (1.3.2)
debugger-ruby_core_source (1.1.8) diff-lcs (1.2.5)
diff-lcs (1.1.3)
em-http-request (1.0.3) em-http-request (1.0.3)
addressable (>= 2.2.3) addressable (>= 2.2.3)
cookiejar cookiejar
em-socksify em-socksify
eventmachine (>= 1.0.0.beta.4) eventmachine (>= 1.0.0.beta.4)
http_parser.rb (>= 0.5.3) http_parser.rb (>= 0.5.3)
em-socksify (0.2.1) em-socksify (0.3.0)
eventmachine (>= 1.0.0.beta.4) eventmachine (>= 1.0.0.beta.4)
eventmachine (1.0.0) eventmachine (1.0.3)
execjs (1.4.0) execjs (2.0.2)
multi_json (~> 1.0) ffi (1.9.3)
ffi (1.3.1)
github-markup (0.7.5) github-markup (0.7.5)
http_parser.rb (0.5.3) http_parser.rb (0.6.0)
jasmine (1.3.1) jasmine (1.3.2)
jasmine-core (~> 1.3.1) jasmine-core (~> 1.3.1)
rack (~> 1.0) rack (~> 1.0)
rspec (>= 1.3.1) rspec (>= 1.3.1)
selenium-webdriver (>= 0.1.3) selenium-webdriver (>= 0.1.3)
jasmine-core (1.3.1) jasmine-core (1.3.1)
jshintrb (0.2.1) jshintrb (0.2.4)
execjs execjs
multi_json (>= 1.3) multi_json (>= 1.3)
rake rake
json (1.7.6) json (1.8.1)
libv8 (3.11.8.13) libv8 (3.16.14.3)
listen (0.7.2) listen (0.7.3)
multi_json (1.5.0) multi_json (1.9.3)
net-http-persistent (2.9.4) net-http-persistent (2.9.4)
nginx_test_helper (0.1.0) nginx_test_helper (0.3.0)
popen4 popen4
nokogiri (1.5.6) nokogiri (1.5.11)
open4 (1.3.0) open4 (1.3.3)
popen4 (0.1.2) popen4 (0.1.2)
Platform (>= 0.4.0) Platform (>= 0.4.0)
open4 (>= 0.4.0) open4 (>= 0.4.0)
rack (1.5.2) rack (1.5.2)
rake (10.0.3) rake (10.0.4)
rb-inotify (0.8.8) rb-fsevent (0.9.4)
rb-inotify (0.9.4)
ffi (>= 0.5.0) ffi (>= 0.5.0)
ref (1.0.2) ref (1.0.5)
rspec (2.12.0) rspec (2.14.1)
rspec-core (~> 2.12.0) rspec-core (~> 2.14.0)
rspec-expectations (~> 2.12.0) rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.12.0) rspec-mocks (~> 2.14.0)
rspec-core (2.12.2) rspec-core (2.14.8)
rspec-expectations (2.12.1) rspec-expectations (2.14.5)
diff-lcs (~> 1.1.3) diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.12.2) rspec-mocks (2.14.6)
rubyzip (0.9.9) rubyzip (1.1.3)
selenium-webdriver (2.29.0) selenium-webdriver (2.41.0)
childprocess (>= 0.2.5) childprocess (>= 0.5.0)
multi_json (~> 1.0) multi_json (~> 1.0)
rubyzip rubyzip (~> 1.0)
websocket (~> 1.0.4) websocket (~> 1.0.4)
therubyracer (0.11.3) therubyracer (0.12.1)
libv8 (~> 3.11.8.12) libv8 (~> 3.16.14.0)
ref ref
thin (1.5.1) thin (1.5.1)
daemons (>= 1.0.9) daemons (>= 1.0.9)
...@@ -86,18 +85,19 @@ PLATFORMS ...@@ -86,18 +85,19 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
RedCloth (~> 4.2.9) RedCloth (~> 4.2.9)
debugger (~> 1.3.1) debugger
em-http-request (~> 1.0.3) em-http-request (~> 1.0.3)
github-markup (~> 0.7.5) github-markup (~> 0.7.5)
jasmine (~> 1.3.1) jasmine (~> 1.3.1)
jshintrb (~> 0.2.1) jshintrb (~> 0.2.1)
json (~> 1.7.6) json (~> 1.8.1)
listen (~> 0.7.2) listen (~> 0.7.2)
net-http-persistent (~> 2.9) net-http-persistent (~> 2.9)
nginx_test_helper (~> 0.1.0) nginx_test_helper (~> 0.3.0)
nokogiri (~> 1.5.6) nokogiri (~> 1.5.6)
rake (~> 10.0.3) rake (~> 10.0.3)
rb-inotify (~> 0.8.8) rb-fsevent (~> 0.9)
rspec (~> 2.12.0) rb-inotify (~> 0.9.4)
therubyracer (~> 0.11.3) rspec (~> 2.14.1)
therubyracer
thin (~> 1.5.1) thin (~> 1.5.1)
...@@ -57,8 +57,9 @@ begin ...@@ -57,8 +57,9 @@ begin
task :test_server do task :test_server do
require File.expand_path('misc/spec/spec_helper', project_dir) require File.expand_path('misc/spec/spec_helper', project_dir)
include NginxTestHelper include NginxTestHelper
config = NginxTestHelper::Config.new "jasmine", {:configuration_template => File.read(File.expand_path('misc/nginx.conf', project_dir))} template = File.read(File.expand_path('misc/nginx.conf', project_dir))
start_server(config) config = NginxTestHelper::Config.new "jasmine", {:configuration_template => (RUBY_PLATFORM =~ /darwin/) ? template.gsub('epoll', 'kqueue') : template }
abort "Could not start test server" if start_server(config).include?("[emerg]")
end end
rescue LoadError rescue LoadError
......
...@@ -456,7 +456,7 @@ ...@@ -456,7 +456,7 @@
if ((this.pushstream.readyState === PushStream.OPEN) && if ((this.pushstream.readyState === PushStream.OPEN) &&
(this.type === EventSourceWrapper.TYPE) && (this.type === EventSourceWrapper.TYPE) &&
(event.type === 'error') && (event.type === 'error') &&
(this.connection.readyState === EventSource.CONNECTING)) { (this.connection.readyState === window.EventSource.CONNECTING)) {
// EventSource already has a reconnection function using the last-event-id header // EventSource already has a reconnection function using the last-event-id header
return; return;
} }
...@@ -739,7 +739,7 @@ ...@@ -739,7 +739,7 @@
this.opentimer = clearTimer(this.opentimer); this.opentimer = clearTimer(this.opentimer);
if (this.connection) { if (this.connection) {
try { this.connection.abort(); } catch (e) { try { this.connection.abort(); } catch (e) {
try { Ajax.clear(this.connection); } catch (e) { /* ignore error on closing */ } try { Ajax.clear(this.connection); } catch (e1) { /* ignore error on closing */ }
} }
this.connection = null; this.connection = null;
this.xhrSettings.url = null; this.xhrSettings.url = null;
......
...@@ -4,8 +4,9 @@ error_log logs/nginx-main_error.log debug; ...@@ -4,8 +4,9 @@ error_log logs/nginx-main_error.log debug;
# Development Mode # Development Mode
master_process off; master_process off;
daemon off; daemon off;
worker_rlimit_core 500M; worker_rlimit_core 2500M;
working_directory /tmp; working_directory /tmp;
debug_points abort;
worker_processes 2; worker_processes 2;
......
module CustomHttpMatchers
class BeHttpStatus
def initialize(expected)
@expected = expected
@should_has_content = nil
end
def matches?(target)
@target = target
ret = @target.response_header.status.eql?(@expected)
ret = @should_has_content ? has_content? : !has_content? unless (@should_has_content.nil? || !ret)
ret
end
alias == matches?
def without_body
@should_has_content = false
self
end
def with_body
@should_has_content = true
self
end
def failure_message_for_should
"expected that the #{@target.req.method} to #{@target.req.uri} to #{description}"
end
def failure_message_for_should_not
"expected that the #{@target.req.method} to #{@target.req.uri} not to #{description}"
end
def description
returned_values = " but returned with status #{@target.response_header.status} and content_length equals to #{@target.response_header.content_length.to_i}"
about_content = " and #{@should_has_content ? "with body" : "without body"}" unless @should_has_content.nil?
"be returned with status #{@expected}#{about_content}#{returned_values}"
end
private
def has_content?
@target.response_header.content_length.to_i > 0
end
end
def be_http_status(expected)
BeHttpStatus.new(expected)
end
end
...@@ -23,7 +23,7 @@ describe "Measure Memory" do ...@@ -23,7 +23,7 @@ describe "Measure Memory" do
channel = 'ch_test_message_size' channel = 'ch_test_message_size'
body = '1' body = '1'
nginx_run_server(config) do |conf| nginx_run_server(config, :timeout => 30) do |conf|
shared_size = conf.shared_memory_size.to_i * 1024 * 1024 shared_size = conf.shared_memory_size.to_i * 1024 * 1024
post_channel_message = "POST /pub?id=#{channel} HTTP/1.1\r\nHost: localhost\r\nContent-Length: #{body.size}\r\n\r\n#{body}" post_channel_message = "POST /pub?id=#{channel} HTTP/1.1\r\nHost: localhost\r\nContent-Length: #{body.size}\r\n\r\n#{body}"
...@@ -31,7 +31,7 @@ describe "Measure Memory" do ...@@ -31,7 +31,7 @@ describe "Measure Memory" do
while (true) do while (true) do
socket.print(post_channel_message) socket.print(post_channel_message)
resp_headers, resp_body = read_response_on_socket(socket, {:wait_for => "}\r\n"}) resp_headers, resp_body = read_response_on_socket(socket, "}\r\n")
break unless resp_headers.match(/200 OK/) break unless resp_headers.match(/200 OK/)
end end
socket.close socket.close
...@@ -53,7 +53,7 @@ describe "Measure Memory" do ...@@ -53,7 +53,7 @@ describe "Measure Memory" do
it "should check channel size" do it "should check channel size" do
body = '1' body = '1'
nginx_run_server(config, :timeout => 1500) do |conf| nginx_run_server(config, :timeout => 150) do |conf|
shared_size = conf.shared_memory_size.to_i * 1024 * 1024 shared_size = conf.shared_memory_size.to_i * 1024 * 1024
socket = open_socket(nginx_host, nginx_port) socket = open_socket(nginx_host, nginx_port)
...@@ -62,7 +62,7 @@ describe "Measure Memory" do ...@@ -62,7 +62,7 @@ describe "Measure Memory" do
while (true) do while (true) do
post_channel_message = "POST /pub?id=#{channel} HTTP/1.1\r\nHost: localhost\r\nContent-Length: #{body.size}\r\n\r\n#{body}" post_channel_message = "POST /pub?id=#{channel} HTTP/1.1\r\nHost: localhost\r\nContent-Length: #{body.size}\r\n\r\n#{body}"
socket.print(post_channel_message) socket.print(post_channel_message)
resp_headers, resp_body = read_response_on_socket(socket, {:wait_for => "}\r\n"}) resp_headers, resp_body = read_response_on_socket(socket, "}\r\n")
break unless resp_headers.match(/200 OK/) break unless resp_headers.match(/200 OK/)
channel += 1 channel += 1
end end
...@@ -83,7 +83,7 @@ describe "Measure Memory" do ...@@ -83,7 +83,7 @@ describe "Measure Memory" do
end end
it "should check subscriber size" do it "should check subscriber size" do
nginx_run_server(config.merge({:shared_memory_size => "300k", :header_template => "H"})) do |conf| nginx_run_server(config.merge({:shared_memory_size => "128k", :header_template => "H"})) do |conf|
shared_size = conf.shared_memory_size.to_i * 1024 #shm size is in kbytes for this test shared_size = conf.shared_memory_size.to_i * 1024 #shm size is in kbytes for this test
EventMachine.run do EventMachine.run do
...@@ -104,12 +104,11 @@ describe "Measure Memory" do ...@@ -104,12 +104,11 @@ describe "Measure Memory" do
it "should check subscriber system size" do it "should check subscriber system size" do
channel = 'ch_test_subscriber_system_size' channel = 'ch_test_subscriber_system_size'
body = '1'
nginx_run_server(config.merge({:header_template => "H", :master_process => 'off', :daemon => 'off'}), :timeout => 15) do |conf| nginx_run_server(config.merge({:header_template => "H", :master_process => 'off', :daemon => 'off'}), :timeout => 15) do |conf|
#warming up #warming up
EventMachine.run do EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_i.to_s).get :head => headers, :body => body sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_i.to_s).get :head => headers
sub.stream do |chunk| sub.stream do |chunk|
EventMachine.stop EventMachine.stop
end end
...@@ -117,12 +116,12 @@ describe "Measure Memory" do ...@@ -117,12 +116,12 @@ describe "Measure Memory" do
per_subscriber = 0 per_subscriber = 0
EventMachine.run do EventMachine.run do
memory_1 = `ps -eo rss,cmd | grep -E 'ngin[xX] -c #{conf.configuration_filename}'`.split(' ')[0].to_i memory_1 = `ps -o rss= -p #{File.read conf.pid_file}`.split(' ')[0].to_i
subscriber_in_loop_with_limit(channel, headers, body, 1000, 1499) do subscriber_in_loop_with_limit(channel, headers, 1000, 1099) do
sleep(1) sleep(1)
memory_2 = `ps -eo rss,cmd | grep -E 'ngin[xX] -c #{conf.configuration_filename}'`.split(' ')[0].to_i memory_2 = `ps -o rss= -p #{File.read conf.pid_file}`.split(' ')[0].to_i
per_subscriber = ((memory_2 - memory_1).to_f / 500) * 1000 per_subscriber = ((memory_2 - memory_1).to_f / 100) * 1000
EventMachine.stop EventMachine.stop
end end
...@@ -145,15 +144,16 @@ def subscriber_in_loop(channel, headers, &block) ...@@ -145,15 +144,16 @@ def subscriber_in_loop(channel, headers, &block)
end end
end end
def subscriber_in_loop_with_limit(channel, headers, body, start, limit, &block) def subscriber_in_loop_with_limit(channel, headers, start, limit, &block)
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_i.to_s).get :head => headers, :body => body sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_i.to_s).get :head => headers
sub.stream do |chunk| sub.stream do |chunk|
if start == limit if start == limit
block.call block.call
EventMachine.stop EventMachine.stop
end else
subscriber_in_loop_with_limit(channel, headers, body, start + 1, limit) do subscriber_in_loop_with_limit(channel, headers, start + 1, limit) do
yield block yield block
end
end end
end end
sub.callback do sub.callback do
......
...@@ -62,6 +62,8 @@ describe "Send Signals" do ...@@ -62,6 +62,8 @@ describe "Send Signals" do
open_sockets_1 = 0 open_sockets_1 = 0
nginx_run_server(config, :timeout => 60) do |conf| nginx_run_server(config, :timeout => 60) do |conf|
error_log_pre = File.readlines(conf.error_log)
EventMachine.run do EventMachine.run do
# create subscriber # create subscriber
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
...@@ -127,8 +129,9 @@ describe "Send Signals" do ...@@ -127,8 +129,9 @@ describe "Send Signals" do
# send stop signal # send stop signal
`#{ nginx_executable } -c #{ conf.configuration_filename } -s stop > /dev/null 2>&1` `#{ nginx_executable } -c #{ conf.configuration_filename } -s stop > /dev/null 2>&1`
error_log = File.read(conf.error_log)
error_log.should_not include("open socket") error_log_pos = File.readlines(conf.error_log)
(error_log_pos - error_log_pre).join.should_not include("open socket")
end end
end end
end end
......
...@@ -72,11 +72,12 @@ error_log <%= error_log %> debug; ...@@ -72,11 +72,12 @@ error_log <%= error_log %> debug;
master_process <%= master_process %>; master_process <%= master_process %>;
daemon <%= daemon %>; daemon <%= daemon %>;
worker_processes <%= nginx_workers %>; worker_processes <%= nginx_workers %>;
worker_rlimit_core 500M; worker_rlimit_core 2500M;
working_directory <%= File.join(nginx_tests_tmp_dir, "cores", config_id) %>; working_directory <%= File.join(nginx_tests_tmp_dir, "cores", config_id) %>;
debug_points abort;
events { events {
worker_connections 1024; worker_connections 256;
use <%= (RUBY_PLATFORM =~ /darwin/) ? 'kqueue' : 'epoll' %>; use <%= (RUBY_PLATFORM =~ /darwin/) ? 'kqueue' : 'epoll' %>;
} }
......
require 'rubygems' require 'rubygems'
# Set up gems listed in the Gemfile. # Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Bundler.require(:default, :test) if defined?(Bundler) Bundler.require(:default, :test) if defined?(Bundler)
require 'nginx_configuration' require File.expand_path('nginx_configuration', File.dirname(__FILE__))
require 'custom_http_matchers'
Signal.trap("CLD", "IGNORE")
RSpec.configure do |config| RSpec.configure do |config|
config.before(:suite) do
FileUtils.rm_rf Dir[File.join(NginxTestHelper.nginx_tests_tmp_dir, "cores", "**")]
end
config.before(:each) do
core_dir = File.join(File.join(NginxTestHelper.nginx_tests_tmp_dir, "cores", config_id))
FileUtils.mkdir_p core_dir
Dir.chdir core_dir
end
config.after(:each) do config.after(:each) do
NginxTestHelper::Config.delete_config_and_log_files(config_id) if has_passed? NginxTestHelper::Config.delete_config_and_log_files(config_id) if has_passed?
end end
config.after(:suite) do
cores = Dir[File.join(NginxTestHelper.nginx_tests_tmp_dir, "cores", "**", "core")]
raise StandardError.new "\n\nCore dump(s) at:\n#{cores.join("\n")}\n\n" unless cores.empty?
end
config.order = "random" config.order = "random"
config.include(CustomHttpMatchers)
end end
def publish_message_inline(channel, headers, body, &block) def publish_message_inline(channel, headers, body, &block)
...@@ -67,7 +55,7 @@ def publish_messages_until_fill_the_memory(channel, body, &block) ...@@ -67,7 +55,7 @@ def publish_messages_until_fill_the_memory(channel, body, &block)
socket = open_socket(nginx_host, nginx_port) socket = open_socket(nginx_host, nginx_port)
while (true) do while (true) do
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}") 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}")
resp_headers, resp_body = read_response_on_socket(socket, {:wait_for => "}\r\n"}) resp_headers, resp_body = read_response_on_socket(socket, "}\r\n")
break unless resp_headers.match(/200 OK/) break unless resp_headers.match(/200 OK/)
i += 1 i += 1
end end
......
...@@ -66,7 +66,7 @@ describe "Subscriber Properties" do ...@@ -66,7 +66,7 @@ describe "Subscriber Properties" do
start = Time.now start = Time.now
nginx_run_server(config.merge(:subscriber_connection_ttl => "10s"), :timeout => 30) do |conf| nginx_run_server(config.merge(:subscriber_connection_ttl => "10s"), :timeout => 30) do |conf|
EventMachine.run do EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s, :inactivity_timeout => 15).get :head => headers
sub.callback do sub.callback do
stop = Time.now stop = Time.now
time_diff_sec(start, stop).should be_in_the_interval(10, 10.5) time_diff_sec(start, stop).should be_in_the_interval(10, 10.5)
......
# encoding: ascii
require 'spec_helper' require 'spec_helper'
describe "Receive old messages" do describe "Receive old messages" do
...@@ -6,7 +7,8 @@ describe "Receive old messages" do ...@@ -6,7 +7,8 @@ describe "Receive old messages" do
:header_template => nil, :header_template => nil,
:footer_template => nil, :footer_template => nil,
:message_template => '{\"channel\":\"~channel~\", \"id\":\"~id~\", \"message\":\"~text~\"}\r\n', :message_template => '{\"channel\":\"~channel~\", \"id\":\"~id~\", \"message\":\"~text~\"}\r\n',
:subscriber_mode => subscriber_mode :subscriber_mode => subscriber_mode,
:ping_message_interval => '1s'
} }
end end
......
...@@ -505,7 +505,7 @@ describe "Subscriber WebSocket" do ...@@ -505,7 +505,7 @@ describe "Subscriber WebSocket" do
nginx_run_server(config.merge(:ping_message_interval => "1s"), :timeout => 10) do |conf| nginx_run_server(config.merge(:ping_message_interval => "1s"), :timeout => 10) do |conf|
File.open(conf.error_log, "a").truncate(0) error_log_pre = File.readlines(conf.error_log)
EventMachine.run do EventMachine.run do
publish_message_inline(channel, {}, "body") publish_message_inline(channel, {}, "body")
...@@ -538,8 +538,8 @@ describe "Subscriber WebSocket" do ...@@ -538,8 +538,8 @@ describe "Subscriber WebSocket" do
resp_2["channels"].to_i.should eql(1) resp_2["channels"].to_i.should eql(1)
resp_2["subscribers"].to_i.should eql(0) resp_2["subscribers"].to_i.should eql(0)
error_log = File.read(conf.error_log) error_log_pos = File.readlines(conf.error_log)
error_log.should_not include("client sent invalid") (error_log_pos - error_log_pre).join.should_not include("client sent invalid")
EventMachine.stop EventMachine.stop
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