zk 0.8.2 → 0.8.3

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.
@@ -1,3 +1,3 @@
1
1
  module ZK
2
- VERSION = "0.8.2"
2
+ VERSION = "0.8.3"
3
3
  end
@@ -290,9 +290,7 @@ describe ZK::Election do
290
290
  end
291
291
 
292
292
  it %[should be palin who is leader] do
293
- pending_192 "this test is flaky" do
294
- @palin.should be_leader
295
- end
293
+ @palin.should be_leader
296
294
  end
297
295
 
298
296
  it %[should have seen both the death and life events] do
@@ -301,9 +299,7 @@ describe ZK::Election do
301
299
  end
302
300
 
303
301
  it %[should see the data of the new leader] do
304
- pending_192 "this test is buggy under 1.9.2" do
305
- @observer.leader_data.should == 'palin'
306
- end
302
+ @observer.leader_data.should == 'palin'
307
303
  end
308
304
  end
309
305
  end
@@ -4,43 +4,29 @@ describe ZK do
4
4
  before do
5
5
  @zk = ZK.new("localhost:#{ZK_TEST_PORT}", :watcher => nil)
6
6
 
7
- # @zk.set_debug_level(:debug) unless defined?(::JRUBY_VERSION)
7
+ @base_path = "/zktests"
8
+ @zk.rm_rf(@base_path)
9
+ @zk.mkdir_p(@base_path)
10
+ end
8
11
 
9
- wait_until{ @zk.connected? }
12
+ after do
13
+ @zk.rm_rf(@base_path)
14
+ @zk.close!
10
15
  end
11
16
 
12
17
  describe ZK, "with no paths" do
13
- before(:each) do
14
- delete_test!
15
- end
16
-
17
- after(:each) do
18
- delete_test!
19
- @zk.close!
20
- wait_until{ @zk.closed? }
21
- end
22
-
23
- def delete_test!
24
- if (@zk.exists?('/test'))
25
- @zk.children("/test").each do |child|
26
- @zk.delete("/test/#{child}")
27
- end
28
- @zk.delete('/test')
29
- end
30
- end
31
-
32
18
  it "should not exist" do
33
- @zk.exists?("/test").should be_false
19
+ @zk.exists?("#{@base_path}/test").should be_false
34
20
  end
35
21
 
36
22
  it "should create a path" do
37
- @zk.create("/test", "test_data", :mode => :ephemeral).should == "/test"
23
+ @zk.create("#{@base_path}/test", "test_data", :mode => :ephemeral).should == "#{@base_path}/test"
38
24
  end
39
25
 
40
26
  it "should be able to set the data" do
41
- @zk.create("/test", "something", :mode => :ephemeral)
42
- @zk.set("/test", "somethingelse")
43
- @zk.get("/test").first.should == "somethingelse"
27
+ @zk.create("#{@base_path}/test", "something", :mode => :ephemeral)
28
+ @zk.set("#{@base_path}/test", "somethingelse")
29
+ @zk.get("#{@base_path}/test").first.should == "somethingelse"
44
30
  end
45
31
 
46
32
  it "should raise an exception for a non existent path" do
@@ -48,27 +34,27 @@ describe ZK do
48
34
  end
49
35
 
50
36
  it "should create a path with sequence set" do
51
- @zk.create("/test", "test_data", :mode => :persistent_sequential).should =~ /test(\d+)/
37
+ @zk.create("#{@base_path}/test", "test_data", :mode => :persistent_sequential).should =~ /test(\d+)/
52
38
  end
53
39
 
54
40
  it "should create an ephemeral path" do
55
- @zk.create("/test", "test_data", :mode => :ephemeral).should == "/test"
41
+ @zk.create("#{@base_path}/test", "test_data", :mode => :ephemeral).should == "#{@base_path}/test"
56
42
  end
57
43
 
58
44
  it "should remove ephemeral path when client session ends" do
59
- @zk.create("/test", "test_data", :mode => :ephemeral).should == "/test"
60
- @zk.exists?("/test").should_not be_nil
45
+ @zk.create("#{@base_path}/test", "test_data", :mode => :ephemeral).should == "#{@base_path}/test"
46
+ @zk.exists?("#{@base_path}/test").should_not be_nil
61
47
  @zk.close!
62
48
  wait_until(2) { !@zk.connected? }
63
49
  @zk.should_not be_connected
64
50
 
65
51
  @zk = ZK.new("localhost:#{ZK_TEST_PORT}", :watcher => nil)
66
52
  wait_until{ @zk.connected? }
67
- @zk.exists?("/test").should be_false
53
+ @zk.exists?("#{@base_path}/test").should be_false
68
54
  end
69
55
 
70
56
  it "should remove sequential ephemeral path when client session ends" do
71
- created = @zk.create("/test", "test_data", :mode => :ephemeral_sequential)
57
+ created = @zk.create("#{@base_path}/test", "test_data", :mode => :ephemeral_sequential)
72
58
  created.should =~ /test(\d+)/
73
59
  @zk.exists?(created).should_not be_nil
74
60
  @zk.close!
@@ -77,40 +63,23 @@ describe ZK do
77
63
  wait_until{ @zk.connected? }
78
64
  @zk.exists?(created).should be_false
79
65
  end
80
-
81
66
  end
82
67
 
83
68
  describe ZK, "with a path" do
84
69
  before(:each) do
85
- delete_test!
86
- @zk.create("/test", "test_data", :mode => :persistent)
87
- end
88
-
89
- after(:each) do
90
- delete_test!
91
- @zk.close!
92
- wait_until{ @zk.closed? }
93
- end
94
-
95
- def delete_test!
96
- if (@zk.exists?('/test'))
97
- @zk.children("/test").each do |child|
98
- @zk.delete("/test/#{child}")
99
- end
100
- @zk.delete('/test')
101
- end
70
+ @zk.create("#{@base_path}/test", "test_data", :mode => :persistent)
102
71
  end
103
72
 
104
73
  it "should return a stat" do
105
- @zk.stat("/test").should be_instance_of(ZookeeperStat::Stat)
74
+ @zk.stat("#{@base_path}/test").should be_instance_of(ZookeeperStat::Stat)
106
75
  end
107
76
 
108
77
  it "should return a boolean" do
109
- @zk.exists?("/test").should be_true
78
+ @zk.exists?("#{@base_path}/test").should be_true
110
79
  end
111
80
 
112
81
  it "should get data and stat" do
113
- data, stat = @zk.get("/test")
82
+ data, stat = @zk.get("#{@base_path}/test")
114
83
  data.should == "test_data"
115
84
  stat.should be_a_kind_of(ZookeeperStat::Stat)
116
85
  stat.created_time.should_not == 0
@@ -118,59 +87,41 @@ describe ZK do
118
87
 
119
88
  it "should set data with a file" do
120
89
  file = File.read('spec/test_file.txt')
121
- @zk.set("/test", file)
122
- @zk.get("/test").first.should == file
90
+ @zk.set("#{@base_path}/test", file)
91
+ @zk.get("#{@base_path}/test").first.should == file
123
92
  end
124
93
 
125
94
  it "should delete path" do
126
- @zk.delete("/test")
127
- @zk.exists?("/test").should be_false
95
+ @zk.delete("#{@base_path}/test")
96
+ @zk.exists?("#{@base_path}/test").should be_false
128
97
  end
129
98
 
130
99
  it "should create a child path" do
131
- @zk.create("/test/child", "child", :mode => :ephemeral).should == "/test/child"
100
+ @zk.create("#{@base_path}/test/child", "child", :mode => :ephemeral).should == "#{@base_path}/test/child"
132
101
  end
133
102
 
134
103
  it "should create sequential child paths" do
135
- (child1 = @zk.create("/test/child", "child1", :mode => :persistent_sequential)).should =~ /\/test\/child(\d+)/
136
- (child2 = @zk.create("/test/child", "child2", :mode => :persistent_sequential)).should =~ /\/test\/child(\d+)/
137
- children = @zk.children("/test")
104
+ (child1 = @zk.create("#{@base_path}/test/child", "child1", :mode => :persistent_sequential)).should =~ /\/test\/child(\d+)/
105
+ (child2 = @zk.create("#{@base_path}/test/child", "child2", :mode => :persistent_sequential)).should =~ /\/test\/child(\d+)/
106
+ children = @zk.children("#{@base_path}/test")
138
107
  children.length.should == 2
139
108
  children.should be_include(child1.match(/\/test\/(child\d+)/)[1])
140
109
  children.should be_include(child2.match(/\/test\/(child\d+)/)[1])
141
110
  end
142
111
 
143
112
  it "should have no children" do
144
- @zk.children("/test").should be_empty
113
+ @zk.children("#{@base_path}/test").should be_empty
145
114
  end
146
-
147
115
  end
148
116
 
149
117
  describe ZK, "with children" do
150
-
151
118
  before(:each) do
152
- delete_test!
153
- @zk.create("/test", "test_data", :mode => :persistent)
154
- @zk.create("/test/child", "child", :mode => "persistent").should == "/test/child"
155
- end
156
-
157
- after(:each) do
158
- delete_test!
159
- @zk.close!
160
- wait_until{ @zk.closed? }
161
- end
162
-
163
- def delete_test!
164
- if (@zk.exists?('/test'))
165
- @zk.children("/test").each do |child|
166
- @zk.delete("/test/#{child}")
167
- end
168
- @zk.delete('/test')
169
- end
119
+ @zk.create("#{@base_path}/test", "test_data", :mode => :persistent)
120
+ @zk.create("#{@base_path}/test/child", "child", :mode => "persistent").should == "#{@base_path}/test/child"
170
121
  end
171
122
 
172
123
  it "should get children" do
173
- @zk.children("/test").should eql(["child"])
124
+ @zk.children("#{@base_path}/test").should eql(["child"])
174
125
  end
175
126
  end
176
127
  end
data/zk.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.summary = %q{A high-level wrapper around the zookeeper driver}
13
13
  s.description = s.summary
14
14
 
15
- s.add_runtime_dependency 'slyphon-zookeeper', '~> 0.2.1'
15
+ s.add_runtime_dependency 'slyphon-zookeeper', '~> 0.2.3'
16
16
 
17
17
  s.add_development_dependency 'rspec', '~> 2.4.0'
18
18
  s.add_development_dependency 'wirble'
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: 59
4
+ hash: 57
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 2
10
- version: 0.8.2
9
+ - 3
10
+ version: 0.8.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonathan D. Simms
@@ -27,12 +27,12 @@ dependencies:
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
- hash: 21
30
+ hash: 17
31
31
  segments:
32
32
  - 0
33
33
  - 2
34
- - 1
35
- version: 0.2.1
34
+ - 3
35
+ version: 0.2.3
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency