kazoo-ruby 0.3.3 → 0.4.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 +4 -4
- data/lib/kazoo.rb +7 -0
- data/lib/kazoo/broker.rb +31 -16
- data/lib/kazoo/cli/consumers.rb +36 -1
- data/lib/kazoo/cli/topics.rb +14 -1
- data/lib/kazoo/cluster.rb +61 -29
- data/lib/kazoo/consumergroup.rb +148 -34
- data/lib/kazoo/partition.rb +9 -4
- data/lib/kazoo/replica_assigner.rb +74 -0
- data/lib/kazoo/subscription.rb +215 -0
- data/lib/kazoo/topic.rb +128 -82
- data/lib/kazoo/version.rb +1 -1
- data/test/functional/functional_consumergroup_test.rb +105 -53
- data/test/functional/functional_subscription_test.rb +62 -0
- data/test/functional/functional_topic_management_test.rb +25 -2
- data/test/replica_assigner_test.rb +80 -0
- data/test/subscription_test.rb +148 -0
- data/test/topic_test.rb +6 -19
- metadata +10 -2
data/test/topic_test.rb
CHANGED
@@ -7,9 +7,9 @@ class TopicTest < Minitest::Test
|
|
7
7
|
@cluster = mock_cluster
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def test_set_partitions_from_json
|
11
11
|
json_payload = '{"version":1,"partitions":{"2":[1,2,3],"1":[3,1,2],"3":[2,3,1],"0":[3,2,1]}}'
|
12
|
-
topic =
|
12
|
+
topic = @cluster.topic('test.4').set_partitions_from_json(json_payload)
|
13
13
|
|
14
14
|
assert_equal 4, topic.partitions.length
|
15
15
|
assert_equal [3,2,1], topic.partitions[0].replicas.map(&:id)
|
@@ -20,19 +20,19 @@ class TopicTest < Minitest::Test
|
|
20
20
|
|
21
21
|
def test_replication_factor
|
22
22
|
json_payload = '{"version":1,"partitions":{"2":[1,2,3],"1":[3,1,2],"3":[2,3,1],"0":[3,2,1]}}'
|
23
|
-
topic =
|
23
|
+
topic = @cluster.topic('test.4').set_partitions_from_json(json_payload)
|
24
24
|
assert_equal 3, topic.replication_factor
|
25
25
|
|
26
26
|
json_payload = '{"version":1,"partitions":{"2":[2,3],"1":[2],"3":[2,3,1],"0":[3,2,1]}}'
|
27
|
-
topic =
|
27
|
+
topic = @cluster.topic('test.4').set_partitions_from_json(json_payload)
|
28
28
|
assert_equal 1, topic.replication_factor
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def test_topic_under_replicated?
|
32
32
|
refute @cluster.topics['test.1'].under_replicated?
|
33
33
|
refute @cluster.topics['test.1'].partitions[0].under_replicated?
|
34
34
|
|
35
|
-
@cluster.topics['test.1'].partitions[0].expects(:isr).returns([@cluster.brokers[1]])
|
35
|
+
@cluster.topics['test.1'].partitions[0].expects(:isr).returns([@cluster.brokers[1]]).twice
|
36
36
|
|
37
37
|
assert @cluster.topics['test.1'].partitions[0].under_replicated?
|
38
38
|
assert @cluster.topics['test.1'].under_replicated?
|
@@ -73,19 +73,6 @@ class TopicTest < Minitest::Test
|
|
73
73
|
refute t.valid?
|
74
74
|
end
|
75
75
|
|
76
|
-
def test_sequentially_assign_partitions
|
77
|
-
topic = Kazoo::Topic.new(@cluster, 'test.new')
|
78
|
-
|
79
|
-
assert_raises(ArgumentError) { topic.send(:sequentially_assign_partitions, 4, 100) }
|
80
|
-
|
81
|
-
topic.send(:sequentially_assign_partitions, 4, 3)
|
82
|
-
|
83
|
-
assert_equal 4, topic.partitions.length
|
84
|
-
assert_equal 3, topic.replication_factor
|
85
|
-
assert topic.partitions.all? { |p| p.replicas.length == 3 }
|
86
|
-
assert topic.valid?
|
87
|
-
end
|
88
|
-
|
89
76
|
def test_partitions_as_json
|
90
77
|
assignment = @cluster.topics['test.1'].send(:partitions_as_json)
|
91
78
|
assert_equal 1, assignment.length
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kazoo-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -122,13 +122,18 @@ files:
|
|
122
122
|
- lib/kazoo/cluster.rb
|
123
123
|
- lib/kazoo/consumergroup.rb
|
124
124
|
- lib/kazoo/partition.rb
|
125
|
+
- lib/kazoo/replica_assigner.rb
|
126
|
+
- lib/kazoo/subscription.rb
|
125
127
|
- lib/kazoo/topic.rb
|
126
128
|
- lib/kazoo/version.rb
|
127
129
|
- test/broker_test.rb
|
128
130
|
- test/cluster_test.rb
|
129
131
|
- test/functional/functional_consumergroup_test.rb
|
132
|
+
- test/functional/functional_subscription_test.rb
|
130
133
|
- test/functional/functional_topic_management_test.rb
|
131
134
|
- test/partition_test.rb
|
135
|
+
- test/replica_assigner_test.rb
|
136
|
+
- test/subscription_test.rb
|
132
137
|
- test/test_helper.rb
|
133
138
|
- test/topic_test.rb
|
134
139
|
homepage: https://github.com/wvanbergen/kazoo
|
@@ -159,7 +164,10 @@ test_files:
|
|
159
164
|
- test/broker_test.rb
|
160
165
|
- test/cluster_test.rb
|
161
166
|
- test/functional/functional_consumergroup_test.rb
|
167
|
+
- test/functional/functional_subscription_test.rb
|
162
168
|
- test/functional/functional_topic_management_test.rb
|
163
169
|
- test/partition_test.rb
|
170
|
+
- test/replica_assigner_test.rb
|
171
|
+
- test/subscription_test.rb
|
164
172
|
- test/test_helper.rb
|
165
173
|
- test/topic_test.rb
|