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/watch_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe ZK do
|
|
17
17
|
after do
|
18
18
|
mute_logger do
|
19
19
|
if @zk.connected?
|
20
|
-
@zk.close!
|
20
|
+
@zk.close!
|
21
21
|
wait_until { !@zk.connected? }
|
22
22
|
end
|
23
23
|
|
@@ -33,29 +33,29 @@ describe ZK do
|
|
33
33
|
locker.synchronize do
|
34
34
|
callback_called = true
|
35
35
|
end
|
36
|
-
event.path.
|
36
|
+
expect(event.path).to eq(@path)
|
37
37
|
end
|
38
38
|
|
39
39
|
@zk.exists?(@path, :watch => true)
|
40
40
|
@zk.create(@path, "", :mode => :ephemeral)
|
41
41
|
|
42
42
|
wait_until(5) { locker.synchronize { callback_called } }
|
43
|
-
callback_called.
|
43
|
+
expect(callback_called).to be(true)
|
44
44
|
end
|
45
45
|
|
46
46
|
describe :regression do
|
47
|
-
before do
|
48
|
-
|
49
|
-
end
|
47
|
+
# before do
|
48
|
+
# pending_in_travis("these tests take too long or time out")
|
49
|
+
# end
|
50
50
|
|
51
|
-
# this is stupid, and a bad test, but we have to check that events
|
52
|
-
# don't get re-delivered to a single registered callback just because
|
51
|
+
# this is stupid, and a bad test, but we have to check that events
|
52
|
+
# don't get re-delivered to a single registered callback just because
|
53
53
|
# :watch => true was called twice
|
54
54
|
#
|
55
55
|
# again, we're testing a negative here, so consider this a regression check
|
56
56
|
#
|
57
57
|
def wait_for_events_to_not_be_delivered(events)
|
58
|
-
|
58
|
+
expect { wait_until(0.2) { events.length >= 2 } }.to raise_error(WaitWatchers::TimeoutError)
|
59
59
|
end
|
60
60
|
|
61
61
|
it %[should only deliver an event once to each watcher registered for exists?] do
|
@@ -67,14 +67,14 @@ describe ZK do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
2.times do
|
70
|
-
@zk.exists?(@path, :watch => true).
|
70
|
+
expect(@zk.exists?(@path, :watch => true)).not_to be(true)
|
71
71
|
end
|
72
72
|
|
73
73
|
@zk.create(@path, '', :mode => :ephemeral)
|
74
74
|
|
75
75
|
wait_for_events_to_not_be_delivered(events)
|
76
76
|
|
77
|
-
events.length.
|
77
|
+
expect(events.length).to eq(1)
|
78
78
|
end
|
79
79
|
|
80
80
|
it %[should only deliver an event once to each watcher registered for get] do
|
@@ -89,14 +89,14 @@ describe ZK do
|
|
89
89
|
|
90
90
|
2.times do
|
91
91
|
data, stat = @zk.get(@path, :watch => true)
|
92
|
-
data.
|
92
|
+
expect(data).to eq('one')
|
93
93
|
end
|
94
94
|
|
95
95
|
@zk.set(@path, 'two')
|
96
96
|
|
97
97
|
wait_for_events_to_not_be_delivered(events)
|
98
98
|
|
99
|
-
events.length.
|
99
|
+
expect(events.length).to eq(1)
|
100
100
|
end
|
101
101
|
|
102
102
|
|
@@ -112,20 +112,20 @@ describe ZK do
|
|
112
112
|
|
113
113
|
2.times do
|
114
114
|
children = @zk.children(@path, :watch => true)
|
115
|
-
children.
|
115
|
+
expect(children).to be_empty
|
116
116
|
end
|
117
117
|
|
118
118
|
@zk.create("#{@path}/pfx", '', :mode => :ephemeral_sequential)
|
119
119
|
|
120
120
|
wait_for_events_to_not_be_delivered(events)
|
121
121
|
|
122
|
-
events.length.
|
122
|
+
expect(events.length).to eq(1)
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
126
|
it %[should restrict_new_watches_for? if a successul watch has been set] do
|
127
127
|
@zk.stat(@path, :watch => true)
|
128
|
-
@zk.event_handler.
|
128
|
+
expect(@zk.event_handler).to be_restricting_new_watches_for(:data, @path)
|
129
129
|
end
|
130
130
|
|
131
131
|
it %[should not a block on new watches after an operation fails] do
|
@@ -141,19 +141,19 @@ describe ZK do
|
|
141
141
|
|
142
142
|
# get a path that doesn't exist with a watch
|
143
143
|
|
144
|
-
|
144
|
+
expect { @zk.get(@path, :watch => true) }.to raise_error(ZK::Exceptions::NoNode)
|
145
145
|
|
146
|
-
@zk.event_handler.
|
146
|
+
expect(@zk.event_handler).not_to be_restricting_new_watches_for(:data, @path)
|
147
147
|
|
148
148
|
@zk.stat(@path, :watch => true)
|
149
149
|
|
150
|
-
@zk.event_handler.
|
150
|
+
expect(@zk.event_handler).to be_restricting_new_watches_for(:data, @path)
|
151
151
|
|
152
152
|
@zk.create(@path, '')
|
153
153
|
|
154
154
|
wait_while { events.empty? }
|
155
155
|
|
156
|
-
events.
|
156
|
+
expect(events).not_to be_empty
|
157
157
|
end
|
158
158
|
|
159
159
|
it %[should call a child listener when the node is deleted] do
|
@@ -177,10 +177,10 @@ describe ZK do
|
|
177
177
|
|
178
178
|
event = events.pop
|
179
179
|
|
180
|
-
event.
|
180
|
+
expect(event).not_to be_nil
|
181
181
|
|
182
|
-
event.path.
|
183
|
-
event.type.
|
182
|
+
expect(event.path).to eq(@path)
|
183
|
+
expect(event.type).to eq(Zookeeper::ZOO_DELETED_EVENT)
|
184
184
|
|
185
185
|
# Create the node again
|
186
186
|
@zk.create(@path, '')
|
@@ -196,10 +196,10 @@ describe ZK do
|
|
196
196
|
|
197
197
|
event = events.pop
|
198
198
|
|
199
|
-
event.
|
199
|
+
expect(event).not_to be_nil
|
200
200
|
|
201
|
-
event.path.
|
202
|
-
event.type.
|
201
|
+
expect(event.path).to eq(@path)
|
202
|
+
expect(event.type).to eq(Zookeeper::ZOO_DELETED_EVENT)
|
203
203
|
end
|
204
204
|
|
205
205
|
describe ':all' do
|
@@ -230,7 +230,7 @@ describe ZK do
|
|
230
230
|
@zk.create(@path)
|
231
231
|
@zk.create(@other_path, 'blah')
|
232
232
|
|
233
|
-
wait_until { events.length == 2 }.
|
233
|
+
expect(wait_until { events.length == 2 }).to be(true)
|
234
234
|
end
|
235
235
|
end
|
236
236
|
|
@@ -250,58 +250,58 @@ describe ZK do
|
|
250
250
|
|
251
251
|
it %[should deliver only the created event to the created block] do
|
252
252
|
@events.synchronize do
|
253
|
-
@zk.stat(@path, :watch => true).
|
253
|
+
expect(@zk.stat(@path, :watch => true)).not_to exist
|
254
254
|
|
255
255
|
@zk.create(@path)
|
256
256
|
|
257
257
|
@events.wait_for_created
|
258
258
|
|
259
|
-
@events.created.
|
260
|
-
@events.created.first.
|
261
|
-
@events.all.
|
259
|
+
expect(@events.created).not_to be_empty
|
260
|
+
expect(@events.created.first).to be_node_created
|
261
|
+
expect(@events.all).not_to be_empty
|
262
262
|
|
263
|
-
@zk.stat(@path, :watch => true).
|
263
|
+
expect(@zk.stat(@path, :watch => true)).to exist
|
264
264
|
|
265
|
-
@events.all.length.
|
265
|
+
expect(@events.all.length).to eq(1)
|
266
266
|
|
267
267
|
@zk.delete(@path)
|
268
268
|
|
269
269
|
@events.wait_for_all
|
270
270
|
end
|
271
271
|
|
272
|
-
@events.all.length.
|
272
|
+
expect(@events.all.length).to eq(2)
|
273
273
|
|
274
274
|
# :deleted event was delivered, make sure it didn't get delivered to the :created block
|
275
|
-
@events.created.length.
|
275
|
+
expect(@events.created.length).to eq(1)
|
276
276
|
end
|
277
277
|
|
278
278
|
it %[should deliver only the changed event to the changed block] do
|
279
279
|
@events.synchronize do
|
280
280
|
@zk.create(@path)
|
281
281
|
|
282
|
-
@zk.stat(@path, :watch => true).
|
282
|
+
expect(@zk.stat(@path, :watch => true)).to exist
|
283
283
|
|
284
284
|
@zk.set(@path, 'data')
|
285
285
|
|
286
286
|
@events.wait_for_changed
|
287
287
|
end
|
288
288
|
|
289
|
-
@events.changed.
|
290
|
-
@events.changed.length.
|
291
|
-
@events.changed.first.
|
289
|
+
expect(@events.changed).not_to be_empty
|
290
|
+
expect(@events.changed.length).to eq(1)
|
291
|
+
expect(@events.changed.first).to be_node_changed
|
292
292
|
|
293
|
-
@events.all.length.
|
293
|
+
expect(@events.all.length).to eq(1)
|
294
294
|
|
295
295
|
@events.synchronize do
|
296
|
-
@zk.stat(@path, :watch => true).
|
296
|
+
expect(@zk.stat(@path, :watch => true)).to exist
|
297
297
|
@zk.delete(@path)
|
298
298
|
@events.wait_for_all
|
299
299
|
end
|
300
300
|
|
301
|
-
@events.all.length.
|
301
|
+
expect(@events.all.length).to eq(2)
|
302
302
|
|
303
303
|
# :deleted event was delivered, make sure it didn't get delivered to the :changed block
|
304
|
-
@events.changed.length.
|
304
|
+
expect(@events.changed.length).to eq(1)
|
305
305
|
end
|
306
306
|
|
307
307
|
it %[should deliver only the child event to the child block] do
|
@@ -309,53 +309,53 @@ describe ZK do
|
|
309
309
|
|
310
310
|
@events.synchronize do
|
311
311
|
@zk.create(@path)
|
312
|
-
@zk.children(@path, :watch => true).
|
312
|
+
expect(@zk.children(@path, :watch => true)).to be_empty
|
313
313
|
|
314
314
|
child_path = @zk.create("#{@path}/m", '', :sequence => true)
|
315
315
|
|
316
316
|
@events.wait_for_child
|
317
317
|
|
318
|
-
@events.child.length.
|
319
|
-
@events.child.first.
|
318
|
+
expect(@events.child.length).to eq(1)
|
319
|
+
expect(@events.child.first).to be_node_child
|
320
320
|
|
321
|
-
@zk.stat(@path, :watch => true).
|
321
|
+
expect(@zk.stat(@path, :watch => true)).to exist
|
322
322
|
|
323
|
-
@events.all.length.
|
323
|
+
expect(@events.all.length).to eq(1)
|
324
324
|
|
325
325
|
@zk.set(@path, '') # equivalent to a 'touch'
|
326
326
|
@events.wait_for_all
|
327
327
|
end
|
328
328
|
|
329
|
-
@events.all.length.
|
329
|
+
expect(@events.all.length).to eq(2)
|
330
330
|
|
331
331
|
# :changed event was delivered, make sure it didn't get delivered to the :child block
|
332
|
-
@events.child.length.
|
332
|
+
expect(@events.child.length).to eq(1)
|
333
333
|
end
|
334
334
|
|
335
335
|
it %[should deliver only the deleted event to the deleted block] do
|
336
336
|
@events.synchronize do
|
337
337
|
@zk.create(@path)
|
338
|
-
@zk.stat(@path, :watch => true).
|
338
|
+
expect(@zk.stat(@path, :watch => true)).to exist
|
339
339
|
@zk.delete(@path)
|
340
340
|
|
341
341
|
@events.wait_for_deleted
|
342
342
|
@events.wait_while_all { |all| all.empty? }
|
343
343
|
|
344
|
-
@events.deleted.
|
345
|
-
@events.deleted.first.
|
346
|
-
@events.all.length.
|
344
|
+
expect(@events.deleted).not_to be_empty
|
345
|
+
expect(@events.deleted.first).to be_node_deleted
|
346
|
+
expect(@events.all.length).to eq(1)
|
347
347
|
|
348
|
-
@zk.stat(@path, :watch => true).
|
348
|
+
expect(@zk.stat(@path, :watch => true)).not_to exist
|
349
349
|
|
350
350
|
@zk.create(@path)
|
351
351
|
|
352
352
|
@events.wait_for_all
|
353
353
|
end
|
354
354
|
|
355
|
-
@events.all.length.
|
355
|
+
expect(@events.all.length).to be > 1
|
356
356
|
|
357
357
|
# :deleted event was delivered, make sure it didn't get delivered to the :created block
|
358
|
-
@events.deleted.length.
|
358
|
+
expect(@events.deleted.length).to eq(1)
|
359
359
|
end
|
360
360
|
end # event catcher scope
|
361
361
|
|
@@ -372,30 +372,30 @@ describe ZK do
|
|
372
372
|
end
|
373
373
|
|
374
374
|
@events.synchronize do
|
375
|
-
@zk.stat(@path, :watch => true).
|
375
|
+
expect(@zk.stat(@path, :watch => true)).not_to exist
|
376
376
|
|
377
377
|
@zk.create(@path)
|
378
378
|
|
379
379
|
@cond.wait(5)
|
380
380
|
|
381
|
-
@events.
|
382
|
-
@events.length.
|
383
|
-
@events.first.
|
381
|
+
expect(@events).not_to be_empty
|
382
|
+
expect(@events.length).to eq(1)
|
383
|
+
expect(@events.first).to be_node_created
|
384
384
|
|
385
|
-
@zk.stat(@path, :watch => true).
|
385
|
+
expect(@zk.stat(@path, :watch => true)).to exist
|
386
386
|
@zk.set(@path, 'blah')
|
387
387
|
|
388
388
|
@cond.wait(5)
|
389
389
|
end
|
390
390
|
|
391
|
-
@events.length.
|
392
|
-
@events.last.
|
391
|
+
expect(@events.length).to eq(2)
|
392
|
+
expect(@events.last).to be_node_changed
|
393
393
|
end
|
394
394
|
|
395
395
|
it %[should barf if an invalid event name is given] do
|
396
|
-
|
396
|
+
expect do
|
397
397
|
@zk.register(@path, :only => :tripping) { }
|
398
|
-
end.
|
398
|
+
end.to raise_error(ArgumentError)
|
399
399
|
end
|
400
400
|
end # event interest
|
401
401
|
end # watchers
|
@@ -416,21 +416,9 @@ describe ZK do
|
|
416
416
|
|
417
417
|
it %[should fire the registered callback] do
|
418
418
|
wait_while { @event.nil? }
|
419
|
-
@event.
|
419
|
+
expect(@event).not_to be_nil
|
420
420
|
end
|
421
421
|
end
|
422
|
-
|
423
|
-
describe 'registered listeners' do
|
424
|
-
before do
|
425
|
-
@event = flexmock(:event) do |m|
|
426
|
-
m.should_receive(:type).and_return(-1)
|
427
|
-
m.should_receive(:zk=).with(any())
|
428
|
-
m.should_receive(:node_event?).and_return(false)
|
429
|
-
m.should_receive(:state_event?).and_return(true)
|
430
|
-
m.should_receive(:state).and_return(Zookeeper::Constants::ZOO_CONNECTED_STATE)
|
431
|
-
end
|
432
|
-
end
|
433
|
-
end # registered listeners
|
434
422
|
end
|
435
423
|
end
|
436
424
|
|
data/spec/zk/zookeeper_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
shared_examples_for 'ZK basic' do
|
4
4
|
before do
|
5
|
-
logger.debug { "connection_args: #{connection_args.inspect}" }
|
5
|
+
logger.debug { "connection_args: #{connection_args.inspect}" }
|
6
6
|
begin
|
7
7
|
@zk.create(@base_path)
|
8
8
|
rescue ZK::Exceptions::NodeExists
|
@@ -11,58 +11,58 @@ shared_examples_for 'ZK basic' do
|
|
11
11
|
|
12
12
|
describe ZK, "with no authentication" do
|
13
13
|
it "should add authentication" do
|
14
|
-
@zk.add_auth({:scheme => 'digest', :cert => 'bob:password'}).
|
14
|
+
expect(@zk.add_auth({:scheme => 'digest', :cert => 'bob:password'})).to include({:rc => 0})
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe ZK, "with no paths" do
|
19
19
|
it "should not exist" do
|
20
|
-
@zk.exists?("#{@base_path}/test").
|
20
|
+
expect(@zk.exists?("#{@base_path}/test")).to be(false)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should create a path" do
|
24
|
-
@zk.create("#{@base_path}/test", "test_data", :mode => :ephemeral).
|
24
|
+
expect(@zk.create("#{@base_path}/test", "test_data", :mode => :ephemeral)).to eq("#{@base_path}/test")
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should be able to set the data" do
|
28
28
|
@zk.create("#{@base_path}/test", "something", :mode => :ephemeral)
|
29
29
|
@zk.set("#{@base_path}/test", "somethingelse")
|
30
|
-
@zk.get("#{@base_path}/test").first.
|
30
|
+
expect(@zk.get("#{@base_path}/test").first).to eq("somethingelse")
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should raise an exception for a non existent path" do
|
34
|
-
|
34
|
+
expect { @zk.get("/non_existent_path") }.to raise_error(ZK::Exceptions::NoNode)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should create a path with sequence set" do
|
38
|
-
@zk.create("#{@base_path}/test", "test_data", :mode => :persistent_sequential).
|
38
|
+
expect(@zk.create("#{@base_path}/test", "test_data", :mode => :persistent_sequential)).to match(/test(\d+)/)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should create an ephemeral path" do
|
42
|
-
@zk.create("#{@base_path}/test", "test_data", :mode => :ephemeral).
|
42
|
+
expect(@zk.create("#{@base_path}/test", "test_data", :mode => :ephemeral)).to eq("#{@base_path}/test")
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should remove ephemeral path when client session ends" do
|
46
|
-
@zk.create("#{@base_path}/test", "test_data", :mode => :ephemeral).
|
47
|
-
@zk.exists?("#{@base_path}/test").
|
46
|
+
expect(@zk.create("#{@base_path}/test", "test_data", :mode => :ephemeral)).to eq("#{@base_path}/test")
|
47
|
+
expect(@zk.exists?("#{@base_path}/test")).not_to be_nil
|
48
48
|
@zk.close!
|
49
49
|
wait_until(2) { !@zk.connected? }
|
50
|
-
@zk.
|
50
|
+
expect(@zk).not_to be_connected
|
51
51
|
|
52
52
|
@zk = ZK.new(*connection_args)
|
53
53
|
wait_until{ @zk.connected? }
|
54
|
-
@zk.exists?("#{@base_path}/test").
|
54
|
+
expect(@zk.exists?("#{@base_path}/test")).to be(false)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should remove sequential ephemeral path when client session ends" do
|
58
58
|
created = @zk.create("#{@base_path}/test", "test_data", :mode => :ephemeral_sequential)
|
59
|
-
created.
|
60
|
-
@zk.exists?(created).
|
59
|
+
expect(created).to match(/test(\d+)/)
|
60
|
+
expect(@zk.exists?(created)).not_to be_nil
|
61
61
|
@zk.close!
|
62
62
|
|
63
63
|
@zk = ZK.new(*connection_args)
|
64
64
|
wait_until{ @zk.connected? }
|
65
|
-
@zk.exists?(created).
|
65
|
+
expect(@zk.exists?(created)).to be(false)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -72,57 +72,57 @@ shared_examples_for 'ZK basic' do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should return a stat" do
|
75
|
-
@zk.stat("#{@base_path}/test").
|
75
|
+
expect(@zk.stat("#{@base_path}/test")).to be_instance_of(Zookeeper::Stat)
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should return a boolean" do
|
79
|
-
@zk.exists?("#{@base_path}/test").
|
79
|
+
expect(@zk.exists?("#{@base_path}/test")).to be(true)
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should get data and stat" do
|
83
83
|
data, stat = @zk.get("#{@base_path}/test")
|
84
|
-
data.
|
85
|
-
stat.
|
86
|
-
stat.created_time.
|
84
|
+
expect(data).to eq("test_data")
|
85
|
+
expect(stat).to be_a_kind_of(Zookeeper::Stat)
|
86
|
+
expect(stat.created_time).not_to eq(0)
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should set data with a file" do
|
90
90
|
file = File.read('spec/test_file.txt')
|
91
91
|
@zk.set("#{@base_path}/test", file)
|
92
|
-
@zk.get("#{@base_path}/test").first.
|
92
|
+
expect(@zk.get("#{@base_path}/test").first).to eq(file)
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should delete path" do
|
96
96
|
@zk.delete("#{@base_path}/test")
|
97
|
-
@zk.exists?("#{@base_path}/test").
|
97
|
+
expect(@zk.exists?("#{@base_path}/test")).to be(false)
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should create a child path" do
|
101
|
-
@zk.create("#{@base_path}/test/child", "child", :mode => :ephemeral).
|
101
|
+
expect(@zk.create("#{@base_path}/test/child", "child", :mode => :ephemeral)).to eq("#{@base_path}/test/child")
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should create sequential child paths" do
|
105
|
-
(child1 = @zk.create("#{@base_path}/test/child", "child1", :mode => :persistent_sequential)).
|
106
|
-
(child2 = @zk.create("#{@base_path}/test/child", "child2", :mode => :persistent_sequential)).
|
105
|
+
expect(child1 = @zk.create("#{@base_path}/test/child", "child1", :mode => :persistent_sequential)).to match(/\/test\/child(\d+)/)
|
106
|
+
expect(child2 = @zk.create("#{@base_path}/test/child", "child2", :mode => :persistent_sequential)).to match(/\/test\/child(\d+)/)
|
107
107
|
children = @zk.children("#{@base_path}/test")
|
108
|
-
children.length.
|
109
|
-
children.
|
110
|
-
children.
|
108
|
+
expect(children.length).to eq(2)
|
109
|
+
expect(children).to be_include(child1.match(/\/test\/(child\d+)/)[1])
|
110
|
+
expect(children).to be_include(child2.match(/\/test\/(child\d+)/)[1])
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should have no children" do
|
114
|
-
@zk.children("#{@base_path}/test").
|
114
|
+
expect(@zk.children("#{@base_path}/test")).to be_empty
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
118
|
describe ZK, "with children" do
|
119
119
|
before(:each) do
|
120
120
|
@zk.create("#{@base_path}/test", "test_data", :mode => :persistent)
|
121
|
-
@zk.create("#{@base_path}/test/child", "child", :mode => "persistent").
|
121
|
+
expect(@zk.create("#{@base_path}/test/child", "child", :mode => "persistent")).to eq("#{@base_path}/test/child")
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should get children" do
|
125
|
-
@zk.children("#{@base_path}/test").
|
125
|
+
expect(@zk.children("#{@base_path}/test")).to eql(["child"])
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
data/zk.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = %q{A high-level wrapper around the zookeeper driver}
|
13
13
|
s.description = s.summary + "\n"
|
14
14
|
|
15
|
-
s.add_runtime_dependency 'zookeeper', '~> 1.
|
15
|
+
s.add_runtime_dependency 'zookeeper', '~> 1.5.0'
|
16
16
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,48 +1,48 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan D. Simms
|
8
8
|
- Topper Bowers
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-09-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: zookeeper
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.
|
20
|
+
version: 1.5.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 1.
|
28
|
-
description:
|
27
|
+
version: 1.5.0
|
28
|
+
description: 'A high-level wrapper around the zookeeper driver
|
29
29
|
|
30
|
-
'
|
30
|
+
'
|
31
31
|
email:
|
32
32
|
- slyphon@gmail.com
|
33
33
|
executables: []
|
34
34
|
extensions: []
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
37
|
-
- .dotfiles/ctags_paths
|
38
|
-
- .dotfiles/rspec-logging
|
39
|
-
- .dotfiles/ruby-gemset
|
40
|
-
- .dotfiles/ruby-version
|
41
|
-
- .dotfiles/rvmrc
|
42
|
-
- .
|
43
|
-
- .
|
44
|
-
- .
|
45
|
-
- .yardopts
|
37
|
+
- ".dotfiles/ctags_paths"
|
38
|
+
- ".dotfiles/rspec-logging"
|
39
|
+
- ".dotfiles/ruby-gemset"
|
40
|
+
- ".dotfiles/ruby-version"
|
41
|
+
- ".dotfiles/rvmrc"
|
42
|
+
- ".github/workflows/build.yml"
|
43
|
+
- ".gitignore"
|
44
|
+
- ".gitmodules"
|
45
|
+
- ".yardopts"
|
46
46
|
- Gemfile
|
47
47
|
- Guardfile
|
48
48
|
- LICENSE
|
@@ -137,24 +137,23 @@ files:
|
|
137
137
|
homepage: https://github.com/slyphon/zk
|
138
138
|
licenses: []
|
139
139
|
metadata: {}
|
140
|
-
post_install_message:
|
140
|
+
post_install_message:
|
141
141
|
rdoc_options: []
|
142
142
|
require_paths:
|
143
143
|
- lib
|
144
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
145
145
|
requirements:
|
146
|
-
- -
|
146
|
+
- - ">="
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: '0'
|
149
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
|
-
- -
|
151
|
+
- - ">="
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
|
-
|
156
|
-
|
157
|
-
signing_key:
|
155
|
+
rubygems_version: 3.1.6
|
156
|
+
signing_key:
|
158
157
|
specification_version: 4
|
159
158
|
summary: A high-level wrapper around the zookeeper driver
|
160
159
|
test_files:
|
data/.travis.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# This should kick us over to the docker system
|
2
|
-
sudo: false
|
3
|
-
|
4
|
-
notifications:
|
5
|
-
email:
|
6
|
-
- slyphon@gmail.com
|
7
|
-
- eric@5stops.com
|
8
|
-
|
9
|
-
env:
|
10
|
-
- SPAWN_ZOOKEEPER='true'
|
11
|
-
|
12
|
-
# pull in releaseops submodule
|
13
|
-
before_install:
|
14
|
-
- gem update bundler
|
15
|
-
- git submodule update --init --recursive
|
16
|
-
|
17
|
-
rvm:
|
18
|
-
- 1.9.3
|
19
|
-
- 1.9.2
|
20
|
-
- 1.8.7
|
21
|
-
- ree
|
22
|
-
- 2.0.0
|
23
|
-
- 2.1.0
|
24
|
-
- 2.2.0
|
25
|
-
|
26
|
-
# jruby specs are too intesive for travis
|
27
|
-
# - jruby-18mode
|
28
|
-
# - jruby-19mode
|
29
|
-
|
30
|
-
bundler_args: --without development docs coverage
|