Skip to content

Commit faa409a

Browse files
authored
HBASE-30283 list_labels shell command should return readable labels (#8461) (#8477)
Signed-off-by: Peng Lu <lupeng@apache.org> (cherry picked from commit 8e8190e)
1 parent de0a93a commit faa409a

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

hbase-shell/src/main/ruby/shell/commands/list_labels.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ def help
3333

3434
def command(regex = '.*')
3535
list = visibility_labels_admin.list_labels(regex)
36+
labels = []
3637
list.each do |label|
37-
formatter.row([org.apache.hadoop.hbase.util.Bytes.toStringBinary(label.toByteArray)])
38+
label_string = org.apache.hadoop.hbase.util.Bytes.toStringBinary(label.toByteArray)
39+
formatter.row([label_string])
40+
labels << label_string
3841
end
42+
labels
3943
end
4044
end
4145
end

hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test_cluster.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,17 @@ def teardown
8686
assert_not_nil(res['x:a'])
8787
end
8888

89+
define_test "list_labels should return an Array of readable label Strings" do
90+
label = 'TEST_LIST_LABELS'
91+
command(:add_labels, label)
92+
$TEST_CLUSTER.waitLabelAvailable(10000, label)
93+
94+
labels = command(:list_labels, 'TEST_.*')
95+
assert_kind_of(Array, labels)
96+
labels.each { |l| assert_kind_of(String, l) }
97+
assert(labels.include?(label),
98+
"list_labels should include the created label #{label}")
99+
end
100+
89101
end
90102
end

0 commit comments

Comments
 (0)