From 3c3de83b614abdcebe4191fc24dac32fd6ef5828 Mon Sep 17 00:00:00 2001 From: Karthik Palanisamy Date: Mon, 14 Oct 2019 22:13:23 -0700 Subject: [PATCH 1/4] HBASE-23176 delete_all_snapshot does not work with regex --- .../main/ruby/shell/commands/delete_all_snapshot.rb | 3 ++- hbase-shell/src/test/ruby/hbase/admin_test.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hbase-shell/src/main/ruby/shell/commands/delete_all_snapshot.rb b/hbase-shell/src/main/ruby/shell/commands/delete_all_snapshot.rb index 52276fc9c797..e6e6eb53cd4b 100644 --- a/hbase-shell/src/main/ruby/shell/commands/delete_all_snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/delete_all_snapshot.rb @@ -34,7 +34,8 @@ def command(regex) count = list.size list.each do |snapshot| creation_time = Time.at(snapshot.getCreationTime / 1000).to_s - formatter.row([snapshot.getName, snapshot.getTable + ' (' + creation_time + ')']) + formatter.row([snapshot.getName, snapshot.getTableNameAsString + + ' (' + creation_time + ')']) end puts "\nDelete the above #{count} snapshots (y/n)?" unless count == 0 answer = 'n' diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb b/hbase-shell/src/test/ruby/hbase/admin_test.rb index 1461c7f4ef13..7a8470a67cc2 100644 --- a/hbase-shell/src/test/ruby/hbase/admin_test.rb +++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb @@ -449,6 +449,17 @@ def teardown #------------------------------------------------------------------------------- + define_test 'delete_all_snapshot by regex' do + drop_test_table(@create_test_name) + admin.create(@create_test_name, 'a') + command(:snapshot, @create_test_name, 's1') + admin.delete_all_snapshot('s1.*') + output = capture_stdout { command(:list_snapshots) } + assert(output.include?('0 row')) + end + + #------------------------------------------------------------------------------- + define_test "list_regions should fail for disabled table" do drop_test_table(@create_test_name) admin.create(@create_test_name, 'a') From 960c2fcc3630973b17f876a1487087332686b522 Mon Sep 17 00:00:00 2001 From: Karthik Palanisamy Date: Tue, 15 Oct 2019 10:48:33 -0700 Subject: [PATCH 2/4] HBASE-23176 Removed test-case --- hbase-shell/src/test/ruby/hbase/admin_test.rb | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb b/hbase-shell/src/test/ruby/hbase/admin_test.rb index 7a8470a67cc2..1461c7f4ef13 100644 --- a/hbase-shell/src/test/ruby/hbase/admin_test.rb +++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb @@ -449,17 +449,6 @@ def teardown #------------------------------------------------------------------------------- - define_test 'delete_all_snapshot by regex' do - drop_test_table(@create_test_name) - admin.create(@create_test_name, 'a') - command(:snapshot, @create_test_name, 's1') - admin.delete_all_snapshot('s1.*') - output = capture_stdout { command(:list_snapshots) } - assert(output.include?('0 row')) - end - - #------------------------------------------------------------------------------- - define_test "list_regions should fail for disabled table" do drop_test_table(@create_test_name) admin.create(@create_test_name, 'a') From fa05907b1b5ff3ac440a43937cae386b3638de5a Mon Sep 17 00:00:00 2001 From: Karthik Palanisamy Date: Tue, 15 Oct 2019 13:28:47 -0700 Subject: [PATCH 3/4] HBASE-23176 Fix for delete_table_snapshots.rb --- .../src/main/ruby/shell/commands/delete_table_snapshots.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hbase-shell/src/main/ruby/shell/commands/delete_table_snapshots.rb b/hbase-shell/src/main/ruby/shell/commands/delete_table_snapshots.rb index a7875f10234c..a79ac6fa6844 100644 --- a/hbase-shell/src/main/ruby/shell/commands/delete_table_snapshots.rb +++ b/hbase-shell/src/main/ruby/shell/commands/delete_table_snapshots.rb @@ -43,7 +43,8 @@ def command(tableNameregex, snapshotNameRegex = '.*') count = list.size list.each do |snapshot| creation_time = Time.at(snapshot.getCreationTime / 1000).to_s - formatter.row([snapshot.getName, snapshot.getTable + ' (' + creation_time + ')']) + formatter.row([snapshot.getName, snapshot.getTableNameAsString + + ' (' + creation_time + ')']) end puts "\nDelete the above #{count} snapshots (y/n)?" unless count == 0 answer = 'n' From d41384b5cc2c82bd64224f44deec27297bc04785 Mon Sep 17 00:00:00 2001 From: Karthik Palanisamy Date: Thu, 17 Oct 2019 00:29:54 -0700 Subject: [PATCH 4/4] HBASE-23176 remove depricated method --- .../src/main/ruby/shell/commands/delete_all_snapshot.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hbase-shell/src/main/ruby/shell/commands/delete_all_snapshot.rb b/hbase-shell/src/main/ruby/shell/commands/delete_all_snapshot.rb index e6e6eb53cd4b..e6be8c1e1631 100644 --- a/hbase-shell/src/main/ruby/shell/commands/delete_all_snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/delete_all_snapshot.rb @@ -54,7 +54,8 @@ def command(regex) formatter.header(['SNAPSHOT', 'TABLE + CREATION TIME']) list.each do |snapshot| creation_time = Time.at(snapshot.getCreationTime / 1000).to_s - formatter.row([snapshot.getName, snapshot.getTable + ' (' + creation_time + ')']) + formatter.row([snapshot.getName, snapshot.getTableNameAsString + + ' (' + creation_time + ')']) end end end