From 10a64186b4e0453575fd327330202310dc11a6c0 Mon Sep 17 00:00:00 2001 From: Guangxu Cheng Date: Wed, 31 May 2017 21:25:37 +0800 Subject: [PATCH] HBASE-16120 Add shell test for truncate_preserve --- hbase-shell/src/test/ruby/hbase/admin_test.rb | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb b/hbase-shell/src/test/ruby/hbase/admin_test.rb index 1884217..b812d37 100644 --- a/hbase-shell/src/test/ruby/hbase/admin_test.rb +++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb @@ -273,6 +273,22 @@ module Hbase assert(!output.empty?) end + #------------------------------------------------------------------------------- + + define_test "truncate_preserve should empty a table" do + table(@test_name).put(1, "x:a", 1) + table(@test_name).put(2, "x:a", 2) + assert_equal(2, table(@test_name)._count_internal) + # This is hacky. Need to get the configuration into admin instance + command(:truncate_preserve, @test_name) + assert_equal(0, table(@test_name)._count_internal) + end + + define_test "truncate_preserve should yield log records" do + output = capture_stdout { command(:truncate_preserve, @test_name) } + assert(!output.empty?) + end + define_test "truncate_preserve should maintain the previous region boundaries" do drop_test_table(@create_test_name) admin.create(@create_test_name, 'a', {NUMREGIONS => 10, SPLITALGO => 'HexStringSplit'}) -- 1.7.1