From 68868fc0735c82dd88ee92a05f0eefc2574e6754 Mon Sep 17 00:00:00 2001 From: Xiao Liu Date: Wed, 15 Jul 2026 11:17:26 +0800 Subject: [PATCH] HBASE-30283 list_labels shell command should return readable labels (#8461) Signed-off-by: Peng Lu --- .../src/main/ruby/shell/commands/list_labels.rb | 6 +++++- .../hbase/visibility_labels_admin_test_cluster.rb | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/hbase-shell/src/main/ruby/shell/commands/list_labels.rb b/hbase-shell/src/main/ruby/shell/commands/list_labels.rb index 8619642351a5..50cc704c44cf 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_labels.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_labels.rb @@ -33,9 +33,13 @@ def help def command(regex = '.*') list = visibility_labels_admin.list_labels(regex) + labels = [] list.each do |label| - formatter.row([org.apache.hadoop.hbase.util.Bytes.toStringBinary(label.toByteArray)]) + label_string = org.apache.hadoop.hbase.util.Bytes.toStringBinary(label.toByteArray) + formatter.row([label_string]) + labels << label_string end + labels end end end diff --git a/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test_cluster.rb b/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test_cluster.rb index b59b9b9065fa..b0b440b3a46d 100644 --- a/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test_cluster.rb +++ b/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test_cluster.rb @@ -86,5 +86,17 @@ def teardown assert_not_nil(res['x:a']) end + define_test "list_labels should return an Array of readable label Strings" do + label = 'TEST_LIST_LABELS' + command(:add_labels, label) + $TEST_CLUSTER.waitLabelAvailable(10000, label) + + labels = command(:list_labels, 'TEST_.*') + assert_kind_of(Array, labels) + labels.each { |l| assert_kind_of(String, l) } + assert(labels.include?(label), + "list_labels should include the created label #{label}") + end + end end