diff options
author | Abdelkader Boudih <terminale@gmail.com> | 2014-08-12 09:17:19 +0000 |
---|---|---|
committer | Abdelkader Boudih <terminale@gmail.com> | 2014-08-12 09:17:19 +0000 |
commit | a75f085941b2d6aed160f5f2f7e64e5fc7e03826 (patch) | |
tree | 23174b264983a15c3108ec912b355829c5f17a80 /activejob/test/support/integration/adapters | |
parent | b45b99894a60eda434abec94d133a1cfd8de2dda (diff) | |
parent | 14f74a8331f94150dfee653224de8fc837797709 (diff) | |
download | rails-a75f085941b2d6aed160f5f2f7e64e5fc7e03826.tar.gz rails-a75f085941b2d6aed160f5f2f7e64e5fc7e03826.tar.bz2 rails-a75f085941b2d6aed160f5f2f7e64e5fc7e03826.zip |
Add 'activejob/' from commit '14f74a8331f94150dfee653224de8fc837797709'
git-subtree-dir: activejob
git-subtree-mainline: b45b99894a60eda434abec94d133a1cfd8de2dda
git-subtree-split: 14f74a8331f94150dfee653224de8fc837797709
Diffstat (limited to 'activejob/test/support/integration/adapters')
9 files changed, 143 insertions, 0 deletions
diff --git a/activejob/test/support/integration/adapters/backburner.rb b/activejob/test/support/integration/adapters/backburner.rb new file mode 100644 index 0000000000..7271d50a45 --- /dev/null +++ b/activejob/test/support/integration/adapters/backburner.rb @@ -0,0 +1,15 @@ +module BackburnerJobsManager + def clear_jobs + Backburner::Worker.connection.tubes.all.map &:clear + end + + def start_workers + @thread = Thread.new { Backburner.work "active-jobs-default" } + end + + def stop_workers + @thread.kill + end + +end + diff --git a/activejob/test/support/integration/adapters/delayed_job.rb b/activejob/test/support/integration/adapters/delayed_job.rb new file mode 100644 index 0000000000..3e55933438 --- /dev/null +++ b/activejob/test/support/integration/adapters/delayed_job.rb @@ -0,0 +1,14 @@ +module DelayedJobJobsManager + def clear_jobs + Delayed::Job.delete_all + end + + def start_workers + @worker = Delayed::Worker.new(quiet: false, sleep_delay: 0.5) + @thread = Thread.new { @worker.start } + end + + def stop_workers + @worker.stop + end +end diff --git a/activejob/test/support/integration/adapters/qu.rb b/activejob/test/support/integration/adapters/qu.rb new file mode 100644 index 0000000000..12d063ea0d --- /dev/null +++ b/activejob/test/support/integration/adapters/qu.rb @@ -0,0 +1,14 @@ +module QuJobsManager + def clear_jobs + Qu.clear "active_jobs_default" + end + + def start_workers + @thread = Thread.new { Qu::Worker.new("active_jobs_default").start } + end + + def stop_workers + @thread.kill + end +end + diff --git a/activejob/test/support/integration/adapters/que.rb b/activejob/test/support/integration/adapters/que.rb new file mode 100644 index 0000000000..f15c9af910 --- /dev/null +++ b/activejob/test/support/integration/adapters/que.rb @@ -0,0 +1,19 @@ +module QueJobsManager + def clear_jobs + Que.clear! + end + + def start_workers + @thread = Thread.new do + loop do + Que::Job.work("active_jobs_default") + sleep 0.5 + end + end + end + + def stop_workers + @thread.kill + end +end + diff --git a/activejob/test/support/integration/adapters/queue_classic.rb b/activejob/test/support/integration/adapters/queue_classic.rb new file mode 100644 index 0000000000..3b24eca5b9 --- /dev/null +++ b/activejob/test/support/integration/adapters/queue_classic.rb @@ -0,0 +1,21 @@ +module QC; WAIT_TIME = 0.5; end + +module QueueClassicJobsManager + def clear_jobs + # disabling this as it locks + # QC::Queue.new("active_jobs_default").delete_all + end + + def start_workers + @pid = fork do + QC::Conn.connection = QC::Conn.connect + worker = QC::Worker.new(q_name: 'active_jobs_default') + worker.start + end + end + + def stop_workers + Process.kill 'HUP', @pid + end +end + diff --git a/activejob/test/support/integration/adapters/resque.rb b/activejob/test/support/integration/adapters/resque.rb new file mode 100644 index 0000000000..b9811bd3e1 --- /dev/null +++ b/activejob/test/support/integration/adapters/resque.rb @@ -0,0 +1,18 @@ +module ResqueJobsManager + def clear_jobs + Resque.queues.each { |queue_name| Resque.redis.del "queue:#{queue_name}" } + Resque.redis.keys("delayed:*").each { |key| Resque.redis.del "#{key}" } + Resque.redis.del "delayed_queue_schedule" + end + + def start_workers + @thread = Thread.new do + Resque::Worker.new("*").work(0.5) + end + end + + def stop_workers + @thread.kill + end +end + diff --git a/activejob/test/support/integration/adapters/sidekiq.rb b/activejob/test/support/integration/adapters/sidekiq.rb new file mode 100644 index 0000000000..d3b7d15614 --- /dev/null +++ b/activejob/test/support/integration/adapters/sidekiq.rb @@ -0,0 +1,19 @@ +require 'sidekiq/launcher' +require 'sidekiq/api' + +module SidekiqJobsManager + def clear_jobs + Sidekiq::Queue.new("active_jobs_default").clear + end + + def start_workers + options = {:queues=>["active_jobs_default"], :concurrency=>1, :environment=>"test", :timeout=>8, :daemon=>true, :strict=>true} + @launcher = Sidekiq::Launcher.new(options) + @launcher.run + end + + def stop_workers + @launcher.stop + end +end + diff --git a/activejob/test/support/integration/adapters/sneakers.rb b/activejob/test/support/integration/adapters/sneakers.rb new file mode 100644 index 0000000000..5dcab68515 --- /dev/null +++ b/activejob/test/support/integration/adapters/sneakers.rb @@ -0,0 +1,18 @@ +require 'sneakers/runner' + +module SneakersJobsManager + def clear_jobs + end + + def start_workers + cmd = %{cd #{Rails.root.to_s} && (RAILS_ENV=test AJADAPTER=sneakers WORKERS=ActiveJob::QueueAdapters::SneakersAdapter::JobWrapper bundle exec rake --trace sneakers:run)} + `#{cmd}` + while !Rails.root.join("tmp/sneakers.pid").exist? do + sleep 0.5 + end + end + + def stop_workers + Process.kill 'TERM', File.open(Rails.root.join("tmp/sneakers.pid").to_s).read.to_i + end +end diff --git a/activejob/test/support/integration/adapters/sucker_punch.rb b/activejob/test/support/integration/adapters/sucker_punch.rb new file mode 100644 index 0000000000..317f9c80fd --- /dev/null +++ b/activejob/test/support/integration/adapters/sucker_punch.rb @@ -0,0 +1,5 @@ +module SuckerPunchJobsManager + def clear_jobs + end +end + |