zookeeper 0.9.4 → 1.0.0.beta.1
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.
- data/.dotfiles/rvmrc +1 -0
- data/.gitignore +3 -0
- data/.gitmodules +3 -0
- data/.travis.yml +22 -0
- data/CHANGELOG +38 -5
- data/Gemfile +18 -1
- data/README.markdown +2 -0
- data/Rakefile +47 -109
- data/ext/c_zookeeper.rb +10 -6
- data/ext/zookeeper_base.rb +23 -11
- data/ext/zookeeper_c.c +14 -10
- data/java/{zookeeper_base.rb → java_base.rb} +13 -12
- data/lib/zookeeper.rb +32 -244
- data/lib/zookeeper/acls.rb +17 -13
- data/lib/zookeeper/callbacks.rb +28 -11
- data/lib/zookeeper/client.rb +30 -0
- data/lib/zookeeper/client_methods.rb +241 -0
- data/lib/zookeeper/common.rb +13 -12
- data/lib/zookeeper/common/queue_with_pipe.rb +3 -7
- data/lib/zookeeper/compatibility.rb +135 -0
- data/lib/zookeeper/constants.rb +35 -1
- data/lib/zookeeper/em_client.rb +1 -1
- data/lib/zookeeper/exceptions.rb +117 -93
- data/lib/zookeeper/rake_tasks.rb +165 -0
- data/lib/zookeeper/stat.rb +16 -16
- data/lib/zookeeper/version.rb +2 -4
- data/scripts/upgrade-1.0-sed-alike.rb +46 -0
- data/spec/c_zookeeper_spec.rb +10 -9
- data/spec/chrooted_connection_spec.rb +2 -2
- data/spec/default_watcher_spec.rb +4 -4
- data/spec/em_spec.rb +1 -1
- data/spec/shared/connection_examples.rb +52 -37
- data/spec/spec_helper.rb +22 -84
- data/spec/support/00_spawn_zookeeper.rb +20 -0
- data/spec/support/zookeeper_spec_helpers.rb +84 -0
- data/spec/zookeeper_spec.rb +1 -1
- metadata +47 -34
- data/examples/cloud_config.rb +0 -125
- data/test/test_basic.rb +0 -37
- data/test/test_callback1.rb +0 -36
- data/test/test_close.rb +0 -16
- data/test/test_esoteric.rb +0 -7
- data/test/test_watcher1.rb +0 -56
- data/test/test_watcher2.rb +0 -52
data/lib/zookeeper/version.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
if ARGV.empty?
|
4
|
+
$stderr.puts <<-EOS
|
5
|
+
Usage: #{File.basename(__FILE__)} file1 file2 file3
|
6
|
+
|
7
|
+
Fix references to Zookeeper classes and modules.
|
8
|
+
|
9
|
+
This script acts like sed and edits files in place (not saving backups,
|
10
|
+
as you *are* using source control and aren't a complete tool).
|
11
|
+
|
12
|
+
if you have any doubts, *read the script*:
|
13
|
+
----------------------------------------------------------------------
|
14
|
+
|
15
|
+
#{File.read(__FILE__)}
|
16
|
+
|
17
|
+
EOS
|
18
|
+
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
require 'tempfile'
|
24
|
+
require 'fileutils'
|
25
|
+
|
26
|
+
ARGV.each do |path|
|
27
|
+
Tempfile.open(File.basename(path)) do |tmp|
|
28
|
+
File.open(path) do |input|
|
29
|
+
while line = input.gets
|
30
|
+
tmp.puts line.gsub(/\bZookeeperStat::Stat\b/, 'Zookeeper::Stat').
|
31
|
+
gsub(/\bZookeeper::(\w+)Callback\b/, 'Zookeeper::Callbacks::\1Callback').
|
32
|
+
gsub(/\bZookeeperACLs::(ZOO_\w+)\b/, 'Zookeeper::Constants::\1').
|
33
|
+
gsub(/\bZookeeperExceptions::ZookeeperException::(\w+)\b/, 'Zookeeper::Exceptions::\1').
|
34
|
+
gsub(/\bZookeeper(Constants|Exceptions|Common|ACLs|Callbacks)\b/, 'Zookeeper::\1').
|
35
|
+
gsub(/\bZookeeperException::(\w+)\b/, 'Exceptions::\1')
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
tmp.fsync
|
41
|
+
tmp.close
|
42
|
+
|
43
|
+
FileUtils.mv(tmp.path, path)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/spec/c_zookeeper_spec.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# tests the CZookeeper, obviously only available when running under MRI
|
2
|
-
require 'spec_helper'
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
unless defined?(::JRUBY_VERSION)
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe Zookeeper::CZookeeper do
|
6
7
|
def pop_all_events
|
7
8
|
[].tap do |rv|
|
8
9
|
begin
|
@@ -13,13 +14,13 @@ if Module.const_defined?(:CZookeeper)
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def wait_until_connected(timeout=2)
|
16
|
-
wait_until(timeout) { @czk.state ==
|
17
|
+
wait_until(timeout) { @czk.state == Zookeeper::Constants::ZOO_CONNECTED_STATE }
|
17
18
|
end
|
18
19
|
|
19
20
|
describe do
|
20
21
|
before do
|
21
|
-
@event_queue =
|
22
|
-
@czk = CZookeeper.new(
|
22
|
+
@event_queue = Zookeeper::Common::QueueWithPipe.new
|
23
|
+
@czk = Zookeeper::CZookeeper.new(Zookeeper.default_cnx_str, @event_queue)
|
23
24
|
end
|
24
25
|
|
25
26
|
after do
|
@@ -39,9 +40,9 @@ if Module.const_defined?(:CZookeeper)
|
|
39
40
|
it %[should have a connection event after being connected] do
|
40
41
|
event = wait_until(2) { @event_queue.pop }
|
41
42
|
event.should be
|
42
|
-
event[:req_id].should ==
|
43
|
-
event[:type].should ==
|
44
|
-
event[:state].should ==
|
43
|
+
event[:req_id].should == Zookeeper::Common::ZKRB_GLOBAL_CB_REQ
|
44
|
+
event[:type].should == Zookeeper::Constants::ZOO_SESSION_EVENT
|
45
|
+
event[:state].should == Zookeeper::Constants::ZOO_CONNECTED_STATE
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
@@ -6,7 +6,7 @@ describe 'Zookeeper chrooted' do
|
|
6
6
|
let(:data) { "underpants" }
|
7
7
|
let(:chroot_path) { '/slyphon-zookeeper-chroot' }
|
8
8
|
|
9
|
-
let(:connection_string) { "
|
9
|
+
let(:connection_string) { "#{Zookeeper.default_cnx_str}#{chroot_path}" }
|
10
10
|
|
11
11
|
before do
|
12
12
|
@zk = Zookeeper.new(connection_string)
|
@@ -52,7 +52,7 @@ describe 'Zookeeper chrooted' do
|
|
52
52
|
it %[should return ZNONODE] do
|
53
53
|
rv = zk.create(:path => '/', :data => '')
|
54
54
|
rv[:rc].should_not be_zero
|
55
|
-
rv[:rc].should ==
|
55
|
+
rv[:rc].should == Zookeeper::Exceptions::ZNONODE
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -5,18 +5,18 @@ describe Zookeeper do
|
|
5
5
|
before do
|
6
6
|
@events = []
|
7
7
|
@watch_block = lambda do |hash|
|
8
|
-
|
8
|
+
logger.debug "watch_block: #{hash.inspect}"
|
9
9
|
@events << hash
|
10
10
|
end
|
11
11
|
|
12
|
-
@zk = Zookeeper.new(
|
12
|
+
@zk = Zookeeper.new(Zookeeper.default_cnx_str, 10, @watch_block)
|
13
13
|
|
14
14
|
wait_until(2) { @zk.connected? }
|
15
15
|
@zk.should be_connected
|
16
|
-
|
16
|
+
logger.debug "connected!"
|
17
17
|
|
18
18
|
wait_until(2) { !@events.empty? }
|
19
|
-
|
19
|
+
logger.debug "got events!"
|
20
20
|
end
|
21
21
|
|
22
22
|
after do
|
data/spec/em_spec.rb
CHANGED
@@ -34,7 +34,7 @@ shared_examples_for "connection" do
|
|
34
34
|
|
35
35
|
it %[should return a stat] do
|
36
36
|
@rv[:stat].should_not be_nil
|
37
|
-
@rv[:stat].should be_kind_of(
|
37
|
+
@rv[:stat].should be_kind_of(Zookeeper::Stat)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -43,7 +43,7 @@ shared_examples_for "connection" do
|
|
43
43
|
|
44
44
|
before do
|
45
45
|
@event = nil
|
46
|
-
@watcher = Zookeeper::WatcherCallback.new
|
46
|
+
@watcher = Zookeeper::Callbacks::WatcherCallback.new
|
47
47
|
|
48
48
|
@rv = zk.get(:path => path, :watcher => @watcher, :watcher_context => path)
|
49
49
|
end
|
@@ -67,7 +67,7 @@ shared_examples_for "connection" do
|
|
67
67
|
|
68
68
|
describe :async do
|
69
69
|
before do
|
70
|
-
@cb = Zookeeper::DataCallback.new
|
70
|
+
@cb = Zookeeper::Callbacks::DataCallback.new
|
71
71
|
|
72
72
|
@rv = zk.get(:path => path, :callback => @cb, :callback_context => path)
|
73
73
|
wait_until(1.0) { @cb.completed? }
|
@@ -82,7 +82,7 @@ shared_examples_for "connection" do
|
|
82
82
|
|
83
83
|
it %[should have the stat object in the callback] do
|
84
84
|
@cb.stat.should_not be_nil
|
85
|
-
@cb.stat.should be_kind_of(
|
85
|
+
@cb.stat.should be_kind_of(Zookeeper::Stat)
|
86
86
|
end
|
87
87
|
|
88
88
|
it %[should have the data] do
|
@@ -94,8 +94,8 @@ shared_examples_for "connection" do
|
|
94
94
|
it_should_behave_like "all success return values"
|
95
95
|
|
96
96
|
before do
|
97
|
-
@cb = Zookeeper::DataCallback.new
|
98
|
-
@watcher = Zookeeper::WatcherCallback.new
|
97
|
+
@cb = Zookeeper::Callbacks::DataCallback.new
|
98
|
+
@watcher = Zookeeper::Callbacks::WatcherCallback.new
|
99
99
|
|
100
100
|
@rv = zk.get(:path => path, :callback => @cb, :callback_context => path, :watcher => @watcher, :watcher_context => path)
|
101
101
|
wait_until(1.0) { @cb.completed? }
|
@@ -104,7 +104,7 @@ shared_examples_for "connection" do
|
|
104
104
|
|
105
105
|
it %[should have the stat object in the callback] do
|
106
106
|
@cb.stat.should_not be_nil
|
107
|
-
@cb.stat.should be_kind_of(
|
107
|
+
@cb.stat.should be_kind_of(Zookeeper::Stat)
|
108
108
|
end
|
109
109
|
|
110
110
|
it %[should have the data] do
|
@@ -129,7 +129,7 @@ shared_examples_for "connection" do
|
|
129
129
|
|
130
130
|
describe 'bad arguments' do
|
131
131
|
it %[should barf with a BadArguments error] do
|
132
|
-
lambda { zk.get(:bad_arg => 'what!?') }.should raise_error(
|
132
|
+
lambda { zk.get(:bad_arg => 'what!?') }.should raise_error(Zookeeper::Exceptions::BadArguments)
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end # get
|
@@ -150,7 +150,7 @@ shared_examples_for "connection" do
|
|
150
150
|
|
151
151
|
it %[should return the new stat] do
|
152
152
|
@rv[:stat].should_not be_nil
|
153
|
-
@rv[:stat].should be_kind_of(
|
153
|
+
@rv[:stat].should be_kind_of(Zookeeper::Stat)
|
154
154
|
@rv[:stat].version.should > @stat.version
|
155
155
|
end
|
156
156
|
end
|
@@ -164,7 +164,7 @@ shared_examples_for "connection" do
|
|
164
164
|
|
165
165
|
it %[should return the new stat] do
|
166
166
|
@rv[:stat].should_not be_nil
|
167
|
-
@rv[:stat].should be_kind_of(
|
167
|
+
@rv[:stat].should be_kind_of(Zookeeper::Stat)
|
168
168
|
@rv[:stat].version.should > @stat.version
|
169
169
|
end
|
170
170
|
end
|
@@ -190,14 +190,14 @@ shared_examples_for "connection" do
|
|
190
190
|
it %[should barf if the data size is too large], :input_size => true do
|
191
191
|
large_data = '0' * (1024 ** 2)
|
192
192
|
|
193
|
-
lambda { zk.set(:path => path, :data => large_data) }.should raise_error(
|
193
|
+
lambda { zk.set(:path => path, :data => large_data) }.should raise_error(Zookeeper::Exceptions::DataTooLargeException)
|
194
194
|
end
|
195
195
|
end
|
196
196
|
end # sync
|
197
197
|
|
198
198
|
describe :async do
|
199
199
|
before do
|
200
|
-
@cb = Zookeeper::StatCallback.new
|
200
|
+
@cb = Zookeeper::Callbacks::StatCallback.new
|
201
201
|
end
|
202
202
|
|
203
203
|
describe 'without version' do
|
@@ -264,7 +264,7 @@ shared_examples_for "connection" do
|
|
264
264
|
it %[should barf if the data size is too large], :input_size => true do
|
265
265
|
large_data = '0' * (1024 ** 2)
|
266
266
|
|
267
|
-
lambda { zk.set(:path => path, :data => large_data, :callback => @cb, :callback_context => path) }.should raise_error(
|
267
|
+
lambda { zk.set(:path => path, :data => large_data, :callback => @cb, :callback_context => path) }.should raise_error(Zookeeper::Exceptions::DataTooLargeException)
|
268
268
|
end
|
269
269
|
end
|
270
270
|
|
@@ -303,7 +303,7 @@ shared_examples_for "connection" do
|
|
303
303
|
|
304
304
|
it %[should have a stat object whose num_children is 3] do
|
305
305
|
@rv[:stat].should_not be_nil
|
306
|
-
@rv[:stat].should be_kind_of(
|
306
|
+
@rv[:stat].should be_kind_of(Zookeeper::Stat)
|
307
307
|
@rv[:stat].num_children.should == 3
|
308
308
|
end
|
309
309
|
end
|
@@ -314,7 +314,7 @@ shared_examples_for "connection" do
|
|
314
314
|
before do
|
315
315
|
@addtl_child = 'child3'
|
316
316
|
|
317
|
-
@watcher = Zookeeper::WatcherCallback.new
|
317
|
+
@watcher = Zookeeper::Callbacks::WatcherCallback.new
|
318
318
|
|
319
319
|
@rv = zk.get_children(:path => path, :watcher => @watcher, :watcher_context => path)
|
320
320
|
end
|
@@ -331,7 +331,7 @@ shared_examples_for "connection" do
|
|
331
331
|
|
332
332
|
it %[should have a stat object whose num_children is 3] do
|
333
333
|
@rv[:stat].should_not be_nil
|
334
|
-
@rv[:stat].should be_kind_of(
|
334
|
+
@rv[:stat].should be_kind_of(Zookeeper::Stat)
|
335
335
|
@rv[:stat].num_children.should == 3
|
336
336
|
end
|
337
337
|
|
@@ -353,7 +353,7 @@ shared_examples_for "connection" do
|
|
353
353
|
it_should_behave_like "all success return values"
|
354
354
|
|
355
355
|
before do
|
356
|
-
@cb =
|
356
|
+
@cb = Zookeeper::Callbacks::StringsCallback.new
|
357
357
|
@rv = zk.get_children(:path => path, :callback => @cb, :callback_context => path)
|
358
358
|
|
359
359
|
wait_until { @cb.completed? }
|
@@ -372,7 +372,7 @@ shared_examples_for "connection" do
|
|
372
372
|
|
373
373
|
it %[should have a stat object whose num_children is 3] do
|
374
374
|
@cb.stat.should_not be_nil
|
375
|
-
@cb.stat.should be_kind_of(
|
375
|
+
@cb.stat.should be_kind_of(Zookeeper::Stat)
|
376
376
|
@cb.stat.num_children.should == 3
|
377
377
|
end
|
378
378
|
end
|
@@ -383,8 +383,8 @@ shared_examples_for "connection" do
|
|
383
383
|
before do
|
384
384
|
@addtl_child = 'child3'
|
385
385
|
|
386
|
-
@watcher = Zookeeper::WatcherCallback.new
|
387
|
-
@cb =
|
386
|
+
@watcher = Zookeeper::Callbacks::WatcherCallback.new
|
387
|
+
@cb = Zookeeper::Callbacks::StringsCallback.new
|
388
388
|
|
389
389
|
@rv = zk.get_children(:path => path, :watcher => @watcher, :watcher_context => path, :callback => @cb, :callback_context => path)
|
390
390
|
wait_until { @cb.completed? }
|
@@ -407,7 +407,7 @@ shared_examples_for "connection" do
|
|
407
407
|
|
408
408
|
it %[should have a stat object whose num_children is 3] do
|
409
409
|
@cb.stat.should_not be_nil
|
410
|
-
@cb.stat.should be_kind_of(
|
410
|
+
@cb.stat.should be_kind_of(Zookeeper::Stat)
|
411
411
|
@cb.stat.num_children.should == 3
|
412
412
|
end
|
413
413
|
|
@@ -445,7 +445,7 @@ shared_examples_for "connection" do
|
|
445
445
|
it_should_behave_like "all success return values"
|
446
446
|
|
447
447
|
before do
|
448
|
-
@watcher = Zookeeper::WatcherCallback.new
|
448
|
+
@watcher = Zookeeper::Callbacks::WatcherCallback.new
|
449
449
|
|
450
450
|
@rv = zk.stat(:path => path, :watcher => @watcher, :watcher_context => path)
|
451
451
|
end
|
@@ -472,7 +472,7 @@ shared_examples_for "connection" do
|
|
472
472
|
it_should_behave_like "all success return values"
|
473
473
|
|
474
474
|
before do
|
475
|
-
@cb =
|
475
|
+
@cb = Zookeeper::Callbacks::StatCallback.new
|
476
476
|
@rv = zk.stat(:path => path, :callback => @cb, :callback_context => path)
|
477
477
|
|
478
478
|
wait_until { @cb.completed? }
|
@@ -494,9 +494,9 @@ shared_examples_for "connection" do
|
|
494
494
|
before do
|
495
495
|
@addtl_child = 'child3'
|
496
496
|
|
497
|
-
@watcher = Zookeeper::WatcherCallback.new
|
497
|
+
@watcher = Zookeeper::Callbacks::WatcherCallback.new
|
498
498
|
|
499
|
-
@cb =
|
499
|
+
@cb = Zookeeper::Callbacks::StatCallback.new
|
500
500
|
@rv = zk.stat(:path => path, :callback => @cb, :callback_context => path, :watcher => @watcher, :watcher_context => path)
|
501
501
|
|
502
502
|
wait_until { @cb.completed? }
|
@@ -541,7 +541,7 @@ shared_examples_for "connection" do
|
|
541
541
|
it %[should barf if the data size is too large], :input_size => true do
|
542
542
|
large_data = '0' * (1024 ** 2)
|
543
543
|
|
544
|
-
lambda { zk.create(:path => path, :data => large_data) }.should raise_error(
|
544
|
+
lambda { zk.create(:path => path, :data => large_data) }.should raise_error(Zookeeper::Exceptions::DataTooLargeException)
|
545
545
|
end
|
546
546
|
end
|
547
547
|
|
@@ -642,7 +642,7 @@ shared_examples_for "connection" do
|
|
642
642
|
|
643
643
|
describe :async do
|
644
644
|
before do
|
645
|
-
@cb =
|
645
|
+
@cb = Zookeeper::Callbacks::StringCallback.new
|
646
646
|
end
|
647
647
|
|
648
648
|
describe :default_flags do
|
@@ -676,7 +676,7 @@ shared_examples_for "connection" do
|
|
676
676
|
|
677
677
|
lambda do
|
678
678
|
zk.create(:path => path, :data => large_data, :callback => @cb, :callback_context => path)
|
679
|
-
end.should raise_error(
|
679
|
+
end.should raise_error(Zookeeper::Exceptions::DataTooLargeException)
|
680
680
|
end
|
681
681
|
end
|
682
682
|
|
@@ -821,7 +821,7 @@ shared_examples_for "connection" do
|
|
821
821
|
|
822
822
|
describe :async do
|
823
823
|
before do
|
824
|
-
@cb =
|
824
|
+
@cb = Zookeeper::Callbacks::VoidCallback.new
|
825
825
|
end
|
826
826
|
|
827
827
|
describe 'without version' do
|
@@ -886,7 +886,7 @@ shared_examples_for "connection" do
|
|
886
886
|
end
|
887
887
|
|
888
888
|
it %[should return a stat for the path] do
|
889
|
-
@rv[:stat].should be_kind_of(
|
889
|
+
@rv[:stat].should be_kind_of(Zookeeper::Stat)
|
890
890
|
end
|
891
891
|
|
892
892
|
it %[should return the acls] do
|
@@ -906,7 +906,7 @@ shared_examples_for "connection" do
|
|
906
906
|
it_should_behave_like "all success return values"
|
907
907
|
|
908
908
|
before do
|
909
|
-
@cb = Zookeeper::ACLCallback.new
|
909
|
+
@cb = Zookeeper::Callbacks::ACLCallback.new
|
910
910
|
@rv = zk.get_acl(:path => path, :callback => @cb, :callback_context => path)
|
911
911
|
|
912
912
|
wait_until(2) { @cb.completed? }
|
@@ -914,7 +914,7 @@ shared_examples_for "connection" do
|
|
914
914
|
end
|
915
915
|
|
916
916
|
it %[should return a stat for the path] do
|
917
|
-
@cb.stat.should be_kind_of(
|
917
|
+
@cb.stat.should be_kind_of(Zookeeper::Stat)
|
918
918
|
end
|
919
919
|
|
920
920
|
it %[should return the acls] do
|
@@ -922,7 +922,7 @@ shared_examples_for "connection" do
|
|
922
922
|
acls.should be_kind_of(Array)
|
923
923
|
|
924
924
|
acl = acls.first
|
925
|
-
acl.should be_kind_of(
|
925
|
+
acl.should be_kind_of(Zookeeper::ACLs::ACL)
|
926
926
|
|
927
927
|
acl.perms.should == Zookeeper::ZOO_PERM_ALL
|
928
928
|
|
@@ -935,7 +935,7 @@ shared_examples_for "connection" do
|
|
935
935
|
describe :set_acl do
|
936
936
|
before do
|
937
937
|
@perms = 5
|
938
|
-
@new_acl = [
|
938
|
+
@new_acl = [Zookeeper::ACLs::ACL.new(:perms => @perms, :id => Zookeeper::Constants::ZOO_ANYONE_ID_UNSAFE)]
|
939
939
|
pending("No idea how to set ACLs")
|
940
940
|
end
|
941
941
|
|
@@ -950,7 +950,7 @@ shared_examples_for "connection" do
|
|
950
950
|
|
951
951
|
describe :session_id do
|
952
952
|
it %[should return the session_id as a Fixnum] do
|
953
|
-
zk.session_id.should be_kind_of(
|
953
|
+
zk.session_id.should be_kind_of(Integer)
|
954
954
|
end
|
955
955
|
end
|
956
956
|
|
@@ -965,7 +965,7 @@ shared_examples_for "connection" do
|
|
965
965
|
it_should_behave_like "all success return values"
|
966
966
|
|
967
967
|
before do
|
968
|
-
@cb = Zookeeper::StringCallback.new
|
968
|
+
@cb = Zookeeper::Callbacks::StringCallback.new
|
969
969
|
@rv = zk.sync(:path => path, :callback => @cb)
|
970
970
|
|
971
971
|
wait_until(2) { @cb.completed }
|
@@ -975,7 +975,7 @@ shared_examples_for "connection" do
|
|
975
975
|
|
976
976
|
describe :errors do
|
977
977
|
it %[should barf with BadArguments if :callback is not given] do
|
978
|
-
lambda { zk.sync(:path => path) }.should raise_error(
|
978
|
+
lambda { zk.sync(:path => path) }.should raise_error(Zookeeper::Exceptions::BadArguments)
|
979
979
|
end
|
980
980
|
end
|
981
981
|
end
|
@@ -1014,5 +1014,20 @@ shared_examples_for "connection" do
|
|
1014
1014
|
end
|
1015
1015
|
end
|
1016
1016
|
end
|
1017
|
+
|
1018
|
+
unless defined?(::JRUBY_VERSION)
|
1019
|
+
describe 'fork protection' do
|
1020
|
+
it %[should raise an InheritedConnectionError if the current Process.pid is different from the one that created the client] do
|
1021
|
+
pid = Process.pid
|
1022
|
+
begin
|
1023
|
+
Process.stub(:pid => -1)
|
1024
|
+
lambda { zk.stat(:path => path) }.should raise_error(Zookeeper::Exceptions::InheritedConnectionError)
|
1025
|
+
ensure
|
1026
|
+
# ensure we reset this, only want it to fail during the test
|
1027
|
+
Process.stub(:pid => pid)
|
1028
|
+
end
|
1029
|
+
end
|
1030
|
+
end
|
1031
|
+
end
|
1017
1032
|
end
|
1018
1033
|
|