Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed tests (rspec 2.9.0 bug and app_name in logs)

 * updated rspec-expectations for bug exposed by aruba
 * updated Resque::Pool::CLI to allow passing in an appname
 * expected "aruba" appname in logfiles or output
 * send Resque::Pool::CLI.log through Resque::Pool.log instead
  • Loading branch information...
commit 92b48f39d29c96ace71b823df8c5ea2fdcd88901 1 parent 0bdb9b6
@nevans authored
View
2  Gemfile.lock
@@ -54,7 +54,7 @@ GEM
rspec-expectations (~> 2.9.0)
rspec-mocks (~> 2.9.0)
rspec-core (2.9.0)
- rspec-expectations (2.9.0)
+ rspec-expectations (2.9.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.9.0)
sinatra (1.3.2)
View
12 features/step_definitions/resque-pool_steps.rb
@@ -9,7 +9,7 @@ def process_should_not_exist(pid)
def grab_worker_pids(count, str)
puts "TODO: check output_or_log for #{count} worker started messages"
pid_regex = (1..count).map { '(\d+)' }.join ', '
- full_regex = /resque-pool-manager\[\d+\]: Pool contains worker PIDs: \[#{pid_regex}\]/m
+ full_regex = /resque-pool-manager\[aruba\]\[\d+\]: Pool contains worker PIDs: \[#{pid_regex}\]/m
str.should =~ full_regex
@worker_pids = full_regex.match(str).captures.map {|pid| pid.to_i }
end
@@ -67,7 +67,7 @@ def children_of(ppid)
when "QUIT"
keep_trying do
step "the #{output_logfiles} should contain the following lines (with interpolated $PID):", <<-EOF
-resque-pool-manager[$PID]: QUIT: graceful shutdown, waiting for children
+resque-pool-manager[aruba][$PID]: QUIT: graceful shutdown, waiting for children
EOF
end
else
@@ -102,15 +102,15 @@ def children_of(ppid)
Then /^the pool manager should (report|log) that it has started up$/ do |report_log|
keep_trying do
step "the #{output_or_logfiles_string(report_log)} should contain the following lines (with interpolated $PID):", <<-EOF
-resque-pool-manager[$PID]: Resque Pool running in test environment
-resque-pool-manager[$PID]: started manager
+resque-pool-manager[aruba][$PID]: Resque Pool running in test environment
+resque-pool-manager[aruba][$PID]: started manager
EOF
end
end
Then /^the pool manager should (report|log) that the pool is empty$/ do |report_log|
step "the #{output_or_logfiles_string(report_log)} should contain the following lines (with interpolated $PID):", <<-EOF
-resque-pool-manager[$PID]: Pool is empty
+resque-pool-manager[aruba][$PID]: Pool is empty
EOF
end
@@ -141,7 +141,7 @@ def children_of(ppid)
Then /^the pool manager should (report|log) that it is finished$/ do |report_log|
step "the #{output_or_logfiles_string(report_log)} should contain the following lines (with interpolated $PID):", <<-EOF
-resque-pool-manager[$PID]: manager finished
+resque-pool-manager[aruba][$PID]: manager finished
EOF
end
View
1  lib/resque/pool.rb
@@ -15,6 +15,7 @@ class Pool
CHUNK_SIZE = (16 * 1024)
include Logging
+ extend Logging
attr_reader :config
attr_reader :workers
View
5 lib/resque/pool/cli.rb
@@ -5,7 +5,6 @@
module Resque
class Pool
module CLI
- extend Logging
extend self
def run
@@ -31,6 +30,7 @@ def parse_options
where [options] are:
EOS
opt :config, "Alternate path to config file", :type => String, :short => "-c"
+ opt :appname, "Alternate appname", :type => String, :short => "-a"
opt :daemon, "Run as a background daemon", :default => false, :short => "-d"
opt :stdout, "Redirect stdout to logfile", :type => String, :short => '-o'
opt :stderr, "Redirect stderr to logfile", :type => String, :short => '-e'
@@ -100,8 +100,9 @@ def redirect(opts)
end
def setup_environment(opts)
+ Resque::Pool.app_name = opts[:appname] if opts[:appname]
ENV["RACK_ENV"] = ENV["RAILS_ENV"] = ENV["RESQUE_ENV"] = opts[:environment] if opts[:environment]
- log "Resque Pool running in #{ENV["RAILS_ENV"] || "development"} environment"
+ Resque::Pool.log "Resque Pool running in #{ENV["RAILS_ENV"] || "development"} environment"
ENV["RESQUE_POOL_CONFIG"] = opts[:config] if opts[:config]
end
View
3  lib/resque/pool/logging.rb
@@ -55,7 +55,8 @@ def log_worker(message)
# Include optional app name in procline
def app
- app_name = self.class.respond_to?(:app_name) ? self.class.app_name : nil
+ app_name = self.respond_to?(:app_name) && self.app_name
+ app_name ||= self.class.respond_to?(:app_name) && self.class.app_name
app_name ? "[#{app_name}]" : ""
end
Please sign in to comment.
Something went wrong with that request. Please try again.