elastomer-cli 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/elastomer/cli/shard.rb +29 -1
- data/lib/elastomer/cli/version.rb +1 -1
- data/test/shard_test.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1fbcdfaa586df444cfc13d9fd1e5f86ec16fb3e
|
4
|
+
data.tar.gz: a2daa64a35ec3d963b593227fe8219ca6a56351e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bccc903e4970134e2b7e99a9f25c0842a985a038075ff9a197cabf5810ab714d02ad227964e234d3a9c541dec2306c3629b32a0711940042c1bcf92de9fff0c2
|
7
|
+
data.tar.gz: 297fd892c58f723129f4698a9c577df2277850f04857e1dfbfc54d60af8661596b39f4509cc8d677d5ad505d00773a198b086f33415b9bbbfd86b8edcd6d5925
|
data/CHANGELOG.md
CHANGED
data/lib/elastomer/cli/shard.rb
CHANGED
@@ -9,7 +9,7 @@ module Elastomer
|
|
9
9
|
no_commands do
|
10
10
|
def stats_table
|
11
11
|
Terminal::Table.new do |table|
|
12
|
-
table <<
|
12
|
+
table << [nil] + normalized_node_names
|
13
13
|
table << generate_row("total", node_data)
|
14
14
|
table << :separator
|
15
15
|
|
@@ -160,6 +160,34 @@ module Elastomer
|
|
160
160
|
@node_names ||= node_data.keys.sort
|
161
161
|
end
|
162
162
|
|
163
|
+
# Given the list of node names, extract the first unique name segment
|
164
|
+
# and use that as the normalized node name. The node name is divided
|
165
|
+
# into segments by splitting on the dash "-" character.
|
166
|
+
#
|
167
|
+
# Given the followin node names:
|
168
|
+
#
|
169
|
+
# ["githubsearch3-storage1-cp1-prd", "githubsearch3-storage2-cp1-prd"]
|
170
|
+
#
|
171
|
+
# the resulting normalized names would be:
|
172
|
+
#
|
173
|
+
# ["storage1", "storage2"]
|
174
|
+
#
|
175
|
+
def normalized_node_names
|
176
|
+
ary = node_names.map {|name| name.split("-")}
|
177
|
+
|
178
|
+
names = []
|
179
|
+
|
180
|
+
ary.first.length.times do |col|
|
181
|
+
name_part = ary.map {|row| row[col]}
|
182
|
+
if name_part.uniq.length != 1
|
183
|
+
names = name_part
|
184
|
+
break
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
names
|
189
|
+
end
|
190
|
+
|
163
191
|
end
|
164
192
|
end
|
165
193
|
end
|
data/test/shard_test.rb
CHANGED
@@ -9,5 +9,13 @@ describe Elastomer::CLI::Shard do
|
|
9
9
|
@out.must_match /audit_log/m
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
it 'should normalize node names' do
|
14
|
+
names = (1..4).map {|n| "githubsearch4-storage%d-cp1-prd" % n}
|
15
|
+
@shard_stats = Elastomer::CLI::Shard.new
|
16
|
+
@shard_stats.instance_variable_set(:@node_names, names)
|
17
|
+
|
18
|
+
@shard_stats.normalized_node_names.must_equal %w[storage1 storage2 storage3 storage4]
|
19
|
+
end
|
12
20
|
end
|
13
21
|
end
|