From e6409d511813a87623ac6f653c9ced822a482a18 Mon Sep 17 00:00:00 2001 From: Peter Somogyi Date: Thu, 5 Apr 2018 12:12:14 +0200 Subject: [PATCH] HBASE-20287 After cluster startup list_regions command fails on disabled table Add is_enabled check for list_regions command --- hbase-shell/src/main/ruby/shell/commands/list_regions.rb | 2 ++ hbase-shell/src/test/ruby/hbase/admin_test.rb | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb index bcc0c4aaf3..0ce569c0a3 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb @@ -50,6 +50,8 @@ EOF options = { SERVER_NAME => options } end + raise "Table #{table_name} must be enabled." unless admin.enabled?(table_name) + size_hash = {} if cols.nil? size_hash = { 'SERVER_NAME' => 12, 'REGION_NAME' => 12, 'START_KEY' => 10, 'END_KEY' => 10, 'SIZE' => 5, 'REQ' => 5, 'LOCALITY' => 10 } diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb b/hbase-shell/src/test/ruby/hbase/admin_test.rb index 929484c51d..a27bbc5082 100644 --- a/hbase-shell/src/test/ruby/hbase/admin_test.rb +++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb @@ -319,6 +319,18 @@ module Hbase admin.truncate_preserve(@create_test_name, $TEST_CLUSTER.getConfiguration) assert_equal(splits, table(@create_test_name)._get_splits_internal()) end + + #------------------------------------------------------------------------------- + + define_test "list_regions should fail for disabled table" do + drop_test_table(@create_test_name) + admin.create(@create_test_name, 'a') + command(:disable, @create_test_name) + assert(:is_disabled, @create_test_name) + assert_raise(RuntimeError) do + command(:list_regions, @create_test_name) + end + end end # Simple administration methods tests -- 2.16.2