coney_island 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coney_island/version.rb +1 -1
- data/lib/coney_island/worker.rb +1 -1
- data/test/coney_island_test.rb +1 -1
- data/test/submitter_test.rb +24 -22
- data/test/worker_test.rb +42 -40
- metadata +2 -6
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf90adcd9f29187fbfd2e7733e1c3a258ad34553
|
4
|
+
data.tar.gz: 91b6851a230f62ba75e28d6508a19c3877eac52b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a36841285a8c2c42f4cbb77d950d98d4feebe418e5b5b67604ae49d6d58a6eb4b2145920c63c3fd1f7359fd81ceddd9bf8199c5eb4dd13c95a0f4d45382a410f
|
7
|
+
data.tar.gz: 35e57d874f72ccb0871fafded99c2316ba073c2f35d782f39b2fd0a45eb6c57b4b9e12a666579497c1c10ed4c6993dbe5292425da6c1be7f885f54db3701d0ca
|
data/lib/coney_island/version.rb
CHANGED
data/lib/coney_island/worker.rb
CHANGED
@@ -30,7 +30,7 @@ module ConeyIsland
|
|
30
30
|
@log_io = self.config[:log]
|
31
31
|
self.log = Logger.new(@log_io)
|
32
32
|
|
33
|
-
@instance_config = self.config[:carousels][@ticket]
|
33
|
+
@instance_config = self.config[:carousels][@ticket.to_sym]
|
34
34
|
|
35
35
|
@prefetch_count = @instance_config[:prefetch_count] if @instance_config
|
36
36
|
@prefetch_count ||= 20
|
data/test/coney_island_test.rb
CHANGED
data/test/submitter_test.rb
CHANGED
@@ -1,33 +1,35 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class SubmitterTest < MiniTest::Test
|
4
|
-
describe "
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
ConeyIsland::
|
10
|
-
|
4
|
+
describe "ConeyIsland::Submitter" do
|
5
|
+
describe "running jobs inline" do
|
6
|
+
it "calls the worker directly" do
|
7
|
+
@execute_job_method = Minitest::Mock.new
|
8
|
+
@execute_job_method.expect :call, nil, [Hash]
|
9
|
+
ConeyIsland::Worker.stub(:execute_job_method,@execute_job_method) do
|
10
|
+
ConeyIsland::Submitter.run_inline
|
11
|
+
ConeyIsland::Submitter.submit(TestModel, :add_to_list, args: [[]])
|
12
|
+
end
|
13
|
+
@execute_job_method.verify
|
11
14
|
end
|
12
|
-
@execute_job_method.verify
|
13
15
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
describe "running jobs in the background" do
|
17
|
+
it "publishes the job to the message bus" do
|
18
|
+
@exchange = Minitest::Mock.new
|
19
|
+
@exchange.expect :publish, nil, [String,Hash]
|
20
|
+
@next_tick = Minitest::Mock.new
|
21
|
+
@next_tick.expect :call, nil, []
|
22
|
+
EventMachine.stub(:next_tick, @next_tick) do
|
23
|
+
ConeyIsland::Submitter.stub(:handle_connection, nil) do
|
24
|
+
ConeyIsland::Submitter.stub(:exchange, @exchange) do
|
25
|
+
ConeyIsland::Submitter.stop_running_inline
|
26
|
+
ConeyIsland::Submitter.submit(TestModel, :add_to_list, args: [[]])
|
27
|
+
end
|
26
28
|
end
|
27
29
|
end
|
30
|
+
@next_tick.verify
|
31
|
+
@exchange.verify
|
28
32
|
end
|
29
|
-
@next_tick.verify
|
30
|
-
@exchange.verify
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
data/test/worker_test.rb
CHANGED
@@ -1,51 +1,53 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class WorkerTest < MiniTest::Test
|
4
|
-
describe "
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
it "handles timeouts with 3 retries before bailing out" do
|
10
|
-
ConeyIsland::Worker.job_attempts['my_job_id'] = 1
|
11
|
-
ConeyIsland::Worker.job_attempts.stub(:delete,nil) do
|
12
|
-
ConeyIsland::Worker.handle_job(@metadata,{
|
13
|
-
'klass' => 'TestModel',
|
14
|
-
'method_name' => :take_too_long,
|
15
|
-
'timeout' => 0.01
|
16
|
-
},'my_job_id')
|
4
|
+
describe "ConeyIsland::Worker" do
|
5
|
+
describe "handling jobs" do
|
6
|
+
before do
|
7
|
+
@metadata = MiniTest::Mock.new
|
8
|
+
@metadata.expect :ack, nil
|
17
9
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
10
|
+
it "handles timeouts with 3 retries before bailing out" do
|
11
|
+
ConeyIsland::Worker.job_attempts['my_job_id'] = 1
|
12
|
+
ConeyIsland::Worker.job_attempts.stub(:delete,nil) do
|
13
|
+
ConeyIsland::Worker.handle_job(@metadata,{
|
14
|
+
'klass' => 'TestModel',
|
15
|
+
'method_name' => :take_too_long,
|
16
|
+
'timeout' => 0.01
|
17
|
+
},'my_job_id')
|
18
|
+
end
|
19
|
+
ConeyIsland::Worker.job_attempts['my_job_id'].must_equal 3
|
20
|
+
end
|
21
|
+
it "sends other exeptions to a notification service" do
|
22
|
+
@poke_the_badger = MiniTest::Mock.new
|
23
|
+
@poke_the_badger.expect :call, nil, [Exception,Hash]
|
24
|
+
ConeyIsland::Worker.stub(:poke_the_badger,@poke_the_badger) do
|
25
|
+
ConeyIsland::Worker.handle_job(@metadata,{
|
26
|
+
'klass' => 'TestModel',
|
27
|
+
'method_name' => :throw_an_error
|
28
|
+
},'my_job_id')
|
29
|
+
end
|
30
|
+
@poke_the_badger.verify
|
31
|
+
end
|
32
|
+
it "calls find on the submitted class if an instance_id is present" do
|
33
|
+
TestModel.new('id' => 'my_id')
|
24
34
|
ConeyIsland::Worker.handle_job(@metadata,{
|
25
35
|
'klass' => 'TestModel',
|
26
|
-
'method_name' => :
|
36
|
+
'method_name' => :set_color,
|
37
|
+
'instance_id' => 'my_id',
|
38
|
+
'args' => ['green']
|
27
39
|
},'my_job_id')
|
40
|
+
my_thing = TestModel.find('my_id')
|
41
|
+
my_thing.color.must_equal 'green'
|
42
|
+
end
|
43
|
+
it "acknowledges job completion to the message bus" do
|
44
|
+
ConeyIsland::Worker.handle_job(@metadata,
|
45
|
+
{ 'klass' => 'TestModel',
|
46
|
+
'method_name' => :add_to_list,
|
47
|
+
'args' => [[]]},
|
48
|
+
'my_job_id')
|
49
|
+
@metadata.verify
|
28
50
|
end
|
29
|
-
@poke_the_badger.verify
|
30
|
-
end
|
31
|
-
it "calls find on the submitted class if an instance_id is present" do
|
32
|
-
TestModel.new('id' => 'my_id')
|
33
|
-
ConeyIsland::Worker.handle_job(@metadata,{
|
34
|
-
'klass' => 'TestModel',
|
35
|
-
'method_name' => :set_color,
|
36
|
-
'instance_id' => 'my_id',
|
37
|
-
'args' => ['green']
|
38
|
-
},'my_job_id')
|
39
|
-
my_thing = TestModel.find('my_id')
|
40
|
-
my_thing.color.must_equal 'green'
|
41
|
-
end
|
42
|
-
it "acknowledges job completion to the message bus" do
|
43
|
-
ConeyIsland::Worker.handle_job(@metadata,
|
44
|
-
{ 'klass' => 'TestModel',
|
45
|
-
'method_name' => :add_to_list,
|
46
|
-
'args' => [[]]},
|
47
|
-
'my_job_id')
|
48
|
-
@metadata.verify
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coney_island
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Draut
|
@@ -144,8 +144,6 @@ files:
|
|
144
144
|
- test/dummy/config/locales/en.yml
|
145
145
|
- test/dummy/config/routes.rb
|
146
146
|
- test/dummy/config/secrets.yml
|
147
|
-
- test/dummy/db/test.sqlite3
|
148
|
-
- test/dummy/log/test.log
|
149
147
|
- test/dummy/public/404.html
|
150
148
|
- test/dummy/public/422.html
|
151
149
|
- test/dummy/public/500.html
|
@@ -153,7 +151,7 @@ files:
|
|
153
151
|
- test/submitter_test.rb
|
154
152
|
- test/test_helper.rb
|
155
153
|
- test/worker_test.rb
|
156
|
-
homepage:
|
154
|
+
homepage: http://edraut.github.io/coney_island/
|
157
155
|
licenses:
|
158
156
|
- MIT
|
159
157
|
metadata: {}
|
@@ -209,8 +207,6 @@ test_files:
|
|
209
207
|
- test/dummy/config/routes.rb
|
210
208
|
- test/dummy/config/secrets.yml
|
211
209
|
- test/dummy/config.ru
|
212
|
-
- test/dummy/db/test.sqlite3
|
213
|
-
- test/dummy/log/test.log
|
214
210
|
- test/dummy/public/404.html
|
215
211
|
- test/dummy/public/422.html
|
216
212
|
- test/dummy/public/500.html
|
data/test/dummy/db/test.sqlite3
DELETED
File without changes
|
data/test/dummy/log/test.log
DELETED
File without changes
|