From 664546c208c406bba08b8eda2e6a600154d7232e Mon Sep 17 00:00:00 2001 From: Cristian Bica Date: Tue, 5 Aug 2014 09:05:14 +0300 Subject: Integration testing --- test/dummy/Rakefile | 3 + test/dummy/app/assets/images/.keep | 0 .../app/controllers/application_controller.rb | 3 + test/dummy/app/controllers/concerns/.keep | 0 test/dummy/app/helpers/application_helper.rb | 2 + test/dummy/app/jobs/test_job.rb | 9 +++ test/dummy/app/mailers/.keep | 0 test/dummy/app/models/.keep | 0 test/dummy/app/models/concerns/.keep | 0 test/dummy/config.ru | 4 ++ test/dummy/config/application.rb | 9 +++ test/dummy/config/boot.rb | 5 ++ test/dummy/config/database.yml | 3 + test/dummy/config/environment.rb | 2 + test/dummy/config/environments/test.rb | 13 +++++ test/dummy/config/initializers/activejob.rb | 65 +++++++++++++++++++++ test/dummy/config/initializers/session_store.rb | 1 + test/dummy/config/routes.rb | 2 + test/dummy/config/secrets.yml | 2 + .../migrate/20140804200445_create_delayed_jobs.rb | 22 +++++++ test/dummy/db/schema.rb | 32 ++++++++++ test/dummy/db/test.sqlite3 | Bin 0 -> 24576 bytes test/dummy/lib/assets/.keep | 0 test/dummy/log/.keep | 0 test/dummy/tmp/.keep | 0 test/helper.rb | 12 ++-- test/integration/queuing_test.rb | 18 ++++++ test/support/integration/adapters/backburner.rb | 15 +++++ test/support/integration/adapters/delayed_job.rb | 14 +++++ test/support/integration/adapters/qu.rb | 14 +++++ test/support/integration/adapters/que.rb | 19 ++++++ test/support/integration/adapters/queue_classic.rb | 21 +++++++ test/support/integration/adapters/resque.rb | 18 ++++++ test/support/integration/adapters/sidekiq.rb | 19 ++++++ test/support/integration/adapters/sneakers.rb | 18 ++++++ test/support/integration/adapters/sucker_punch.rb | 5 ++ test/support/integration/helper.rb | 12 ++++ test/support/integration/jobs_manager.rb | 23 ++++++++ test/support/integration/test_case_helpers.rb | 30 ++++++++++ 39 files changed, 411 insertions(+), 4 deletions(-) create mode 100644 test/dummy/Rakefile create mode 100644 test/dummy/app/assets/images/.keep create mode 100644 test/dummy/app/controllers/application_controller.rb create mode 100644 test/dummy/app/controllers/concerns/.keep create mode 100644 test/dummy/app/helpers/application_helper.rb create mode 100644 test/dummy/app/jobs/test_job.rb create mode 100644 test/dummy/app/mailers/.keep create mode 100644 test/dummy/app/models/.keep create mode 100644 test/dummy/app/models/concerns/.keep create mode 100644 test/dummy/config.ru create mode 100644 test/dummy/config/application.rb create mode 100644 test/dummy/config/boot.rb create mode 100644 test/dummy/config/database.yml create mode 100644 test/dummy/config/environment.rb create mode 100644 test/dummy/config/environments/test.rb create mode 100644 test/dummy/config/initializers/activejob.rb create mode 100644 test/dummy/config/initializers/session_store.rb create mode 100644 test/dummy/config/routes.rb create mode 100644 test/dummy/config/secrets.yml create mode 100644 test/dummy/db/migrate/20140804200445_create_delayed_jobs.rb create mode 100644 test/dummy/db/schema.rb create mode 100644 test/dummy/db/test.sqlite3 create mode 100644 test/dummy/lib/assets/.keep create mode 100644 test/dummy/log/.keep create mode 100644 test/dummy/tmp/.keep create mode 100644 test/integration/queuing_test.rb create mode 100644 test/support/integration/adapters/backburner.rb create mode 100644 test/support/integration/adapters/delayed_job.rb create mode 100644 test/support/integration/adapters/qu.rb create mode 100644 test/support/integration/adapters/que.rb create mode 100644 test/support/integration/adapters/queue_classic.rb create mode 100644 test/support/integration/adapters/resque.rb create mode 100644 test/support/integration/adapters/sidekiq.rb create mode 100644 test/support/integration/adapters/sneakers.rb create mode 100644 test/support/integration/adapters/sucker_punch.rb create mode 100644 test/support/integration/helper.rb create mode 100644 test/support/integration/jobs_manager.rb create mode 100644 test/support/integration/test_case_helpers.rb (limited to 'test') diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile new file mode 100644 index 0000000000..9866295e6a --- /dev/null +++ b/test/dummy/Rakefile @@ -0,0 +1,3 @@ +require 'sneakers/tasks' +require File.expand_path('../config/application', __FILE__) +Rails.application.load_tasks diff --git a/test/dummy/app/assets/images/.keep b/test/dummy/app/assets/images/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb new file mode 100644 index 0000000000..1c07694e9d --- /dev/null +++ b/test/dummy/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + protect_from_forgery with: :exception +end diff --git a/test/dummy/app/controllers/concerns/.keep b/test/dummy/app/controllers/concerns/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb new file mode 100644 index 0000000000..de6be7945c --- /dev/null +++ b/test/dummy/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test/dummy/app/jobs/test_job.rb b/test/dummy/app/jobs/test_job.rb new file mode 100644 index 0000000000..281771a851 --- /dev/null +++ b/test/dummy/app/jobs/test_job.rb @@ -0,0 +1,9 @@ +class TestJob < ActiveJob::Base + queue_as :default + + def perform(x) + File.open(Rails.root.join("tmp/#{x}"), "w+") do |f| + f.write x + end + end +end diff --git a/test/dummy/app/mailers/.keep b/test/dummy/app/mailers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/dummy/app/models/.keep b/test/dummy/app/models/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/dummy/app/models/concerns/.keep b/test/dummy/app/models/concerns/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/dummy/config.ru b/test/dummy/config.ru new file mode 100644 index 0000000000..5bc2a619e8 --- /dev/null +++ b/test/dummy/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb new file mode 100644 index 0000000000..8b06039a68 --- /dev/null +++ b/test/dummy/config/application.rb @@ -0,0 +1,9 @@ +require File.expand_path('../boot', __FILE__) +require 'rails/all' +Bundler.require(*Rails.groups) + +module Dummy + class Application < Rails::Application + end +end + diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb new file mode 100644 index 0000000000..6266cfc509 --- /dev/null +++ b/test/dummy/config/boot.rb @@ -0,0 +1,5 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml new file mode 100644 index 0000000000..f5f3aaf1fa --- /dev/null +++ b/test/dummy/config/database.yml @@ -0,0 +1,3 @@ +test: + adapter: sqlite3 + database: "db/test.sqlite3" diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb new file mode 100644 index 0000000000..7fd2f91b8f --- /dev/null +++ b/test/dummy/config/environment.rb @@ -0,0 +1,2 @@ +require File.expand_path('../application', __FILE__) +Rails.application.initialize! diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb new file mode 100644 index 0000000000..ff0318412f --- /dev/null +++ b/test/dummy/config/environments/test.rb @@ -0,0 +1,13 @@ +Rails.application.configure do + config.cache_classes = true + config.eager_load = false + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.action_dispatch.show_exceptions = false + config.action_controller.allow_forgery_protection = false + config.action_mailer.delivery_method = :test + config.active_support.deprecation = :stderr + config.log_level = :debug +end diff --git a/test/dummy/config/initializers/activejob.rb b/test/dummy/config/initializers/activejob.rb new file mode 100644 index 0000000000..5fcde86c96 --- /dev/null +++ b/test/dummy/config/initializers/activejob.rb @@ -0,0 +1,65 @@ +case ENV['AJADAPTER'] +when "delayed_job" + ActiveJob::Base.queue_adapter = :delayed_job +when "sidekiq" + ActiveJob::Base.queue_adapter = :sidekiq +when "resque" + ActiveJob::Base.queue_adapter = :resque + Resque.redis = Redis::Namespace.new 'active_jobs_int_test', redis: Redis.connect(url: "tcp://127.0.0.1:6379/12", :thread_safe => true) + Resque.logger = Rails.logger +when 'qu' + ActiveJob::Base.queue_adapter = :qu + ENV['REDISTOGO_URL'] = "tcp://127.0.0.1:6379/12" + backend = Qu::Backend::Redis.new + backend.namespace = "active_jobs_int_test" + Qu.backend = backend + Qu.logger = Rails.logger + Qu.interval = 0.5 +when 'que' + ActiveJob::Base.queue_adapter = :que + QUE_URL = ENV['QUE_DATABASE_URL'] || 'postgres://localhost/active_jobs_que_int_test' + uri = URI.parse(QUE_URL) + user = uri.user||ENV['USER'] + pass = uri.password + db = uri.path[1..-1] + %x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -c 'drop database "#{db}"' -U #{user} -t template1} + %x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -c 'create database "#{db}"' -U #{user} -t template1} + Que.connection = Sequel.connect(QUE_URL) + Que.migrate! + Que.mode = :off + Que.worker_count = 1 +when 'queue_classic' + ENV['QC_DATABASE_URL'] ||= 'postgres://localhost/active_jobs_qc_int_test' + ENV['QC_LISTEN_TIME'] = "0.5" + ActiveJob::Base.queue_adapter = :queue_classic + uri = URI.parse(ENV['QC_DATABASE_URL']) + user = uri.user||ENV['USER'] + pass = uri.password + db = uri.path[1..-1] + %x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -c 'drop database "#{db}"' -U #{user} -t template1} + %x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -c 'create database "#{db}"' -U #{user} -t template1} + QC::Setup.create +when 'sidekiq' + ActiveJob::Base.queue_adapter = :sidekiq +when 'sneakers' + ActiveJob::Base.queue_adapter = :sneakers + Sneakers.configure :heartbeat => 2, + :amqp => 'amqp://guest:guest@localhost:5672', + :vhost => '/', + :exchange => 'active_jobs_sneakers_int_test', + :exchange_type => :direct, + :daemonize => true, + :threads => 1, + :workers => 1, + :pid_path => Rails.root.join("tmp/sneakers.pid").to_s, + :log => Rails.root.join("log/sneakers.log").to_s +when 'sucker_punch' + ActiveJob::Base.queue_adapter = :sucker_punch +when 'backburner' + ActiveJob::Base.queue_adapter = :backburner + Backburner.configure do |config| + config.logger = Rails.logger + end +else + ActiveJob::Base.queue_adapter = nil +end diff --git a/test/dummy/config/initializers/session_store.rb b/test/dummy/config/initializers/session_store.rb new file mode 100644 index 0000000000..70a5a506a9 --- /dev/null +++ b/test/dummy/config/initializers/session_store.rb @@ -0,0 +1 @@ +Rails.application.config.session_store :cookie_store, key: '_dummy_session' diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb new file mode 100644 index 0000000000..1daf9a4121 --- /dev/null +++ b/test/dummy/config/routes.rb @@ -0,0 +1,2 @@ +Rails.application.routes.draw do +end diff --git a/test/dummy/config/secrets.yml b/test/dummy/config/secrets.yml new file mode 100644 index 0000000000..7dfacb38ea --- /dev/null +++ b/test/dummy/config/secrets.yml @@ -0,0 +1,2 @@ +test: + secret_key_base: b83ee5aeada663bc4270a1817d0ca43b2784017cc77dc8afcd60967cc968d4ce30caff9eb682766129e18a4048c4d5ebf14eabf463fc37ad67c18934f4345545 diff --git a/test/dummy/db/migrate/20140804200445_create_delayed_jobs.rb b/test/dummy/db/migrate/20140804200445_create_delayed_jobs.rb new file mode 100644 index 0000000000..ec0dd93ce1 --- /dev/null +++ b/test/dummy/db/migrate/20140804200445_create_delayed_jobs.rb @@ -0,0 +1,22 @@ +class CreateDelayedJobs < ActiveRecord::Migration + def self.up + create_table :delayed_jobs, :force => true do |table| + table.integer :priority, :default => 0, :null => false # Allows some jobs to jump to the front of the queue + table.integer :attempts, :default => 0, :null => false # Provides for retries, but still fail eventually. + table.text :handler, :null => false # YAML-encoded string of the object that will do work + table.text :last_error # reason for last failure (See Note below) + table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future. + table.datetime :locked_at # Set when a client is working on this object + table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead) + table.string :locked_by # Who is working on this object (if locked) + table.string :queue # The name of the queue this job is in + table.timestamps + end + + add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority' + end + + def self.down + drop_table :delayed_jobs + end +end diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb new file mode 100644 index 0000000000..012a099f9c --- /dev/null +++ b/test/dummy/db/schema.rb @@ -0,0 +1,32 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20140804200445) do + + create_table "delayed_jobs", force: true do |t| + t.integer "priority", default: 0, null: false + t.integer "attempts", default: 0, null: false + t.text "handler", null: false + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by" + t.string "queue" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority" + +end diff --git a/test/dummy/db/test.sqlite3 b/test/dummy/db/test.sqlite3 new file mode 100644 index 0000000000..671e20102e Binary files /dev/null and b/test/dummy/db/test.sqlite3 differ diff --git a/test/dummy/lib/assets/.keep b/test/dummy/lib/assets/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/dummy/log/.keep b/test/dummy/log/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/dummy/tmp/.keep b/test/dummy/tmp/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/helper.rb b/test/helper.rb index 7ba7607df2..104dabd861 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -6,10 +6,14 @@ $LOAD_PATH << File.dirname(__FILE__) + "/../lib" require 'active_job' adapter = ENV['AJADAPTER'] || 'inline' -require "adapters/#{adapter}" -puts "Testing using #{adapter}" +puts "Testing#{" integration" if ENV['AJ_INTEGRATION_TESTS']} using #{adapter}" -require 'active_support/testing/autorun' +if ENV['AJ_INTEGRATION_TESTS'] + require 'support/integration/helper' +else + require "adapters/#{adapter}" +end +require 'active_support/testing/autorun' -ActiveJob::Base.logger.level = Logger::ERROR +ActiveJob::Base.logger.level = Logger::DEBUG diff --git a/test/integration/queuing_test.rb b/test/integration/queuing_test.rb new file mode 100644 index 0000000000..bf6137af4c --- /dev/null +++ b/test/integration/queuing_test.rb @@ -0,0 +1,18 @@ +require 'helper' +require 'jobs/logging_job' +require 'active_support/core_ext/numeric/time' + + +class QueuingTest < ActiveSupport::TestCase + setup do + + end + + test 'run queued job' do + id = "AJ-#{SecureRandom.uuid}" + TestJob.enqueue id + sleep 2 + assert Dummy::Application.root.join("tmp/#{id}").exist? + end + +end diff --git a/test/support/integration/adapters/backburner.rb b/test/support/integration/adapters/backburner.rb new file mode 100644 index 0000000000..7271d50a45 --- /dev/null +++ b/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/test/support/integration/adapters/delayed_job.rb b/test/support/integration/adapters/delayed_job.rb new file mode 100644 index 0000000000..3e55933438 --- /dev/null +++ b/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/test/support/integration/adapters/qu.rb b/test/support/integration/adapters/qu.rb new file mode 100644 index 0000000000..12d063ea0d --- /dev/null +++ b/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/test/support/integration/adapters/que.rb b/test/support/integration/adapters/que.rb new file mode 100644 index 0000000000..f15c9af910 --- /dev/null +++ b/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/test/support/integration/adapters/queue_classic.rb b/test/support/integration/adapters/queue_classic.rb new file mode 100644 index 0000000000..3b24eca5b9 --- /dev/null +++ b/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/test/support/integration/adapters/resque.rb b/test/support/integration/adapters/resque.rb new file mode 100644 index 0000000000..b9811bd3e1 --- /dev/null +++ b/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/test/support/integration/adapters/sidekiq.rb b/test/support/integration/adapters/sidekiq.rb new file mode 100644 index 0000000000..d3b7d15614 --- /dev/null +++ b/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/test/support/integration/adapters/sneakers.rb b/test/support/integration/adapters/sneakers.rb new file mode 100644 index 0000000000..5dcab68515 --- /dev/null +++ b/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/test/support/integration/adapters/sucker_punch.rb b/test/support/integration/adapters/sucker_punch.rb new file mode 100644 index 0000000000..317f9c80fd --- /dev/null +++ b/test/support/integration/adapters/sucker_punch.rb @@ -0,0 +1,5 @@ +module SuckerPunchJobsManager + def clear_jobs + end +end + diff --git a/test/support/integration/helper.rb b/test/support/integration/helper.rb new file mode 100644 index 0000000000..cb94e7cfb5 --- /dev/null +++ b/test/support/integration/helper.rb @@ -0,0 +1,12 @@ +ENV["RAILS_ENV"] = "test" +require File.expand_path("../../../dummy/config/environment.rb", __FILE__) +require "rails/test_help" +Rails.backtrace_cleaner.remove_silencers! + +require_relative 'test_case_helpers' +ActiveSupport::TestCase.send(:include, TestCaseHelpers) + +JobsManager.current_manager.setup +JobsManager.current_manager.start_workers +Minitest.after_run { JobsManager.current_manager.stop_workers } + diff --git a/test/support/integration/jobs_manager.rb b/test/support/integration/jobs_manager.rb new file mode 100644 index 0000000000..1da74193b1 --- /dev/null +++ b/test/support/integration/jobs_manager.rb @@ -0,0 +1,23 @@ +class JobsManager + @@managers = {} + attr :adapter_name + + def self.current_manager + @@managers[ENV['AJADAPTER']] ||= new(ENV['AJADAPTER']) + end + + def initialize(adapter_name) + @adapter_name = adapter_name + require_relative "adapters/#{adapter_name}" + extend "#{adapter_name.camelize}JobsManager".constantize + end + + def setup + end + + def start_workers + end + + def stop_workers + end +end diff --git a/test/support/integration/test_case_helpers.rb b/test/support/integration/test_case_helpers.rb new file mode 100644 index 0000000000..9a5eea0783 --- /dev/null +++ b/test/support/integration/test_case_helpers.rb @@ -0,0 +1,30 @@ +require 'active_support/concern' +require 'support/integration/jobs_manager' + +module TestCaseHelpers + extend ActiveSupport::Concern + + included do + self.use_transactional_fixtures = false + + setup do + clear_jobs + end + + teardown do + clear_jobs + FileUtils.rm_rf Dir[Dummy::Application.root.join("tmp/AJ-*")] + end + end + + protected + + def jobs_manager + JobsManager.current_manager + end + + def clear_jobs + jobs_manager.clear_jobs + end + +end -- cgit v1.2.3