mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
initial work on appraisal and rails integration testing, #3241
This commit is contained in:
parent
53b3b82cc7
commit
7737da1744
12 changed files with 387 additions and 8 deletions
7
myapp/Appraisals
Normal file
7
myapp/Appraisals
Normal file
|
@ -0,0 +1,7 @@
|
|||
appraise "rails-4" do
|
||||
gem "rails", "4.2.7"
|
||||
end
|
||||
|
||||
appraise "rails-5" do
|
||||
gem "rails", "5.0.0"
|
||||
end
|
|
@ -1,5 +1,6 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'appraisal'
|
||||
gem 'pry'
|
||||
gem 'sidekiq', :path => '..'
|
||||
gem 'rails', '5.0.0'
|
||||
|
|
|
@ -1,16 +1,32 @@
|
|||
#!/usr/bin/env rake
|
||||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||
|
||||
require File.expand_path('../config/application', __FILE__)
|
||||
|
||||
Myapp::Application.load_tasks
|
||||
task :test do
|
||||
require 'timeout'
|
||||
|
||||
task :load_jobs => :environment do
|
||||
require 'sidekiq/api'
|
||||
Sidekiq::Queue.new.clear
|
||||
%(production development).each do |env|
|
||||
pid = fork do
|
||||
ENV['RAILS_ENV'] = env
|
||||
puts eval(File.read("integration_test.rb"))
|
||||
end
|
||||
|
||||
50_000.times do |x|
|
||||
EmptyWorker.perform_async
|
||||
begin
|
||||
Timeout.timeout(20) do
|
||||
Process.wait
|
||||
end
|
||||
rescue Timeout::Error
|
||||
Process.kill 9, pid
|
||||
# collect status so it doesn't stick around as zombie process
|
||||
Process.wait pid
|
||||
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
|
||||
end
|
||||
|
|
2
myapp/app/jobs/application_job.rb
Normal file
2
myapp/app/jobs/application_job.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
class ApplicationJob < ActiveJob::Base
|
||||
end
|
10
myapp/app/jobs/exit_job.rb
Normal file
10
myapp/app/jobs/exit_job.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class ExitJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(*args)
|
||||
Thread.new do
|
||||
sleep 0.1
|
||||
exit(0)
|
||||
end
|
||||
end
|
||||
end
|
8
myapp/app/models/exiter.rb
Normal file
8
myapp/app/models/exiter.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class Exiter
|
||||
def self.run
|
||||
Thread.new do
|
||||
sleep 0.1
|
||||
exit(0)
|
||||
end
|
||||
end
|
||||
end
|
11
myapp/app/workers/exit_worker.rb
Normal file
11
myapp/app/workers/exit_worker.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class ExitWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform
|
||||
puts Rails.version
|
||||
Thread.new do
|
||||
sleep 0.1
|
||||
exit(0)
|
||||
end
|
||||
end
|
||||
end
|
13
myapp/gemfiles/rails_4.gemfile
Normal file
13
myapp/gemfiles/rails_4.gemfile
Normal file
|
@ -0,0 +1,13 @@
|
|||
# This file was generated by Appraisal
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "appraisal"
|
||||
gem "pry"
|
||||
gem "sidekiq", :path => "../.."
|
||||
gem "rails", "4.2.7"
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3"
|
||||
gem "redis-namespace"
|
||||
end
|
137
myapp/gemfiles/rails_4.gemfile.lock
Normal file
137
myapp/gemfiles/rails_4.gemfile.lock
Normal file
|
@ -0,0 +1,137 @@
|
|||
PATH
|
||||
remote: ../..
|
||||
specs:
|
||||
sidekiq (4.2.6)
|
||||
concurrent-ruby (~> 1.0)
|
||||
connection_pool (~> 2.2, >= 2.2.0)
|
||||
rack-protection (>= 1.5.0)
|
||||
redis (~> 3.2, >= 3.2.1)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (4.2.7)
|
||||
actionpack (= 4.2.7)
|
||||
actionview (= 4.2.7)
|
||||
activejob (= 4.2.7)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
actionpack (4.2.7)
|
||||
actionview (= 4.2.7)
|
||||
activesupport (= 4.2.7)
|
||||
rack (~> 1.6)
|
||||
rack-test (~> 0.6.2)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (4.2.7)
|
||||
activesupport (= 4.2.7)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
activejob (4.2.7)
|
||||
activesupport (= 4.2.7)
|
||||
globalid (>= 0.3.0)
|
||||
activemodel (4.2.7)
|
||||
activesupport (= 4.2.7)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.2.7)
|
||||
activemodel (= 4.2.7)
|
||||
activesupport (= 4.2.7)
|
||||
arel (~> 6.0)
|
||||
activesupport (4.2.7)
|
||||
i18n (~> 0.7)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
appraisal (2.1.0)
|
||||
bundler
|
||||
rake
|
||||
thor (>= 0.14.0)
|
||||
arel (6.0.3)
|
||||
builder (3.2.2)
|
||||
coderay (1.1.1)
|
||||
concurrent-ruby (1.0.2)
|
||||
connection_pool (2.2.0)
|
||||
erubis (2.7.0)
|
||||
globalid (0.3.7)
|
||||
activesupport (>= 4.1.0)
|
||||
i18n (0.7.0)
|
||||
json (1.8.3)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.4)
|
||||
mime-types (>= 1.16, < 4)
|
||||
method_source (0.8.2)
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.1.0)
|
||||
minitest (5.9.1)
|
||||
nokogiri (1.6.8.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
pry (0.10.4)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.8.1)
|
||||
slop (~> 3.4)
|
||||
rack (1.6.4)
|
||||
rack-protection (1.5.3)
|
||||
rack
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (4.2.7)
|
||||
actionmailer (= 4.2.7)
|
||||
actionpack (= 4.2.7)
|
||||
actionview (= 4.2.7)
|
||||
activejob (= 4.2.7)
|
||||
activemodel (= 4.2.7)
|
||||
activerecord (= 4.2.7)
|
||||
activesupport (= 4.2.7)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.2.7)
|
||||
sprockets-rails
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
rails-dom-testing (1.0.7)
|
||||
activesupport (>= 4.2.0.beta, < 5.0)
|
||||
nokogiri (~> 1.6.0)
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (4.2.7)
|
||||
actionpack (= 4.2.7)
|
||||
activesupport (= 4.2.7)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (11.3.0)
|
||||
redis (3.3.1)
|
||||
redis-namespace (1.5.2)
|
||||
redis (~> 3.0, >= 3.0.4)
|
||||
slop (3.6.0)
|
||||
sprockets (3.7.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.0)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.11)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
appraisal
|
||||
pry
|
||||
rails (= 4.2.7)
|
||||
redis-namespace
|
||||
sidekiq!
|
||||
sqlite3
|
||||
|
||||
BUNDLED WITH
|
||||
1.12.5
|
13
myapp/gemfiles/rails_5.gemfile
Normal file
13
myapp/gemfiles/rails_5.gemfile
Normal file
|
@ -0,0 +1,13 @@
|
|||
# This file was generated by Appraisal
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "appraisal"
|
||||
gem "pry"
|
||||
gem "sidekiq", :path => "../.."
|
||||
gem "rails", "5.0.0"
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3"
|
||||
gem "redis-namespace"
|
||||
end
|
141
myapp/gemfiles/rails_5.gemfile.lock
Normal file
141
myapp/gemfiles/rails_5.gemfile.lock
Normal file
|
@ -0,0 +1,141 @@
|
|||
PATH
|
||||
remote: ../..
|
||||
specs:
|
||||
sidekiq (4.2.6)
|
||||
concurrent-ruby (~> 1.0)
|
||||
connection_pool (~> 2.2, >= 2.2.0)
|
||||
rack-protection (>= 1.5.0)
|
||||
redis (~> 3.2, >= 3.2.1)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.0.0)
|
||||
actionpack (= 5.0.0)
|
||||
nio4r (~> 1.2)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.0.0)
|
||||
actionpack (= 5.0.0)
|
||||
actionview (= 5.0.0)
|
||||
activejob (= 5.0.0)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.0.0)
|
||||
actionview (= 5.0.0)
|
||||
activesupport (= 5.0.0)
|
||||
rack (~> 2.0)
|
||||
rack-test (~> 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.0.0)
|
||||
activesupport (= 5.0.0)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
activejob (5.0.0)
|
||||
activesupport (= 5.0.0)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.0.0)
|
||||
activesupport (= 5.0.0)
|
||||
activerecord (5.0.0)
|
||||
activemodel (= 5.0.0)
|
||||
activesupport (= 5.0.0)
|
||||
arel (~> 7.0)
|
||||
activesupport (5.0.0)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
appraisal (2.1.0)
|
||||
bundler
|
||||
rake
|
||||
thor (>= 0.14.0)
|
||||
arel (7.1.4)
|
||||
builder (3.2.2)
|
||||
coderay (1.1.1)
|
||||
concurrent-ruby (1.0.2)
|
||||
connection_pool (2.2.0)
|
||||
erubis (2.7.0)
|
||||
globalid (0.3.7)
|
||||
activesupport (>= 4.1.0)
|
||||
i18n (0.7.0)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.4)
|
||||
mime-types (>= 1.16, < 4)
|
||||
method_source (0.8.2)
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.1.0)
|
||||
minitest (5.9.1)
|
||||
nio4r (1.2.1)
|
||||
nokogiri (1.6.8.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
pry (0.10.4)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.8.1)
|
||||
slop (~> 3.4)
|
||||
rack (2.0.1)
|
||||
rack-protection (1.5.3)
|
||||
rack
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (5.0.0)
|
||||
actioncable (= 5.0.0)
|
||||
actionmailer (= 5.0.0)
|
||||
actionpack (= 5.0.0)
|
||||
actionview (= 5.0.0)
|
||||
activejob (= 5.0.0)
|
||||
activemodel (= 5.0.0)
|
||||
activerecord (= 5.0.0)
|
||||
activesupport (= 5.0.0)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 5.0.0)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-dom-testing (2.0.1)
|
||||
activesupport (>= 4.2.0, < 6.0)
|
||||
nokogiri (~> 1.6.0)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (5.0.0)
|
||||
actionpack (= 5.0.0)
|
||||
activesupport (= 5.0.0)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (11.3.0)
|
||||
redis (3.3.1)
|
||||
redis-namespace (1.5.2)
|
||||
redis (~> 3.0, >= 3.0.4)
|
||||
slop (3.6.0)
|
||||
sprockets (3.7.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.0)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.11)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
websocket-driver (0.6.4)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
appraisal
|
||||
pry
|
||||
rails (= 5.0.0)
|
||||
redis-namespace
|
||||
sidekiq!
|
||||
sqlite3
|
||||
|
||||
BUNDLED WITH
|
||||
1.12.5
|
20
myapp/integration_test.rb
Normal file
20
myapp/integration_test.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
require '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
|
Loading…
Add table
Reference in a new issue