resque-cluster 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/lib/resque/cluster/member.rb +8 -3
- data/lib/resque/cluster/version.rb +1 -1
- data/resque-cluster.gemspec +1 -1
- data/spec/integration/cluster_spec.rb +41 -0
- data/spec/integration/config/global_config3.yml +5 -0
- data/spec/integration/test_member_manager.rb +11 -0
- data/spec/unit/member_spec.rb +2 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8d180c93a32868cb57d270286bd124aaf24bab1
|
4
|
+
data.tar.gz: d12d96cb26be32e27adac81faa1b73362479a01b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b6170bedb0e3be27ab31e8692be4e377a1cc941b4f1d70dddd58b8eeb318825f808c5fde6796cd478b63820d014cbd832554bfb8099d2fbe9558df98beafe6c
|
7
|
+
data.tar.gz: 7c596a869b51618f4483e77526466f204f7cb2062acb2cd709de244eb294a9c20082b22f0befe5b8c1f3ed7f9c85cd35e5ecd0a5b216c3ac251954cfd3e76284
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
multi_json (>= 1.7.5, < 2.0)
|
24
24
|
nokogiri (~> 1.6.3)
|
25
25
|
oauth2
|
26
|
-
gru (0.0.
|
26
|
+
gru (0.0.8)
|
27
27
|
redis (> 0.0)
|
28
28
|
hashie (3.4.1)
|
29
29
|
highline (1.7.2)
|
@@ -121,7 +121,7 @@ PLATFORMS
|
|
121
121
|
DEPENDENCIES
|
122
122
|
awesome_print
|
123
123
|
bundler (~> 1.0)
|
124
|
-
gru (= 0.0.
|
124
|
+
gru (= 0.0.8)
|
125
125
|
jeweler (~> 2.0.1)
|
126
126
|
mock_redis (~> 0.15.0)
|
127
127
|
pry
|
@@ -51,12 +51,16 @@ module Resque
|
|
51
51
|
"#{member_prefix}:running_workers"
|
52
52
|
end
|
53
53
|
|
54
|
+
def ping_namespace
|
55
|
+
global_prefix + ":pings"
|
56
|
+
end
|
57
|
+
|
54
58
|
def ping
|
55
|
-
Resque.redis.hset(
|
59
|
+
Resque.redis.hset(ping_namespace, hostname, Time.now.utc)
|
56
60
|
end
|
57
61
|
|
58
62
|
def unping
|
59
|
-
Resque.redis.hdel(
|
63
|
+
Resque.redis.hdel(ping_namespace, hostname)
|
60
64
|
end
|
61
65
|
|
62
66
|
def initialize_gru
|
@@ -108,7 +112,8 @@ module Resque
|
|
108
112
|
client_settings: Resque.redis.client.options,
|
109
113
|
rebalance_flag: @global_config["rebalance_cluster"] || false,
|
110
114
|
cluster_name: Cluster.config[:cluster_name],
|
111
|
-
environment_name: Cluster.config[:environment]
|
115
|
+
environment_name: Cluster.config[:environment],
|
116
|
+
presume_host_dead_after: @global_config["presume_dead_after"] || 120
|
112
117
|
}
|
113
118
|
end
|
114
119
|
end
|
data/resque-cluster.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
s.add_dependency 'resque-pool', '~> 0.5.0'
|
22
|
-
s.add_dependency 'gru', '0.0.
|
22
|
+
s.add_dependency 'gru', '0.0.8'
|
23
23
|
|
24
24
|
s.add_development_dependency 'pry', '> 0.0'
|
25
25
|
s.add_development_dependency 'awesome_print', '> 0.0'
|
@@ -5,6 +5,7 @@ GLOBAL_CONFIG = "spec/integration/config/global_config.yml"
|
|
5
5
|
LOCAL_CONFIG2 = "spec/integration/config/local_config2.yml"
|
6
6
|
GLOBAL_CONFIG2 = "spec/integration/config/global_config2.yml"
|
7
7
|
GLOBAL_REBALANCE_CONFIG2 = "spec/integration/config/global_rebalance_config2.yml"
|
8
|
+
GLOBAL_CONFIG3 = "spec/integration/config/global_config3.yml"
|
8
9
|
|
9
10
|
RSpec.describe "Resque test-cluster" do
|
10
11
|
context "Spin Up and Down" do
|
@@ -178,4 +179,44 @@ RSpec.describe "Resque test-cluster" do
|
|
178
179
|
end
|
179
180
|
end
|
180
181
|
|
182
|
+
context "In case one member gets reaped, the cluster rebalances after assuming a member dead" do
|
183
|
+
before :all do
|
184
|
+
sleep 5
|
185
|
+
@a = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG3)
|
186
|
+
@b = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG3)
|
187
|
+
@c = TestMemberManager.new(LOCAL_CONFIG, GLOBAL_CONFIG3)
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'expects no workers to be running' do
|
191
|
+
expect(TestMemberManager.counts).to be_empty
|
192
|
+
expect(@a.counts).to be_empty
|
193
|
+
expect(@b.counts).to be_empty
|
194
|
+
expect(@c.counts).to be_empty
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'expects counts to be correct after workers get spun up' do
|
198
|
+
@a.start
|
199
|
+
@b.start
|
200
|
+
@c.start
|
201
|
+
expect(TestMemberManager.counts).to eq({"par"=>2, "tar"=>8, "par,tar,var"=>1})
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'cluster adjusts correctly when a member gets reaped' do
|
205
|
+
@a.kill
|
206
|
+
sleep(10)
|
207
|
+
expect(TestMemberManager.counts).to eq({"tar"=>6, "par"=>2, "par,tar,var"=>1})
|
208
|
+
expect(@a.counts).to be_empty
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'cluster rebalances correctly when the member gets brought back up' do
|
212
|
+
@a.start
|
213
|
+
expect(TestMemberManager.counts).to eq({"par"=>2, "tar"=>8, "par,tar,var"=>1})
|
214
|
+
end
|
215
|
+
|
216
|
+
after :all do
|
217
|
+
TestMemberManager.stop_all
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
|
181
222
|
end
|
@@ -33,6 +33,17 @@ class TestMemberManager
|
|
33
33
|
sleep(5)
|
34
34
|
end
|
35
35
|
|
36
|
+
def kill
|
37
|
+
puts "************************************************ About to kill -9 : Pool Master pid ---------- #{@pool_master_pid}"
|
38
|
+
`kill -9 #{@pool_master_pid}`
|
39
|
+
while ( @pool_master_pid ) do
|
40
|
+
pool = `ps -p #{@pool_master_pid} -hf | grep 'resque-pool-master\\[resque-cluster\\]: managing \\[' | awk '{print $1}'`.strip.to_i
|
41
|
+
@pool_master_pid = pool > 0 ? pool : nil
|
42
|
+
end
|
43
|
+
@pid = nil
|
44
|
+
sleep(5)
|
45
|
+
end
|
46
|
+
|
36
47
|
def counts
|
37
48
|
return {} unless @pool_master_pid
|
38
49
|
local_workers = `ps --ppid #{@pool_master_pid} -fh | awk '{print $8}'`.split
|
data/spec/unit/member_spec.rb
CHANGED
@@ -27,6 +27,7 @@ RSpec.describe Resque::Cluster::Member do
|
|
27
27
|
:host_maximums => {'foo' => 1, 'bar' => 9, "foo,bar,baz" => 1},
|
28
28
|
:client_settings => @redis.client.options,
|
29
29
|
:rebalance_flag => false,
|
30
|
+
:presume_host_dead_after => 120,
|
30
31
|
:cluster_name => "unit-test-cluster",
|
31
32
|
:environment_name => "unit-test"
|
32
33
|
}
|
@@ -51,7 +52,7 @@ RSpec.describe Resque::Cluster::Member do
|
|
51
52
|
end
|
52
53
|
|
53
54
|
it 'pings into redis to let the rest of the cluster know of it' do
|
54
|
-
expect(@redis.hget('resque:cluster:unit-test-cluster:unit-test', @@hostname)).to_not be_nil
|
55
|
+
expect(@redis.hget('resque:cluster:unit-test-cluster:unit-test:pings', @@hostname)).to_not be_nil
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-cluster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasha Portnoy
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.
|
33
|
+
version: 0.0.8
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0.
|
40
|
+
version: 0.0.8
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- spec/integration/cluster_spec.rb
|
195
195
|
- spec/integration/config/global_config.yml
|
196
196
|
- spec/integration/config/global_config2.yml
|
197
|
+
- spec/integration/config/global_config3.yml
|
197
198
|
- spec/integration/config/global_rebalance_config2.yml
|
198
199
|
- spec/integration/config/local_config.yml
|
199
200
|
- spec/integration/config/local_config2.yml
|
@@ -236,6 +237,7 @@ test_files:
|
|
236
237
|
- spec/integration/cluster_spec.rb
|
237
238
|
- spec/integration/config/global_config.yml
|
238
239
|
- spec/integration/config/global_config2.yml
|
240
|
+
- spec/integration/config/global_config3.yml
|
239
241
|
- spec/integration/config/global_rebalance_config2.yml
|
240
242
|
- spec/integration/config/local_config.yml
|
241
243
|
- spec/integration/config/local_config2.yml
|