Sha256: 748808ce1e516760e70954397aabf2c1ec5d0d805f8e6f11c8da2237aca53334

Contents?: true

Size: 1.58 KB

Versions: 8

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'
require 'shared/connection_examples'

describe 'Zookeeper chrooted' do
  let(:path) { "/_zkchroottest_" }
  let(:data) { "underpants" } 
  let(:chroot_path) { '/slyphon-zookeeper-chroot' }

  let(:connection_string) { "localhost:2181#{chroot_path}" }

  before do
    @zk = Zookeeper.new(connection_string)
  end

  after do
    @zk and @zk.close
  end

  def zk
    @zk
  end

  describe 'non-existent' do
    describe 'with existing parent' do
      let(:chroot_path) { '/one-level' }

      describe 'create' do
        before do
          with_open_zk do |z|
            rm_rf(z, chroot_path)
          end
        end

        it %[should successfully create the path] do
          rv = zk.create(:path => '/', :data => '')
          rv[:rc].should be_zero
          rv[:path].should == ''
        end
      end
    end

    describe 'with missing parent' do
      let(:chroot_path) { '/deeply/nested/path' }

      describe 'create' do
        before do
          with_open_zk do |z|
            rm_rf(z, chroot_path)
          end
        end

        it %[should return ZNONODE] do
          rv = zk.create(:path => '/', :data => '')
          rv[:rc].should_not be_zero
          rv[:rc].should == ZookeeperExceptions::ZNONODE
        end
      end
    end
  end


  describe do
    before :all do
      Zookeeper.logger.warn "running before :all"

      with_open_zk do |z|
        z.create(:path => chroot_path, :data => '')
      end
    end

    after :all do
      with_open_zk do |z|
        rm_rf(z, chroot_path)
      end
    end

    it_should_behave_like "connection"
  end
end


Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
zookeeper-0.9.4 spec/chrooted_connection_spec.rb
zookeeper-0.9.4-java spec/chrooted_connection_spec.rb
slyphon-zookeeper-0.9.4 spec/chrooted_connection_spec.rb
slyphon-zookeeper-0.9.4-java spec/chrooted_connection_spec.rb
slyphon-zookeeper-0.9.3 spec/chrooted_connection_spec.rb
slyphon-zookeeper-0.9.3-java spec/chrooted_connection_spec.rb
zookeeper-0.9.3 spec/chrooted_connection_spec.rb
zookeeper-0.9.3-java spec/chrooted_connection_spec.rb