Sha256: 2bc76b60d82550bee48d51143fd73123d72f9971a817f4cd36970c759013a383

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'
require 'dcell/registries/zk_adapter'

describe DCell::Registry::ZkAdapter, :pending => TEST_ADEPTER != 'zk' && "no zookeeper" do
  subject { DCell::Registry::ZkAdapter.new TEST_DB[:zk] }
  it_behaves_like "a DCell registry" do
    context "when one znode changes" do
      it "updates a node" do
        expect(DCell::Node).to receive(:update).with("foo")
        subject.set_node("foo", "tcp://fooaddress")
        # WARNING: only by calling get_node we renew the watcher
        subject.get_node("foo").should eq("tcp://fooaddress")
        subject.set_node("foo", "tcp://newaddress")
        sleep 0.8 # takes some time to zookeeper watchers to take full effect
      end
    end
    context "when one znode is deleted" do
      it "deletes a node" do
        expect(DCell::Node).to receive(:remove).with("foo")
        subject.set_node("foo", "tcp://fooaddress")
        # WARNING: only by calling get_node we renew the watcher
        subject.get_node("foo").should eq("tcp://fooaddress")
        subject.remove_node "foo"
        sleep 0.8 # takes some time to zookeeper watchers to take full effect
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
dcell-0.16.1 spec/dcell/registries/zk_adapter_spec.rb
stn-dcell-0.16.0 spec/dcell/registries/zk_adapter_spec.rb