zk 0.8.7 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -9,12 +9,17 @@
9
9
 
10
10
  gemset_name = 'zk'
11
11
 
12
- %w[1.9.3 jruby].each do |rvm_ruby|
12
+ %w[1.8.7 1.9.2 1.9.3 jruby].each do |rvm_ruby|
13
13
  ruby_with_gemset = "#{rvm_ruby}@#{gemset_name}"
14
- bundle_task_name = "mb:#{rvm_ruby}:bundle_install"
15
- rspec_task_name = "mb:#{rvm_ruby}:run_rspec"
14
+ create_gemset_task_name = "mb:#{rvm_ruby}:create_gemset"
15
+ bundle_task_name = "mb:#{rvm_ruby}:bundle_install"
16
+ rspec_task_name = "mb:#{rvm_ruby}:run_rspec"
16
17
 
17
- task bundle_task_name do
18
+ task create_gemset_task_name do
19
+ sh "rvm #{rvm_ruby} do rvm gemset create #{gemset_name}"
20
+ end
21
+
22
+ task bundle_task_name => create_gemset_task_name do
18
23
  rm_f 'Gemfile.lock'
19
24
  sh "rvm #{ruby_with_gemset} do bundle install"
20
25
  end
@@ -23,6 +28,6 @@ gemset_name = 'zk'
23
28
  sh "rvm #{ruby_with_gemset} do bundle exec rspec spec --fail-fast"
24
29
  end
25
30
 
26
- task "mb:test_all_rubies" => rspec_task_name
31
+ task "mb:test_all" => rspec_task_name
27
32
  end
28
33
 
@@ -25,7 +25,7 @@ module ZK
25
25
  rescue Exceptions::NoNode
26
26
  if File.dirname(path) == '/'
27
27
  # ok, we're screwed, blow up
28
- raise KeeperException, "could not create '/', something is wrong", caller
28
+ raise Exceptions::NonExistentRootError, "could not create '/', are you chrooted into a non-existent path?", caller
29
29
  end
30
30
 
31
31
  mkdir_p(File.dirname(path))
@@ -96,6 +96,10 @@ module ZK
96
96
 
97
97
  # raised when assert_locked_for_share! is called and no shared lock is held
98
98
  class MustBeShareLockedException < ZKError; end
99
+
100
+ # raised for certain operations when using a chrooted connection, but the
101
+ # root doesn't exist.
102
+ class NonExistentRootError < ZKError; end
99
103
  end
100
104
  end
101
105
 
data/lib/z_k/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ZK
2
- VERSION = "0.8.7"
2
+ VERSION = "0.8.8"
3
3
  end
@@ -393,33 +393,53 @@ describe "ZK::Locker chrooted" do
393
393
  let(:chroot_path) { '/_zk_chroot_' }
394
394
 
395
395
  let(:zk) { ZK.new("localhost:#{ZK_TEST_PORT}#{chroot_path}") }
396
- let(:zk2) { ZK.new("localhost:#{ZK_TEST_PORT}#{chroot_path}") }
397
- let(:zk3) { ZK.new("localhost:#{ZK_TEST_PORT}#{chroot_path}") }
398
396
 
399
- let(:connections) { [zk, zk2, zk3] }
397
+ describe 'when the chroot exists' do
398
+ let(:zk2) { ZK.new("localhost:#{ZK_TEST_PORT}#{chroot_path}") }
399
+ let(:zk3) { ZK.new("localhost:#{ZK_TEST_PORT}#{chroot_path}") }
400
400
 
401
- let(:path) { "shlock" }
402
- let(:root_lock_path) { "/_zklocking/#{path}" }
401
+ let(:connections) { [zk, zk2, zk3] }
403
402
 
404
- before do
405
- ZK.open("localhost:#{ZK_TEST_PORT}") do |zk|
406
- zk.mkdir_p(chroot_path)
403
+ let(:path) { "shlock" }
404
+ let(:root_lock_path) { "/_zklocking/#{path}" }
405
+
406
+ before do
407
+ ZK.open("localhost:#{ZK_TEST_PORT}") do |zk|
408
+ zk.mkdir_p(chroot_path)
409
+ end
410
+
411
+ wait_until{ connections.all?(&:connected?) }
407
412
  end
408
413
 
409
- wait_until{ connections.all?(&:connected?) }
414
+ after do
415
+ connections.each { |c| c.close! }
416
+ wait_until { !connections.any?(&:connected?) }
417
+
418
+ ZK.open("localhost:#{ZK_TEST_PORT}") do |zk|
419
+ zk.rm_rf(chroot_path)
420
+ end
421
+ end
422
+
423
+ it_should_behave_like 'SharedLocker'
424
+ it_should_behave_like 'ExclusiveLocker'
425
+ it_should_behave_like 'shared-exclusive interaction'
410
426
  end
411
427
 
412
- after do
413
- connections.each { |c| c.close! }
414
- wait_until { !connections.any?(&:connected?) }
428
+ describe "when the root doesn't exist" do
429
+ let(:lock_name) { 'master' }
430
+
431
+ it %[should raise a NonExistentRootError] do
432
+ @got_lock = false
433
+
434
+ lambda do
435
+ zk.with_lock(lock_name) do
436
+ @got_lock = true
437
+ end
438
+ end.should raise_error(ZK::Exceptions::NonExistentRootError)
439
+
415
440
 
416
- ZK.open("localhost:#{ZK_TEST_PORT}") do |zk|
417
- zk.rm_rf(chroot_path)
441
+ @got_lock.should_not be_true
418
442
  end
419
443
  end
420
-
421
- it_should_behave_like 'SharedLocker'
422
- it_should_behave_like 'ExclusiveLocker'
423
- it_should_behave_like 'shared-exclusive interaction'
424
444
  end
425
445
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 47
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 7
10
- version: 0.8.7
9
+ - 8
10
+ version: 0.8.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonathan D. Simms
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-04-11 00:00:00 Z
19
+ date: 2012-04-13 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: slyphon-zookeeper
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  requirements: []
185
185
 
186
186
  rubyforge_project:
187
- rubygems_version: 1.8.10
187
+ rubygems_version: 1.8.15
188
188
  signing_key:
189
189
  specification_version: 3
190
190
  summary: A high-level wrapper around the zookeeper driver