Skip to content

Commit 14f74a8

Browse files
committed
Merge pull request rails#102 from cristianbica/integration_tests
Integration testing
2 parents 06ccd5f + 664546c commit 14f74a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+574
-52
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/test/dummy/log/*
2+
/test/dummy/tmp/*

.travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
before_install:
22
- travis_retry gem install bundler
3+
- sudo apt-get update -qq
4+
- sudo apt-get install beanstalkd
5+
- echo "START=yes" | sudo tee -a /etc/default/beanstalkd
6+
- sudo /etc/init.d/beanstalkd start
7+
38
rvm:
49
- 1.9.3
510
- 2.0.0
611
- 2.1
712
- ruby-head
813
- rbx-2
914
- jruby
15+
env:
16+
- QC_DATABASE_URL="postgres://postgres@localhost/active_jobs_qc_int_test" QUE_DATABASE_URL="postgres://postgres@localhost/active_jobs_qc_int_test"
1017
matrix:
1118
allow_failures:
1219
- rvm: rbx-2
@@ -27,3 +34,6 @@ notifications:
2734
- secure: AgZwJA+9VdnWAw7QN9Z5s6RpQIzsEB0q7V+p3pCzXY45156WocL8iNQx+KnyOQ8jbRUt4L/XIOiZl5xHf4pHjXytHWHNhetAlVQP/hPeDcCSk/h0g5gqgf6QABdp38tBNaUq866bXHgCOZYPwwP9bypcmuv2SLyfIO+b/PBgqN0=
2835
services:
2936
- redis
37+
- rabbitmq
38+
addons:
39+
postgresql: "9.3"

Gemfile

+9
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,12 @@ gem 'que'
1414
gem 'backburner'
1515
gem 'qu-rails', github: "bkeepers/qu", branch: "master"
1616
gem 'qu-redis'
17+
18+
#for integration testing
19+
gem 'arel', github: 'rails/arel'
20+
gem 'rack', github: 'rack/rack'
21+
gem 'i18n', github: 'svenfuchs/i18n'
22+
gem 'rails', github: 'rails/rails'
23+
gem 'sqlite3'
24+
gem 'delayed_job_active_record'
25+
gem 'sequel'

Gemfile.lock

+111-46
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GIT
22
remote: git://github.com/bkeepers/qu.git
3-
revision: 2175633a834504423368d71cb10fb9f072d76cd2
3+
revision: 50f3788f2b55ddd4dc939767fb35aebefa260322
44
branch: master
55
specs:
66
qu (0.2.0)
@@ -11,6 +11,70 @@ GIT
1111
qu (= 0.2.0)
1212
redis-namespace
1313

14+
GIT
15+
remote: git://github.com/rack/rack.git
16+
revision: e98a9f7ef0ddd9589145ea953948c73a8ce3caa9
17+
specs:
18+
rack (1.6.0.alpha)
19+
20+
GIT
21+
remote: git://github.com/rails/arel.git
22+
revision: 66cee768bc163537087037a583f60639eae49fc3
23+
specs:
24+
arel (6.0.0.20140505020427)
25+
26+
GIT
27+
remote: git://github.com/rails/rails.git
28+
revision: b2e88043b52a8f83820a0f4e8a65aa42fd40c544
29+
specs:
30+
actionmailer (4.2.0.alpha)
31+
actionpack (= 4.2.0.alpha)
32+
actionview (= 4.2.0.alpha)
33+
mail (~> 2.5, >= 2.5.4)
34+
actionpack (4.2.0.alpha)
35+
actionview (= 4.2.0.alpha)
36+
activesupport (= 4.2.0.alpha)
37+
rack (~> 1.6.0.alpha)
38+
rack-test (~> 0.6.2)
39+
actionview (4.2.0.alpha)
40+
activesupport (= 4.2.0.alpha)
41+
builder (~> 3.1)
42+
erubis (~> 2.7.0)
43+
activemodel (4.2.0.alpha)
44+
activesupport (= 4.2.0.alpha)
45+
builder (~> 3.1)
46+
activerecord (4.2.0.alpha)
47+
activemodel (= 4.2.0.alpha)
48+
activesupport (= 4.2.0.alpha)
49+
arel (~> 6.0.0)
50+
activesupport (4.2.0.alpha)
51+
i18n (>= 0.7.0.dev, < 0.8)
52+
json (~> 1.7, >= 1.7.7)
53+
minitest (~> 5.1)
54+
thread_safe (~> 0.1)
55+
tzinfo (~> 1.1)
56+
rails (4.2.0.alpha)
57+
actionmailer (= 4.2.0.alpha)
58+
actionpack (= 4.2.0.alpha)
59+
actionview (= 4.2.0.alpha)
60+
activemodel (= 4.2.0.alpha)
61+
activerecord (= 4.2.0.alpha)
62+
activesupport (= 4.2.0.alpha)
63+
bundler (>= 1.3.0, < 2.0)
64+
railties (= 4.2.0.alpha)
65+
sprockets-rails (~> 2.1)
66+
railties (4.2.0.alpha)
67+
actionpack (= 4.2.0.alpha)
68+
activesupport (= 4.2.0.alpha)
69+
rake (>= 0.8.7)
70+
thor (>= 0.18.1, < 2.0)
71+
72+
GIT
73+
remote: git://github.com/svenfuchs/i18n.git
74+
revision: cb679b8cdbab675703a3f88de4d48a48f7b50e06
75+
specs:
76+
i18n (0.7.0.dev)
77+
1478
PATH
1579
remote: .
1680
specs:
@@ -21,27 +85,9 @@ PATH
2185
GEM
2286
remote: https://rubygems.org/
2387
specs:
24-
actionpack (4.1.1)
25-
actionview (= 4.1.1)
26-
activesupport (= 4.1.1)
27-
rack (~> 1.5.2)
28-
rack-test (~> 0.6.2)
29-
actionview (4.1.1)
30-
activesupport (= 4.1.1)
31-
builder (~> 3.1)
32-
erubis (~> 2.7.0)
33-
activemodel (4.1.1)
34-
activesupport (= 4.1.1)
35-
builder (~> 3.1)
36-
activemodel-globalid (0.1.0)
88+
activemodel-globalid (0.1.1)
3789
activemodel (>= 4.1.0)
3890
activesupport (>= 4.1.0)
39-
activesupport (4.1.1)
40-
i18n (~> 0.6, >= 0.6.9)
41-
json (~> 1.7, >= 1.7.7)
42-
minitest (~> 5.1)
43-
thread_safe (~> 0.1)
44-
tzinfo (~> 1.1)
4591
amq-protocol (1.9.2)
4692
backburner (0.4.5)
4793
beaneater (~> 0.3.1)
@@ -54,54 +100,56 @@ GEM
54100
timers (~> 1.1.0)
55101
connection_pool (2.0.0)
56102
dante (0.1.5)
57-
delayed_job (4.0.1)
103+
delayed_job (4.0.2)
58104
activesupport (>= 3.0, < 4.2)
105+
delayed_job_active_record (4.0.1)
106+
activerecord (>= 3.0, < 4.2)
107+
delayed_job (>= 3.0, < 4.1)
59108
erubis (2.7.0)
60-
i18n (0.6.9)
109+
hike (1.2.3)
61110
json (1.8.1)
62-
minitest (5.3.4)
111+
mail (2.6.1)
112+
mime-types (>= 1.16, < 3)
113+
mime-types (2.3)
114+
minitest (5.4.0)
63115
mono_logger (1.1.0)
64-
multi_json (1.9.3)
116+
multi_json (1.10.1)
65117
pg (0.17.1)
66-
que (0.7.3)
118+
que (0.8.1)
67119
queue_classic (2.2.3)
68120
pg (~> 0.17.0)
69-
rack (1.5.2)
70-
rack-protection (1.5.2)
121+
rack-protection (1.5.3)
71122
rack
72123
rack-test (0.6.2)
73124
rack (>= 1.0)
74-
railties (4.1.1)
75-
actionpack (= 4.1.1)
76-
activesupport (= 4.1.1)
77-
rake (>= 0.8.7)
78-
thor (>= 0.18.1, < 2.0)
79125
rake (10.3.2)
80-
redis (3.0.7)
81-
redis-namespace (1.4.1)
82-
redis (~> 3.0.4)
83-
resque (1.24.1)
126+
redis (3.1.0)
127+
redis-namespace (1.5.1)
128+
redis (~> 3.0, >= 3.0.4)
129+
resque (1.25.2)
84130
mono_logger (~> 1.0)
85131
multi_json (~> 1.0)
86-
redis-namespace (~> 1.2)
132+
redis-namespace (~> 1.3)
87133
sinatra (>= 0.9.2)
88134
vegas (~> 0.1.2)
89-
resque-scheduler (2.2.0)
90-
redis (>= 3.0.0)
91-
resque (>= 1.20.0, < 1.25)
135+
resque-scheduler (3.0.0)
136+
mono_logger (~> 1.0)
137+
redis (~> 3.0)
138+
resque (~> 1.25)
92139
rufus-scheduler (~> 2.0)
93140
rufus-scheduler (2.0.24)
94141
tzinfo (>= 0.3.22)
95-
serverengine (1.5.7)
142+
sequel (4.8.0)
143+
serverengine (1.5.9)
96144
sigdump (~> 0.2.2)
97-
sidekiq (3.0.2)
145+
sidekiq (3.2.1)
98146
celluloid (>= 0.15.2)
99147
connection_pool (>= 2.0.0)
100148
json
101149
redis (>= 3.0.6)
102150
redis-namespace (>= 1.3.1)
103151
sigdump (0.2.2)
104-
sinatra (1.4.4)
152+
sinatra (1.4.5)
105153
rack (~> 1.4)
106154
rack-protection (~> 1.4)
107155
tilt (~> 1.3, >= 1.3.4)
@@ -110,14 +158,24 @@ GEM
110158
serverengine
111159
thor
112160
thread
113-
sucker_punch (1.0.5)
161+
sprockets (2.12.1)
162+
hike (~> 1.2)
163+
multi_json (~> 1.0)
164+
rack (~> 1.0)
165+
tilt (~> 1.1, != 1.3.0)
166+
sprockets-rails (2.1.3)
167+
actionpack (>= 3.0)
168+
activesupport (>= 3.0)
169+
sprockets (~> 2.8)
170+
sqlite3 (1.3.9)
171+
sucker_punch (1.1)
114172
celluloid (~> 0.15.2)
115173
thor (0.19.1)
116174
thread (0.1.4)
117-
thread_safe (0.3.3)
175+
thread_safe (0.3.4)
118176
tilt (1.4.1)
119177
timers (1.1.0)
120-
tzinfo (1.1.0)
178+
tzinfo (1.2.1)
121179
thread_safe (~> 0.1)
122180
vegas (0.1.11)
123181
rack (>= 1.0.0)
@@ -127,15 +185,22 @@ PLATFORMS
127185

128186
DEPENDENCIES
129187
activejob!
188+
arel!
130189
backburner
131190
delayed_job
191+
delayed_job_active_record
192+
i18n!
132193
qu-rails!
133194
qu-redis
134195
que
135196
queue_classic
197+
rack!
198+
rails!
136199
rake
137200
resque
138201
resque-scheduler
202+
sequel
139203
sidekiq
140204
sneakers (= 0.1.1.pre)
205+
sqlite3
141206
sucker_punch

Rakefile

+30-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ end
1818

1919
task default: :test
2020

21+
ADAPTERS = %w(inline delayed_job qu que queue_classic resque sidekiq sneakers sucker_punch backburner)
22+
2123
desc 'Run all adapter tests'
2224
task :test do
23-
tasks = %w(test_inline test_delayed_job test_qu test_que test_queue_classic test_resque test_sidekiq test_sneakers test_sucker_punch test_backburner)
25+
tasks = ADAPTERS.map{|a| "test_#{a}" }+["integration_test"]
2426
run_without_aborting(*tasks)
2527
end
2628

27-
%w(inline delayed_job qu que queue_classic resque sidekiq sneakers sucker_punch backburner).each do |adapter|
29+
ADAPTERS.each do |adapter|
2830
Rake::TestTask.new("test_#{adapter}") do |t|
2931
t.libs << 'test'
3032
t.test_files = FileList['test/cases/**/*_test.rb']
@@ -38,3 +40,29 @@ end
3840

3941
task "test_#{adapter}" => "#{adapter}:env"
4042
end
43+
44+
45+
46+
desc 'Run all adapter integration tests'
47+
task :integration_test do
48+
tasks = (ADAPTERS-['inline']).map{|a| "integration_test_#{a}" }
49+
run_without_aborting(*tasks)
50+
end
51+
52+
(ADAPTERS-['inline']).each do |adapter|
53+
Rake::TestTask.new("integration_test_#{adapter}") do |t|
54+
t.libs << 'test'
55+
t.test_files = FileList['test/integration/**/*_test.rb']
56+
t.verbose = true
57+
end
58+
59+
namespace "integration_#{adapter}" do
60+
task test: "integration_test_#{adapter}"
61+
task(:env) do
62+
ENV['AJADAPTER'] = adapter
63+
ENV['AJ_INTEGRATION_TESTS'] = "1"
64+
end
65+
end
66+
67+
task "integration_test_#{adapter}" => "integration_#{adapter}:env"
68+
end

lib/active_job/queue_adapters/sneakers_adapter.rb

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def enqueue_at(job, timestamp, *args)
2121

2222
class JobWrapper
2323
include Sneakers::Worker
24+
from_queue 'active_jobs_default'
2425

2526
def work(msg)
2627
job_name, *args = ActiveSupport::JSON.decode(msg)

test/dummy/Rakefile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require 'sneakers/tasks'
2+
require File.expand_path('../config/application', __FILE__)
3+
Rails.application.load_tasks

test/dummy/app/assets/images/.keep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class ApplicationController < ActionController::Base
2+
protect_from_forgery with: :exception
3+
end

test/dummy/app/controllers/concerns/.keep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ApplicationHelper
2+
end

test/dummy/app/jobs/test_job.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class TestJob < ActiveJob::Base
2+
queue_as :default
3+
4+
def perform(x)
5+
File.open(Rails.root.join("tmp/#{x}"), "w+") do |f|
6+
f.write x
7+
end
8+
end
9+
end

test/dummy/app/mailers/.keep

Whitespace-only changes.

test/dummy/app/models/.keep

Whitespace-only changes.

test/dummy/app/models/concerns/.keep

Whitespace-only changes.

test/dummy/config.ru

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This file is used by Rack-based servers to start the application.
2+
3+
require ::File.expand_path('../config/environment', __FILE__)
4+
run Rails.application

test/dummy/config/application.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require File.expand_path('../boot', __FILE__)
2+
require 'rails/all'
3+
Bundler.require(*Rails.groups)
4+
5+
module Dummy
6+
class Application < Rails::Application
7+
end
8+
end
9+

test/dummy/config/boot.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Set up gems listed in the Gemfile.
2+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3+
4+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5+
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)

test/dummy/config/database.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test:
2+
adapter: sqlite3
3+
database: "db/test.sqlite3"

test/dummy/config/environment.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require File.expand_path('../application', __FILE__)
2+
Rails.application.initialize!

0 commit comments

Comments
 (0)