-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
55 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'appraisal' | ||
gem 'pry' | ||
gem 'sidekiq', :path => '..' | ||
gem 'rails', '5.0.0' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,56 @@ | ||
#!/usr/bin/env rake | ||
|
||
require File.expand_path('../config/application', __FILE__) | ||
task :appraise do | ||
failed = false | ||
|
||
task :test do | ||
require 'timeout' | ||
%w(4 5).each do |ver| | ||
%w(production development).each do |env| | ||
output = `bundle exec ruby integration_setup.rb` | ||
if output.strip != '' | ||
puts output | ||
exit(-1) | ||
end | ||
|
||
%(production development).each do |env| | ||
pid = fork do | ||
ENV['RAILS_ENV'] = env | ||
puts eval(File.read("integration_test.rb")) | ||
end | ||
rout, wout = IO.pipe | ||
rerr, werr = IO.pipe | ||
|
||
begin | ||
Timeout.timeout(20) do | ||
Process.wait | ||
command = "bundle exec sidekiq" | ||
pid = Process.spawn({'RAILS_ENV' => env, 'BUNDLE_GEMFILE' => "gemfiles/rails_#{ver}.gemfile"}, | ||
command, :out => wout, :err => werr) | ||
status = nil | ||
begin | ||
require 'timeout' | ||
Timeout.timeout(10) do | ||
Process.wait(pid) | ||
end | ||
rescue Timeout::Error | ||
Process.kill 9, pid | ||
# collect status so it doesn't stick around as zombie process | ||
Process.wait pid | ||
rescue Timeout::Error | ||
puts "Killing #{pid}" | ||
Process.kill('KILL', pid) | ||
end | ||
status = $? | ||
|
||
# close write ends so we could read them | ||
wout.close | ||
werr.close | ||
|
||
stdout = rout.readlines | ||
stderr = rerr.readlines | ||
|
||
# dispose the read ends of the pipes | ||
rout.close | ||
rerr.close | ||
|
||
rc = status.exitstatus | ||
success = stdout.grep(/Success/).size == 3 | ||
if success | ||
puts "#{ver}/#{env} success, #{pid}/#{rc}/#{success}" | ||
else | ||
puts stdout.join | ||
puts stderr.join if stderr.size > 0 | ||
puts "#{ver}/#{env} failed, #{pid}/#{rc}/#{success}" | ||
failed = true | ||
end | ||
end | ||
puts "#{server} child exited, pid = #{pid}" | ||
Process.wait4(pid) | ||
end | ||
end | ||
|
||
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"] | ||
task :default => :appraisal | ||
else | ||
task :default => :test | ||
exit(failed ? -1 : 0) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
class Exiter | ||
def self.run | ||
Sidekiq.logger.warn "Success" | ||
Thread.new do | ||
sleep 0.1 | ||
exit(0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,8 @@ | ||
require 'redis' | ||
|
||
# Push three different types of jobs into Redis | ||
r = Redis.new | ||
r.flushdb | ||
r.lpush "queue:default", '{"class":"ExitWorker","args":[],"retry":true,"queue":"default","jid":"4c51e497bbfea959deee0567","created_at":1479409542.279716,"enqueued_at":1479409542.279781}' | ||
r.lpush "queue:default", '{"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","wrapped":"ExitJob","queue":"default","args":[{"job_class":"ExitJob","job_id":"f8a11fa4-753e-4567-838e-74009ee25cb2","queue_name":"default","priority":null,"arguments":[],"locale":"en"}],"retry":true,"jid":"d020316e37c17bbcd5d360b1","created_at":1479409368.005358,"enqueued_at":1479409368.0056908}' | ||
r.lpush "queue:default", '{"class":"Sidekiq::Extensions::DelayedClass","args":["---\n- !ruby/class \'Exiter\'\n- :run\n- []\n"],"retry":true,"queue":"default","jid":"6006486330d4a27a03593d09","created_at":1479409495.87069,"enqueued_at":1479409495.870754}' | ||
|
||
require_relative '../lib/sidekiq/cli' | ||
|
||
begin | ||
cli = Sidekiq::CLI.instance | ||
cli.parse | ||
cli.run | ||
rescue => e | ||
raise e if $DEBUG | ||
STDERR.puts e.message | ||
STDERR.puts e.backtrace.join("\n") | ||
exit 1 | ||
end |