zk 1.9.6 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/.github/workflows/build.yml +55 -0
- data/Gemfile +15 -6
- data/README.markdown +9 -9
- data/RELEASES.markdown +10 -1
- data/lib/zk/client.rb +1 -1
- data/lib/zk/event_handler.rb +15 -7
- data/lib/zk/fork_hook.rb +2 -2
- data/lib/zk/locker/locker_base.rb +13 -0
- data/lib/zk/locker/semaphore.rb +1 -3
- data/lib/zk/node_deletion_watcher.rb +3 -4
- data/lib/zk/pool.rb +11 -11
- data/lib/zk/version.rb +1 -1
- data/spec/event_catcher_spec.rb +1 -1
- data/spec/message_queue_spec.rb +6 -6
- data/spec/shared/client_examples.rb +81 -81
- data/spec/shared/locker_examples.rb +13 -13
- data/spec/spec_helper.rb +10 -11
- data/spec/zk/00_forked_client_integration_spec.rb +3 -3
- data/spec/zk/client/locking_and_session_death_spec.rb +2 -2
- data/spec/zk/client_spec.rb +19 -19
- data/spec/zk/election_spec.rb +44 -44
- data/spec/zk/extensions_spec.rb +2 -2
- data/spec/zk/locker/exclusive_locker_spec.rb +41 -41
- data/spec/zk/locker/locker_basic_spec.rb +55 -33
- data/spec/zk/locker/semaphore_spec.rb +39 -32
- data/spec/zk/locker/shared_exclusive_integration_spec.rb +37 -37
- data/spec/zk/locker/shared_locker_spec.rb +43 -43
- data/spec/zk/locker_spec.rb +2 -2
- data/spec/zk/module_spec.rb +25 -25
- data/spec/zk/mongoid_spec.rb +47 -47
- data/spec/zk/node_deletion_watcher_spec.rb +39 -31
- data/spec/zk/pool_spec.rb +56 -65
- data/spec/zk/threaded_callback_spec.rb +10 -10
- data/spec/zk/threadpool_spec.rb +25 -25
- data/spec/zk/watch_spec.rb +67 -79
- data/spec/zk/zookeeper_spec.rb +31 -31
- data/zk.gemspec +1 -1
- metadata +23 -24
- data/.travis.yml +0 -30
data/spec/zk/client_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe ZK::Client::Threaded do
|
|
21
21
|
it %[should do the right thing and not fail] do
|
22
22
|
# this is an extra special case where the user obviously hates us
|
23
23
|
|
24
|
-
@zk.
|
24
|
+
expect(@zk).to be_kind_of(ZK::Client::Threaded) # yeah yeah, just be sure
|
25
25
|
|
26
26
|
shutdown_thread = nil
|
27
27
|
|
@@ -31,17 +31,17 @@ describe ZK::Client::Threaded do
|
|
31
31
|
|
32
32
|
wait_while { shutdown_thread.nil? }
|
33
33
|
|
34
|
-
shutdown_thread.
|
35
|
-
shutdown_thread.
|
34
|
+
expect(shutdown_thread).not_to be_nil
|
35
|
+
expect(shutdown_thread).to be_kind_of(Thread)
|
36
36
|
|
37
|
-
shutdown_thread.join(5).
|
37
|
+
expect(shutdown_thread.join(5)).to eq(shutdown_thread)
|
38
38
|
|
39
|
-
wait_until(5) { @zk.closed? }.
|
39
|
+
expect(wait_until(5) { @zk.closed? }).to be(true)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
describe :reopen do
|
44
|
+
describe :reopen, :jruby => :broken do
|
45
45
|
include_context 'connection opts'
|
46
46
|
|
47
47
|
before do
|
@@ -53,15 +53,15 @@ describe ZK::Client::Threaded do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it %[should say the client is connected after reopen] do
|
56
|
-
@zk.connected
|
56
|
+
expect(@zk.connected?).to eq(true)
|
57
57
|
|
58
58
|
@zk.close!
|
59
59
|
|
60
|
-
@zk.connected
|
60
|
+
expect(@zk.connected?).to eq(false)
|
61
61
|
|
62
62
|
@zk.reopen
|
63
63
|
|
64
|
-
@zk.connected
|
64
|
+
expect(@zk.connected?).to eq(true)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -80,7 +80,7 @@ describe ZK::Client::Threaded do
|
|
80
80
|
# TODO: this is a terrible test. there is no way to guarantee that this
|
81
81
|
# has been retried. the join at the end should not raise an error
|
82
82
|
|
83
|
-
@zk.
|
83
|
+
expect(@zk).not_to be_connected
|
84
84
|
|
85
85
|
th = Thread.new do
|
86
86
|
@zk.stat('/path/to/blah', :retry_duration => 30)
|
@@ -89,11 +89,11 @@ describe ZK::Client::Threaded do
|
|
89
89
|
th.run
|
90
90
|
|
91
91
|
@zk.connect
|
92
|
-
th.join(5).
|
92
|
+
expect(th.join(5)).to eq(th)
|
93
93
|
end
|
94
94
|
|
95
95
|
it %[barfs if the connection is closed before the connected event is received] do
|
96
|
-
@zk.
|
96
|
+
expect(@zk).not_to be_connected
|
97
97
|
|
98
98
|
exc = nil
|
99
99
|
|
@@ -110,14 +110,14 @@ describe ZK::Client::Threaded do
|
|
110
110
|
|
111
111
|
@zk.close!
|
112
112
|
|
113
|
-
th.join(5).
|
113
|
+
expect(th.join(5)).to eq(th)
|
114
114
|
|
115
|
-
exc.
|
116
|
-
exc.
|
115
|
+
expect(exc).not_to be_nil
|
116
|
+
expect(exc).to be_kind_of(ZK::Exceptions::Retryable)
|
117
117
|
end
|
118
118
|
|
119
119
|
it %[should barf if the timeout expires] do
|
120
|
-
@zk.
|
120
|
+
expect(@zk).not_to be_connected
|
121
121
|
|
122
122
|
exc = nil
|
123
123
|
|
@@ -132,10 +132,10 @@ describe ZK::Client::Threaded do
|
|
132
132
|
|
133
133
|
th.run
|
134
134
|
|
135
|
-
th.join(5).
|
135
|
+
expect(th.join(5)).to eq(th)
|
136
136
|
|
137
|
-
exc.
|
138
|
-
exc.
|
137
|
+
expect(exc).not_to be_nil
|
138
|
+
expect(exc).to be_kind_of(ZK::Exceptions::Retryable)
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end # ZK::Client::Threaded
|
data/spec/zk/election_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe ZK::Election, :jruby => :broken do
|
|
4
4
|
include_context 'connection opts'
|
5
5
|
|
6
6
|
before do
|
7
|
-
ZK.open(connection_host) do |cnx|
|
7
|
+
ZK.open(connection_host) do |cnx|
|
8
8
|
logger.debug { "REMOVING /_zkelection" }
|
9
9
|
cnx.rm_rf('/_zkelection')
|
10
10
|
end
|
@@ -56,8 +56,8 @@ describe ZK::Election, :jruby => :broken do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
@palin.on_losing_election do
|
59
|
-
@obama_won.
|
60
|
-
@palin.leader_acked
|
59
|
+
expect(@obama_won).to be(true)
|
60
|
+
expect(@palin.leader_acked?).to be(true)
|
61
61
|
@palin_lost = true
|
62
62
|
end
|
63
63
|
|
@@ -68,21 +68,21 @@ describe ZK::Election, :jruby => :broken do
|
|
68
68
|
oth.run
|
69
69
|
|
70
70
|
wait_until { @obama_waiting }
|
71
|
-
@obama_waiting.
|
71
|
+
expect(@obama_waiting).to be(true)
|
72
72
|
|
73
73
|
# palin's callbacks haven't fired
|
74
|
-
@palin_lost.
|
74
|
+
expect(@palin_lost).to be_nil
|
75
75
|
|
76
76
|
latch.release
|
77
77
|
|
78
78
|
wait_until { @obama_won }
|
79
|
-
@obama_won.
|
79
|
+
expect(@obama_won).to be(true)
|
80
80
|
|
81
|
-
|
81
|
+
expect { expect(oth.join(1)).to eq(oth) }.not_to raise_error
|
82
82
|
|
83
83
|
wait_until { @palin_lost }
|
84
84
|
|
85
|
-
@palin_lost.
|
85
|
+
expect(@palin_lost).to be(true)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -92,7 +92,7 @@ describe ZK::Election, :jruby => :broken do
|
|
92
92
|
@obama_won = @obama_lost = @palin_won = @palin_lost = nil
|
93
93
|
win_latch, lose_latch = Latch.new, Latch.new
|
94
94
|
|
95
|
-
@obama.on_winning_election do
|
95
|
+
@obama.on_winning_election do
|
96
96
|
logger.debug { "obama on_winning_election fired" }
|
97
97
|
@obama_won = true
|
98
98
|
win_latch.release
|
@@ -115,50 +115,50 @@ describe ZK::Election, :jruby => :broken do
|
|
115
115
|
@palin_lost = true
|
116
116
|
lose_latch.release
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
@obama.vote!
|
120
120
|
@palin.vote!
|
121
121
|
|
122
122
|
win_latch.await
|
123
|
-
@obama_won.
|
123
|
+
expect(@obama_won).to be(true)
|
124
124
|
|
125
125
|
lose_latch.await
|
126
|
-
@palin_lost.
|
126
|
+
expect(@palin_lost).to be(true)
|
127
127
|
end
|
128
128
|
|
129
129
|
describe 'winner' do
|
130
130
|
it %[should fire the on_winning_election callbacks] do
|
131
|
-
@obama_won.
|
131
|
+
expect(@obama_won).to be(true)
|
132
132
|
end
|
133
133
|
|
134
134
|
it %[should not fire the on_losing_election callbacks] do
|
135
|
-
@obama_lost.
|
135
|
+
expect(@obama_lost).to be_nil
|
136
136
|
end
|
137
137
|
|
138
138
|
it %[should acknowledge completion of winning callbacks] do
|
139
|
-
@zk.exists?(@obama.leader_ack_path).
|
139
|
+
expect(@zk.exists?(@obama.leader_ack_path)).to be(true)
|
140
140
|
end
|
141
141
|
|
142
142
|
it %[should write its data to the leader_ack node] do
|
143
|
-
@zk.get(@obama.leader_ack_path).first.
|
143
|
+
expect(@zk.get(@obama.leader_ack_path).first).to eq(@data1)
|
144
144
|
end
|
145
145
|
|
146
146
|
it %[should know it's the leader] do
|
147
|
-
@obama.
|
147
|
+
expect(@obama).to be_leader
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
151
|
describe 'loser' do # gets a talk show on Fox News? I KEED! I KEED!
|
152
152
|
it %[should know it isn't the leader] do
|
153
|
-
@palin.
|
153
|
+
expect(@palin).not_to be_leader
|
154
154
|
end
|
155
155
|
|
156
156
|
it %[should not fire the winning callbacks] do
|
157
|
-
@palin_won.
|
157
|
+
expect(@palin_won).not_to be(true)
|
158
158
|
end
|
159
159
|
|
160
160
|
it %[should fire the losing callbacks] do
|
161
|
-
@palin_lost.
|
161
|
+
expect(@palin_lost).to be(true)
|
162
162
|
end
|
163
163
|
|
164
164
|
it %[should take over as leader when the current leader goes away] do
|
@@ -167,13 +167,13 @@ describe ZK::Election, :jruby => :broken do
|
|
167
167
|
@obama.zk.close!
|
168
168
|
wait_until { @palin_won }
|
169
169
|
|
170
|
-
@palin_won.
|
170
|
+
expect(@palin_won).to be(true) # god forbid
|
171
171
|
|
172
172
|
wait_until { @zk2.exists?(@palin.leader_ack_path) }
|
173
173
|
|
174
|
-
@zk2.exists?(@palin.leader_ack_path).
|
174
|
+
expect(@zk2.exists?(@palin.leader_ack_path)).to be(true)
|
175
175
|
|
176
|
-
@zk2.get(@palin.leader_ack_path).first.
|
176
|
+
expect(@zk2.get(@palin.leader_ack_path).first).to eq(@data2)
|
177
177
|
end
|
178
178
|
|
179
179
|
it %[should remain leader if the original leader comes back] do
|
@@ -193,9 +193,9 @@ describe ZK::Election, :jruby => :broken do
|
|
193
193
|
newbama.vote!
|
194
194
|
wait_until { newbama.voted? }
|
195
195
|
|
196
|
-
newbama.
|
197
|
-
win_again.
|
198
|
-
newbama.
|
196
|
+
expect(newbama).to be_voted
|
197
|
+
expect(win_again).to be(false)
|
198
|
+
expect(newbama).not_to be_leader
|
199
199
|
end
|
200
200
|
end
|
201
201
|
end
|
@@ -207,12 +207,12 @@ describe ZK::Election, :jruby => :broken do
|
|
207
207
|
before do
|
208
208
|
@zk3 = ZK.new(*connection_args)
|
209
209
|
|
210
|
-
@zk3.exists?('/_zkelection/2012/leader_ack').
|
210
|
+
expect(@zk3.exists?('/_zkelection/2012/leader_ack')).to be(false)
|
211
211
|
|
212
212
|
@obama = ZK::Election::Candidate.new(@zk, @election_name, :data => @data1)
|
213
213
|
@palin = ZK::Election::Candidate.new(@zk2, @election_name, :data => @data2)
|
214
214
|
|
215
|
-
@zk3.exists?('/_zkelection/2012/leader_ack').
|
215
|
+
expect(@zk3.exists?('/_zkelection/2012/leader_ack')).to be(false)
|
216
216
|
|
217
217
|
@observer = ZK::Election::Observer.new(@zk3, @election_name)
|
218
218
|
end
|
@@ -231,17 +231,17 @@ describe ZK::Election, :jruby => :broken do
|
|
231
231
|
|
232
232
|
@observer.observe!
|
233
233
|
wait_until { !@observer.leader_alive.nil? }
|
234
|
-
@observer.leader_alive.
|
235
|
-
@zk3.exists?(@observer.root_election_node).
|
234
|
+
expect(@observer.leader_alive).not_to be_nil
|
235
|
+
expect(@zk3.exists?(@observer.root_election_node)).to be(false)
|
236
236
|
end
|
237
237
|
|
238
238
|
it %[should set leader_alive to false] do
|
239
|
-
@observer.leader_alive.
|
239
|
+
expect(@observer.leader_alive).to be(false)
|
240
240
|
end
|
241
241
|
|
242
242
|
it %[should fire death callbacks] do
|
243
|
-
@events.length.
|
244
|
-
@events.first.
|
243
|
+
expect(@events.length).to eq(1)
|
244
|
+
expect(@events.first).to eq(:death)
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
@@ -263,19 +263,19 @@ describe ZK::Election, :jruby => :broken do
|
|
263
263
|
end
|
264
264
|
|
265
265
|
it %[should be obama that won] do
|
266
|
-
@obama.
|
266
|
+
expect(@obama).to be_leader
|
267
267
|
end
|
268
268
|
|
269
269
|
it %[should be palin that lost] do
|
270
|
-
@palin.
|
270
|
+
expect(@palin).not_to be_leader
|
271
271
|
end
|
272
272
|
|
273
273
|
it %[should set leader_alive to true] do
|
274
|
-
@observer.leader_alive.
|
274
|
+
expect(@observer.leader_alive).to be(true)
|
275
275
|
end
|
276
276
|
|
277
277
|
it %[should fire the new leader callbacks] do
|
278
|
-
@got_life_event.
|
278
|
+
expect(@got_life_event).to be(true)
|
279
279
|
end
|
280
280
|
end
|
281
281
|
|
@@ -286,7 +286,7 @@ describe ZK::Election, :jruby => :broken do
|
|
286
286
|
wait_until { @obama.leader? }
|
287
287
|
|
288
288
|
@palin.vote!
|
289
|
-
@palin.
|
289
|
+
expect(@palin).not_to be_leader
|
290
290
|
|
291
291
|
@got_life_event = @got_death_event = false
|
292
292
|
|
@@ -297,23 +297,23 @@ describe ZK::Election, :jruby => :broken do
|
|
297
297
|
|
298
298
|
wait_until { !@observer.leader_alive.nil? }
|
299
299
|
|
300
|
-
@observer.leader_alive.
|
300
|
+
expect(@observer.leader_alive).to be(true)
|
301
301
|
@zk.close!
|
302
302
|
wait_until { !@zk.connected? && @palin.leader? && @palin.leader_acked? }
|
303
303
|
end
|
304
304
|
|
305
305
|
it %[should be palin who is leader] do
|
306
|
-
@palin.
|
306
|
+
expect(@palin).to be_leader
|
307
307
|
end
|
308
308
|
|
309
309
|
it %[should have seen both the death and life events] do
|
310
|
-
pending 'this test is flapping'
|
311
|
-
@got_life_event.
|
312
|
-
@got_death_event.
|
310
|
+
# pending 'this test is flapping'
|
311
|
+
expect(@got_life_event).to be(true)
|
312
|
+
expect(@got_death_event).to be(true)
|
313
313
|
end
|
314
314
|
|
315
315
|
it %[should see the data of the new leader] do
|
316
|
-
@observer.leader_data.
|
316
|
+
expect(@observer.leader_data).to eq('palin')
|
317
317
|
end
|
318
318
|
end
|
319
319
|
end
|
data/spec/zk/extensions_spec.rb
CHANGED
@@ -6,8 +6,8 @@ module ZK
|
|
6
6
|
|
7
7
|
it %[should not barf if backtrace is nil] do
|
8
8
|
exc = StandardError.new
|
9
|
-
exc.backtrace.
|
10
|
-
|
9
|
+
expect(exc.backtrace).to be_nil
|
10
|
+
expect { exc.to_std_format }.not_to raise_error
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -9,13 +9,13 @@ shared_examples_for 'ZK::Locker::ExclusiveLocker' do
|
|
9
9
|
|
10
10
|
it %[should raise LockAssertionFailedError if there is an exclusive lock with a number lower than ours] do
|
11
11
|
# this should *really* never happen
|
12
|
-
|
12
|
+
|
13
13
|
rlp = locker.root_lock_path
|
14
14
|
|
15
15
|
zk.mkdir_p(rlp)
|
16
16
|
|
17
17
|
bogus_path = zk.create("#{rlp}/#{ZK::Locker::EXCLUSIVE_LOCK_PREFIX}", :sequential => true, :ephemeral => true)
|
18
|
-
logger.debug { "bogus_path: #{bogus_path.inspect}" }
|
18
|
+
logger.debug { "bogus_path: #{bogus_path.inspect}" }
|
19
19
|
|
20
20
|
th = Thread.new do
|
21
21
|
locker.lock(true)
|
@@ -24,40 +24,40 @@ shared_examples_for 'ZK::Locker::ExclusiveLocker' do
|
|
24
24
|
th.run
|
25
25
|
|
26
26
|
logger.debug { "calling wait_until_blocked" }
|
27
|
-
|
27
|
+
expect { locker.wait_until_blocked(5) }.not_to raise_error
|
28
28
|
logger.debug { "wait_until_blocked returned" }
|
29
|
-
locker.
|
29
|
+
expect(locker).to be_waiting
|
30
30
|
|
31
31
|
wait_until { zk.exists?(locker.lock_path) }
|
32
32
|
|
33
|
-
zk.exists?(locker.lock_path).
|
33
|
+
expect(zk.exists?(locker.lock_path)).to be(true)
|
34
34
|
|
35
35
|
zk.delete(bogus_path)
|
36
36
|
|
37
|
-
th.join(5).
|
37
|
+
expect(th.join(5)).to eq(th)
|
38
38
|
|
39
|
-
locker.lock_path.
|
39
|
+
expect(locker.lock_path).not_to eq(bogus_path)
|
40
40
|
|
41
41
|
zk.create(bogus_path, :ephemeral => true)
|
42
42
|
|
43
|
-
|
43
|
+
expect { locker.assert! }.to raise_error(ZK::Exceptions::LockAssertionFailedError)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe :acquirable? do
|
48
48
|
it %[should work if the lock root doesn't exist] do
|
49
49
|
zk.rm_rf(ZK::Locker.default_root_lock_node)
|
50
|
-
locker.
|
50
|
+
expect(locker).to be_acquirable
|
51
51
|
end
|
52
52
|
|
53
53
|
it %[should check local state of lockedness] do
|
54
|
-
locker.lock.
|
55
|
-
locker.
|
54
|
+
expect(locker.lock).to be(true)
|
55
|
+
expect(locker).to be_acquirable
|
56
56
|
end
|
57
57
|
|
58
58
|
it %[should check if any participants would prevent us from acquiring the lock] do
|
59
|
-
locker.lock.
|
60
|
-
locker2.
|
59
|
+
expect(locker.lock).to be(true)
|
60
|
+
expect(locker2).not_to be_acquirable
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -69,16 +69,16 @@ shared_examples_for 'ZK::Locker::ExclusiveLocker' do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it %[should acquire the first lock] do
|
72
|
-
@rval.
|
72
|
+
expect(@rval).to be(true)
|
73
73
|
end
|
74
74
|
|
75
75
|
it %[should not acquire the second lock] do
|
76
|
-
@rval2.
|
76
|
+
expect(@rval2).to be(false)
|
77
77
|
end
|
78
78
|
|
79
79
|
it %[should acquire the second lock after the first lock is released] do
|
80
|
-
locker.unlock.
|
81
|
-
locker2.lock.
|
80
|
+
expect(locker.unlock).to be(true)
|
81
|
+
expect(locker2.lock).to be(true)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -95,7 +95,7 @@ shared_examples_for 'ZK::Locker::ExclusiveLocker' do
|
|
95
95
|
it %[should block waiting for the lock with old style lock semantics] do
|
96
96
|
ary = []
|
97
97
|
|
98
|
-
locker.lock.
|
98
|
+
expect(locker.lock).to be(false)
|
99
99
|
|
100
100
|
th = Thread.new do
|
101
101
|
locker.lock(true)
|
@@ -103,22 +103,22 @@ shared_examples_for 'ZK::Locker::ExclusiveLocker' do
|
|
103
103
|
end
|
104
104
|
|
105
105
|
locker.wait_until_blocked(5)
|
106
|
-
|
107
|
-
ary.
|
108
|
-
locker.
|
106
|
+
|
107
|
+
expect(ary).to be_empty
|
108
|
+
expect(locker).not_to be_locked
|
109
109
|
|
110
110
|
zk.delete(@read_lock_path)
|
111
111
|
|
112
|
-
th.join(2).
|
112
|
+
expect(th.join(2)).to eq(th)
|
113
113
|
|
114
|
-
ary.length.
|
115
|
-
locker.
|
114
|
+
expect(ary.length).to eq(1)
|
115
|
+
expect(locker).to be_locked
|
116
116
|
end
|
117
117
|
|
118
118
|
it %[should block waiting for the lock with new style lock semantics] do
|
119
119
|
ary = []
|
120
120
|
|
121
|
-
locker.lock.
|
121
|
+
expect(locker.lock).to be(false)
|
122
122
|
|
123
123
|
th = Thread.new do
|
124
124
|
locker.lock(:wait => true)
|
@@ -126,24 +126,24 @@ shared_examples_for 'ZK::Locker::ExclusiveLocker' do
|
|
126
126
|
end
|
127
127
|
|
128
128
|
locker.wait_until_blocked(5)
|
129
|
-
|
130
|
-
ary.
|
131
|
-
locker.
|
129
|
+
|
130
|
+
expect(ary).to be_empty
|
131
|
+
expect(locker).not_to be_locked
|
132
132
|
|
133
133
|
zk.delete(@read_lock_path)
|
134
134
|
|
135
|
-
th.join(2).
|
135
|
+
expect(th.join(2)).to eq(th)
|
136
136
|
|
137
|
-
ary.length.
|
138
|
-
locker.
|
137
|
+
expect(ary.length).to eq(1)
|
138
|
+
expect(locker).to be_locked
|
139
139
|
end
|
140
140
|
|
141
141
|
it %[should time out waiting for the lock] do
|
142
142
|
ary = []
|
143
143
|
|
144
|
-
zk.children(lock_path_base).length.
|
144
|
+
expect(zk.children(lock_path_base).length).to eq(1)
|
145
145
|
|
146
|
-
locker.lock.
|
146
|
+
expect(locker.lock).to be(false)
|
147
147
|
|
148
148
|
th = Thread.new do
|
149
149
|
begin
|
@@ -155,17 +155,17 @@ shared_examples_for 'ZK::Locker::ExclusiveLocker' do
|
|
155
155
|
end
|
156
156
|
|
157
157
|
locker.wait_until_blocked(5)
|
158
|
-
|
159
|
-
ary.should be_empty
|
160
|
-
locker.should_not be_locked
|
161
158
|
|
162
|
-
|
159
|
+
expect(ary).to be_empty
|
160
|
+
expect(locker).not_to be_locked
|
161
|
+
|
162
|
+
expect(th.join(2)).to eq(th)
|
163
163
|
|
164
|
-
zk.children(lock_path_base).length.
|
164
|
+
expect(zk.children(lock_path_base).length).to eq(1)
|
165
165
|
|
166
|
-
ary.
|
167
|
-
@exc.
|
168
|
-
@exc.
|
166
|
+
expect(ary).to be_empty
|
167
|
+
expect(@exc).not_to be_nil
|
168
|
+
expect(@exc).to be_kind_of(ZK::Exceptions::LockWaitTimeoutError)
|
169
169
|
end
|
170
170
|
end # blocking
|
171
171
|
end # lock
|