zk 1.9.3 → 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 +7 -0
- data/.github/workflows/build.yml +55 -0
- data/.gitignore +1 -0
- data/Gemfile +18 -8
- data/README.markdown +9 -9
- data/RELEASES.markdown +28 -1
- data/lib/zk/client/base.rb +15 -0
- data/lib/zk/client/threaded.rb +3 -3
- data/lib/zk/client.rb +1 -1
- data/lib/zk/election.rb +1 -1
- data/lib/zk/event_handler.rb +16 -8
- data/lib/zk/event_handler_subscription/base.rb +1 -1
- data/lib/zk/fork_hook.rb +9 -4
- data/lib/zk/locker/locker_base.rb +14 -2
- data/lib/zk/locker/semaphore.rb +1 -3
- data/lib/zk/logger.rb +34 -0
- data/lib/zk/node_deletion_watcher.rb +4 -5
- data/lib/zk/pool.rb +12 -12
- data/lib/zk/subscription.rb +1 -1
- data/lib/zk/threaded_callback.rb +1 -1
- data/lib/zk/threadpool.rb +1 -1
- data/lib/zk/version.rb +1 -1
- data/lib/zk.rb +1 -5
- data/spec/event_catcher_spec.rb +1 -1
- data/spec/logging_progress_bar_formatter.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 +12 -13
- data/spec/support/bogus_mongoid.rb +1 -1
- data/spec/support/client_forker.rb +1 -1
- data/spec/support/event_catcher.rb +1 -1
- data/spec/support/logging.rb +15 -47
- 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 +36 -30
- data/zk.gemspec +1 -2
- metadata +26 -47
- data/.travis.yml +0 -25
- data/lib/zk/logging.rb +0 -36
@@ -8,12 +8,12 @@ shared_examples_for :shared_exclusive_integration do
|
|
8
8
|
|
9
9
|
describe 'shared lock acquired first' do
|
10
10
|
it %[should block exclusive locks from acquiring until released] do
|
11
|
-
@sh_lock.lock.
|
12
|
-
@ex_lock.lock.
|
11
|
+
expect(@sh_lock.lock).to be(true)
|
12
|
+
expect(@ex_lock.lock).to be(false)
|
13
13
|
|
14
14
|
mutex = Monitor.new
|
15
15
|
cond = mutex.new_cond
|
16
|
-
|
16
|
+
|
17
17
|
th = Thread.new do
|
18
18
|
logger.debug { "@ex_lock trying to acquire acquire lock" }
|
19
19
|
@ex_lock.with_lock do
|
@@ -28,29 +28,29 @@ shared_examples_for :shared_exclusive_integration do
|
|
28
28
|
|
29
29
|
mutex.synchronize do
|
30
30
|
logger.debug { "unlocking the shared lock" }
|
31
|
-
@sh_lock.unlock.
|
31
|
+
expect(@sh_lock.unlock).to be(true)
|
32
32
|
cond.wait_until { th[:got_lock] } # make sure they actually received the lock (avoid race)
|
33
|
-
th[:got_lock].
|
33
|
+
expect(th[:got_lock]).to be(true)
|
34
34
|
logger.debug { "ok, they got the lock" }
|
35
35
|
end
|
36
36
|
|
37
|
-
th.join(5).
|
37
|
+
expect(th.join(5)).to eq(th)
|
38
38
|
|
39
39
|
logger.debug { "thread joined, exclusive lock should be releasd" }
|
40
40
|
|
41
|
-
@ex_lock.
|
41
|
+
expect(@ex_lock).not_to be_locked
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
describe 'multiple shared locks acquired first' do
|
46
46
|
before do
|
47
|
-
zk3.
|
48
|
-
@sh_lock2 = ZK::Locker.shared_locker(zk3, path)
|
47
|
+
expect(zk3).not_to be_nil
|
48
|
+
@sh_lock2 = ZK::Locker.shared_locker(zk3, path)
|
49
49
|
end
|
50
50
|
it %[should not aquire a lock when highest-numbered released but others remain] do
|
51
|
-
@sh_lock.lock.
|
52
|
-
@sh_lock2.lock.
|
53
|
-
@ex_lock.lock.
|
51
|
+
expect(@sh_lock.lock).to be(true)
|
52
|
+
expect(@sh_lock2.lock).to be(true)
|
53
|
+
expect(@ex_lock.lock).to be(false)
|
54
54
|
|
55
55
|
mutex = Monitor.new
|
56
56
|
cond = mutex.new_cond
|
@@ -75,28 +75,28 @@ shared_examples_for :shared_exclusive_integration do
|
|
75
75
|
mutex.synchronize do
|
76
76
|
@ex_lock.wait_until_blocked(1)
|
77
77
|
logger.debug { "unlocking the highest shared lock" }
|
78
|
-
@sh_lock2.unlock.
|
78
|
+
expect(@sh_lock2.unlock).to be(true)
|
79
79
|
cond.wait_until { (!th[:got_lock].nil?) } # make sure they actually received the lock (avoid race)
|
80
|
-
th[:got_lock].
|
80
|
+
expect(th[:got_lock]).to be(false)
|
81
81
|
logger.debug { "they didn't get the lock." }
|
82
82
|
end
|
83
83
|
|
84
|
-
th.join(5).
|
84
|
+
expect(th.join(5)).to eq(th)
|
85
85
|
|
86
86
|
logger.debug { "thread joined, exclusive lock should be releasd" }
|
87
|
-
@sh_lock.unlock.
|
88
|
-
@ex_lock.
|
87
|
+
expect(@sh_lock.unlock).to be(true)
|
88
|
+
expect(@ex_lock).not_to be_locked
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
describe 'exclusive lock acquired first' do
|
93
93
|
it %[should block shared lock from acquiring until released] do
|
94
|
-
@ex_lock.lock.
|
95
|
-
@sh_lock.lock.
|
94
|
+
expect(@ex_lock.lock).to be(true)
|
95
|
+
expect(@sh_lock.lock).to be(false)
|
96
96
|
|
97
97
|
mutex = Monitor.new
|
98
98
|
cond = mutex.new_cond
|
99
|
-
|
99
|
+
|
100
100
|
th = Thread.new do
|
101
101
|
logger.debug { "@ex_lock trying to acquire acquire lock" }
|
102
102
|
@sh_lock.with_lock do
|
@@ -111,31 +111,31 @@ shared_examples_for :shared_exclusive_integration do
|
|
111
111
|
|
112
112
|
mutex.synchronize do
|
113
113
|
logger.debug { "unlocking the shared lock" }
|
114
|
-
@ex_lock.unlock.
|
114
|
+
expect(@ex_lock.unlock).to be(true)
|
115
115
|
cond.wait_until { th[:got_lock] } # make sure they actually received the lock (avoid race)
|
116
|
-
th[:got_lock].
|
116
|
+
expect(th[:got_lock]).to be(true)
|
117
117
|
logger.debug { "ok, they got the lock" }
|
118
118
|
end
|
119
119
|
|
120
|
-
th.join(5).
|
120
|
+
expect(th.join(5)).to eq(th)
|
121
121
|
|
122
122
|
logger.debug { "thread joined, exclusive lock should be releasd" }
|
123
123
|
|
124
|
-
@sh_lock.
|
124
|
+
expect(@sh_lock).not_to be_locked
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
128
|
describe 'shared-exclusive-shared' do
|
129
129
|
before do
|
130
|
-
zk3.
|
131
|
-
@sh_lock2 = ZK::Locker.shared_locker(zk3, path)
|
130
|
+
expect(zk3).not_to be_nil
|
131
|
+
@sh_lock2 = ZK::Locker.shared_locker(zk3, path)
|
132
132
|
end
|
133
133
|
|
134
134
|
it %[should act something like a queue] do
|
135
135
|
@array = []
|
136
136
|
|
137
|
-
@sh_lock.lock.
|
138
|
-
@sh_lock.
|
137
|
+
expect(@sh_lock.lock).to be(true)
|
138
|
+
expect(@sh_lock).to be_locked
|
139
139
|
|
140
140
|
ex_th = Thread.new do
|
141
141
|
begin
|
@@ -150,15 +150,15 @@ shared_examples_for :shared_exclusive_integration do
|
|
150
150
|
logger.debug { "about to wait for @ex_lock to be blocked" }
|
151
151
|
|
152
152
|
@ex_lock.wait_until_blocked(5)
|
153
|
-
@ex_lock.
|
153
|
+
expect(@ex_lock).to be_waiting
|
154
154
|
|
155
155
|
logger.debug { "@ex_lock is waiting" }
|
156
156
|
|
157
|
-
@ex_lock.
|
157
|
+
expect(@ex_lock).not_to be_locked
|
158
158
|
|
159
159
|
# this is the important one, does the second shared lock get blocked by
|
160
160
|
# the exclusive lock
|
161
|
-
@sh_lock2.lock.
|
161
|
+
expect(@sh_lock2.lock).not_to be(true)
|
162
162
|
|
163
163
|
sh2_th = Thread.new do
|
164
164
|
begin
|
@@ -173,19 +173,19 @@ shared_examples_for :shared_exclusive_integration do
|
|
173
173
|
logger.debug { "about to wait for @sh_lock2 to be blocked" }
|
174
174
|
|
175
175
|
@sh_lock2.wait_until_blocked(5)
|
176
|
-
@sh_lock2.
|
176
|
+
expect(@sh_lock2).to be_waiting
|
177
177
|
|
178
178
|
logger.debug { "@sh_lock2 is waiting" }
|
179
179
|
|
180
180
|
# ok, now unlock the first in the chain
|
181
181
|
@sh_lock.assert!
|
182
|
-
@sh_lock.unlock.
|
182
|
+
expect(@sh_lock.unlock).to be(true)
|
183
183
|
|
184
|
-
ex_th.join(5).
|
185
|
-
sh2_th.join(5).
|
184
|
+
expect(ex_th.join(5)).to eq(ex_th)
|
185
|
+
expect(sh2_th.join(5)).to eq(sh2_th)
|
186
186
|
|
187
|
-
@array.length.
|
188
|
-
@array.
|
187
|
+
expect(@array.length).to eq(2)
|
188
|
+
expect(@array).to eq([:ex_lock, :sh_lock2])
|
189
189
|
end
|
190
190
|
end
|
191
191
|
end # shared_exclusive_integration
|
@@ -9,17 +9,17 @@ shared_examples_for 'ZK::Locker::SharedLocker' 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
|
-
locker.lock.
|
12
|
+
expect(locker.lock).to be(true)
|
13
13
|
shl_path = locker.lock_path
|
14
14
|
|
15
|
-
locker2.lock.
|
15
|
+
expect(locker2.lock).to be(true)
|
16
16
|
|
17
|
-
locker.unlock.
|
18
|
-
locker.
|
17
|
+
expect(locker.unlock).to be(true)
|
18
|
+
expect(locker).not_to be_locked
|
19
19
|
|
20
|
-
zk.exists?(shl_path).
|
20
|
+
expect(zk.exists?(shl_path)).to be(false)
|
21
21
|
|
22
|
-
locker2.lock_path.
|
22
|
+
expect(locker2.lock_path).not_to eq(shl_path)
|
23
23
|
|
24
24
|
# convert the first shared lock path into a exclusive one
|
25
25
|
|
@@ -27,7 +27,7 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
|
|
27
27
|
|
28
28
|
zk.create(exl_path, :ephemeral => true)
|
29
29
|
|
30
|
-
|
30
|
+
expect { locker2.assert! }.to raise_error(ZK::Exceptions::LockAssertionFailedError)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -35,18 +35,18 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
|
|
35
35
|
describe %[with default options] do
|
36
36
|
it %[should work if the lock root doesn't exist] do
|
37
37
|
zk.rm_rf(ZK::Locker.default_root_lock_node)
|
38
|
-
locker.
|
38
|
+
expect(locker).to be_acquirable
|
39
39
|
end
|
40
40
|
|
41
41
|
it %[should check local state of lockedness] do
|
42
|
-
locker.lock.
|
43
|
-
locker.
|
42
|
+
expect(locker.lock).to be(true)
|
43
|
+
expect(locker).to be_acquirable
|
44
44
|
end
|
45
45
|
|
46
46
|
it %[should check if any participants would prevent us from acquiring the lock] do
|
47
47
|
ex_lock = ZK::Locker.exclusive_locker(zk, path)
|
48
|
-
ex_lock.lock.
|
49
|
-
locker.
|
48
|
+
expect(ex_lock.lock).to be(true)
|
49
|
+
expect(locker).not_to be_acquirable
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -59,13 +59,13 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it %[should acquire the first lock] do
|
62
|
-
@rval.
|
63
|
-
locker.
|
62
|
+
expect(@rval).to be(true)
|
63
|
+
expect(locker).to be_locked
|
64
64
|
end
|
65
65
|
|
66
66
|
it %[should acquire the second lock] do
|
67
|
-
@rval2.
|
68
|
-
locker2.
|
67
|
+
expect(@rval2).to be(true)
|
68
|
+
expect(locker2).to be_locked
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -77,11 +77,11 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
it %[should return false] do
|
80
|
-
@rval.
|
80
|
+
expect(@rval).to be(false)
|
81
81
|
end
|
82
82
|
|
83
83
|
it %[should not be locked] do
|
84
|
-
locker.
|
84
|
+
expect(locker).not_to be_locked
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -96,7 +96,7 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
|
|
96
96
|
it %[should acquire the lock after the write lock is released old-style] do
|
97
97
|
ary = []
|
98
98
|
|
99
|
-
locker.lock.
|
99
|
+
expect(locker.lock).to be(false)
|
100
100
|
|
101
101
|
th = Thread.new do
|
102
102
|
locker.lock(true)
|
@@ -104,24 +104,24 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
locker.wait_until_blocked(5)
|
107
|
-
locker.
|
108
|
-
locker.
|
109
|
-
ary.
|
107
|
+
expect(locker).to be_waiting
|
108
|
+
expect(locker).not_to be_locked
|
109
|
+
expect(ary).to be_empty
|
110
110
|
|
111
111
|
zk.delete(@write_lock_path)
|
112
112
|
|
113
|
-
th.join(2).
|
113
|
+
expect(th.join(2)).to eq(th)
|
114
114
|
|
115
|
-
ary.
|
116
|
-
ary.length.
|
115
|
+
expect(ary).not_to be_empty
|
116
|
+
expect(ary.length).to eq(1)
|
117
117
|
|
118
|
-
locker.
|
118
|
+
expect(locker).to be_locked
|
119
119
|
end
|
120
120
|
|
121
121
|
it %[should acquire the lock after the write lock is released new-style] do
|
122
122
|
ary = []
|
123
123
|
|
124
|
-
locker.lock.
|
124
|
+
expect(locker.lock).to be(false)
|
125
125
|
|
126
126
|
th = Thread.new do
|
127
127
|
locker.lock(:wait => true)
|
@@ -129,18 +129,18 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
locker.wait_until_blocked(5)
|
132
|
-
locker.
|
133
|
-
locker.
|
134
|
-
ary.
|
132
|
+
expect(locker).to be_waiting
|
133
|
+
expect(locker).not_to be_locked
|
134
|
+
expect(ary).to be_empty
|
135
135
|
|
136
136
|
zk.delete(@write_lock_path)
|
137
137
|
|
138
|
-
th.join(2).
|
138
|
+
expect(th.join(2)).to eq(th)
|
139
139
|
|
140
|
-
ary.
|
141
|
-
ary.length.
|
140
|
+
expect(ary).not_to be_empty
|
141
|
+
expect(ary.length).to eq(1)
|
142
142
|
|
143
|
-
locker.
|
143
|
+
expect(locker).to be_locked
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -150,9 +150,9 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
|
|
150
150
|
|
151
151
|
write_lock_dir = File.dirname(@write_lock_path)
|
152
152
|
|
153
|
-
zk.children(write_lock_dir).length.
|
153
|
+
expect(zk.children(write_lock_dir).length).to eq(1)
|
154
154
|
|
155
|
-
locker.lock.
|
155
|
+
expect(locker.lock).to be(false)
|
156
156
|
|
157
157
|
th = Thread.new do
|
158
158
|
begin
|
@@ -164,16 +164,16 @@ shared_examples_for 'ZK::Locker::SharedLocker' do
|
|
164
164
|
end
|
165
165
|
|
166
166
|
locker.wait_until_blocked(5)
|
167
|
-
locker.
|
168
|
-
locker.
|
169
|
-
ary.
|
167
|
+
expect(locker).to be_waiting
|
168
|
+
expect(locker).not_to be_locked
|
169
|
+
expect(ary).to be_empty
|
170
170
|
|
171
|
-
th.join(2).
|
171
|
+
expect(th.join(2)).to eq(th)
|
172
172
|
|
173
|
-
zk.children(write_lock_dir).length.
|
173
|
+
expect(zk.children(write_lock_dir).length).to eq(1)
|
174
174
|
|
175
|
-
ary.
|
176
|
-
@exc.
|
175
|
+
expect(ary).to be_empty
|
176
|
+
expect(@exc).to be_kind_of(ZK::Exceptions::LockWaitTimeoutError)
|
177
177
|
end
|
178
178
|
|
179
179
|
end
|
data/spec/zk/locker_spec.rb
CHANGED
@@ -14,9 +14,9 @@ describe ZK::Locker do
|
|
14
14
|
|
15
15
|
ZK::Locker.cleanup(@zk)
|
16
16
|
|
17
|
-
|
17
|
+
expect { locker.assert! }.not_to raise_error
|
18
18
|
|
19
|
-
bogus_lock_dir_names.each { |n| @zk.stat("#{ZK::Locker.default_root_lock_node}/#{n}").
|
19
|
+
bogus_lock_dir_names.each { |n| expect(@zk.stat("#{ZK::Locker.default_root_lock_node}/#{n}")).not_to exist }
|
20
20
|
|
21
21
|
end
|
22
22
|
end
|
data/spec/zk/module_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe ZK do
|
|
21
21
|
|
22
22
|
describe %[with a chrooted connection string and a :chroot => '/path'] do
|
23
23
|
it %[should raise an ArgumentError] do
|
24
|
-
|
24
|
+
expect { @zk = ZK.new("#{connection_host}/zktest", :chroot => '/zktest') }.to raise_error(ArgumentError)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -29,7 +29,7 @@ describe ZK do
|
|
29
29
|
before { @zk = ZK.new }
|
30
30
|
|
31
31
|
it %[should create a default connection] do
|
32
|
-
@zk.
|
32
|
+
expect(@zk).to be_connected
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -54,10 +54,10 @@ describe ZK do
|
|
54
54
|
before { @zk = ZK.new(:chroot => chroot_path) }
|
55
55
|
|
56
56
|
it %[should use the default connection string, create the chroot and return the connection] do
|
57
|
-
@zk.exists?('/').
|
57
|
+
expect(@zk.exists?('/')).to be(true)
|
58
58
|
@zk.create('/blah', 'data')
|
59
59
|
|
60
|
-
@unchroot.get("#{chroot_path}/blah").first.
|
60
|
+
expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -69,10 +69,10 @@ describe ZK do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it %[should create the chroot path and then return the connection] do
|
72
|
-
@zk.exists?('/').
|
72
|
+
expect(@zk.exists?('/')).to be(true)
|
73
73
|
@zk.create('/blah', 'data')
|
74
74
|
|
75
|
-
@unchroot.get("#{chroot_path}/blah").first.
|
75
|
+
expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -82,26 +82,26 @@ describe ZK do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
it %[should create the chroot path and then return the connection] do
|
85
|
-
@zk.exists?('/').
|
85
|
+
expect(@zk.exists?('/')).to be(true)
|
86
86
|
@zk.create('/blah', 'data')
|
87
87
|
|
88
|
-
@unchroot.get("#{chroot_path}/blah").first.
|
88
|
+
expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
describe %[and :chroot => :check] do
|
93
93
|
it %[should barf with a ChrootPathDoesNotExistError] do
|
94
|
-
|
94
|
+
expect do
|
95
95
|
# assign in case of a bug, that way this connection will get torn down
|
96
96
|
@zk = ZK.new("#{connection_host}#{chroot_path}", :chroot => :check)
|
97
|
-
end.
|
97
|
+
end.to raise_error(ZK::Exceptions::ChrootPathDoesNotExistError)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
101
|
describe %[and :chroot => :do_nothing] do
|
102
102
|
it %[should return a connection in a weird state] do
|
103
103
|
@zk = ZK.new("#{connection_host}#{chroot_path}", :chroot => :do_nothing)
|
104
|
-
|
104
|
+
expect { @zk.get('/') }.to raise_error(ZK::Exceptions::NoNode)
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -109,10 +109,10 @@ describe ZK do
|
|
109
109
|
before { @zk = ZK.new(connection_host, :chroot => chroot_path) }
|
110
110
|
|
111
111
|
it %[should create the chroot path and then return the connection] do
|
112
|
-
@zk.exists?('/').
|
112
|
+
expect(@zk.exists?('/')).to be(true)
|
113
113
|
@zk.create('/blah', 'data')
|
114
114
|
|
115
|
-
@unchroot.get("#{chroot_path}/blah").first.
|
115
|
+
expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end # as a connection string
|
@@ -125,10 +125,10 @@ describe ZK do
|
|
125
125
|
before { @zk = ZK.new(:chroot => chroot_path) }
|
126
126
|
|
127
127
|
it %[should use the default connection string and totally work] do
|
128
|
-
@zk.exists?('/').
|
128
|
+
expect(@zk.exists?('/')).to be(true)
|
129
129
|
@zk.create('/blah', 'data')
|
130
130
|
|
131
|
-
@unchroot.get("#{chroot_path}/blah").first.
|
131
|
+
expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -139,10 +139,10 @@ describe ZK do
|
|
139
139
|
end
|
140
140
|
|
141
141
|
it %[should totally work] do
|
142
|
-
@zk.exists?('/').
|
142
|
+
expect(@zk.exists?('/')).to be(true)
|
143
143
|
@zk.create('/blah', 'data')
|
144
144
|
|
145
|
-
@unchroot.get("#{chroot_path}/blah").first.
|
145
|
+
expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
@@ -152,26 +152,26 @@ describe ZK do
|
|
152
152
|
end
|
153
153
|
|
154
154
|
it %[should totally work] do
|
155
|
-
@zk.exists?('/').
|
155
|
+
expect(@zk.exists?('/')).to be(true)
|
156
156
|
@zk.create('/blah', 'data')
|
157
157
|
|
158
|
-
@unchroot.get("#{chroot_path}/blah").first.
|
158
|
+
expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
162
|
describe %[and :chroot => :check] do
|
163
163
|
it %[should totally work] do
|
164
|
-
|
164
|
+
expect do
|
165
165
|
# assign in case of a bug, that way this connection will get torn down
|
166
166
|
@zk = ZK.new("#{connection_host}#{chroot_path}", :chroot => :check)
|
167
|
-
end.
|
167
|
+
end.not_to raise_error
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
171
|
describe %[and :chroot => :do_nothing] do
|
172
172
|
it %[should totally work] do
|
173
173
|
@zk = ZK.new("#{connection_host}#{chroot_path}", :chroot => :do_nothing)
|
174
|
-
|
174
|
+
expect { @zk.get('/') }.not_to raise_error
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
@@ -179,15 +179,15 @@ describe ZK do
|
|
179
179
|
before { @zk = ZK.new(connection_host, :chroot => chroot_path) }
|
180
180
|
|
181
181
|
it %[should totally work] do
|
182
|
-
@zk.exists?('/').
|
182
|
+
expect(@zk.exists?('/')).to be(true)
|
183
183
|
@zk.create('/blah', 'data')
|
184
184
|
|
185
|
-
@unchroot.get("#{chroot_path}/blah").first.
|
185
|
+
expect(@unchroot.get("#{chroot_path}/blah").first).to eq('data')
|
186
186
|
end
|
187
187
|
end
|
188
188
|
end # as a connection string
|
189
189
|
end # that exists
|
190
|
-
end # with a chroot
|
190
|
+
end # with a chroot
|
191
191
|
end # :new
|
192
192
|
end # ZK
|
193
193
|
|