hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bus...@apache.org
Subject [2/4] hbase git commit: HBASE-18842 Fix unknown namespace message in clone_snapshot
Date Thu, 26 Apr 2018 04:22:46 GMT
HBASE-18842 Fix unknown namespace message in clone_snapshot

Signed-off-by: Jesse Yates <jyates@apache.org>
(cherry picked from commit 0ff4f5fba9cef8b4dea599357d935b47f6151152)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/c64debbe
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/c64debbe
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/c64debbe

Branch: refs/heads/branch-1.2
Commit: c64debbeaef631cfb71610a17d08133babe25aa1
Parents: 42471dd
Author: Thoralf Gutierrez <thoralfgutierrez@gmail.com>
Authored: Tue Sep 26 10:01:53 2017 -0700
Committer: Sean Busbey <busbey@apache.org>
Committed: Wed Apr 25 23:07:17 2018 -0500

----------------------------------------------------------------------
 .../main/ruby/shell/commands/clone_snapshot.rb  |  4 ++
 .../src/test/ruby/shell/commands_test.rb        | 48 ++++++++++++++++++++
 2 files changed, 52 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/c64debbe/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb b/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb
index 0498c8e..beedad1 100644
--- a/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb
@@ -42,6 +42,10 @@ EOF
           tableName = args[1]
           raise "Table already exists: #{tableName}!"
         end
+        if cause.is_a?(org.apache.hadoop.hbase.NamespaceNotFoundException)
+          namespace_name = args[1].split(':')[0]
+          raise "Unknown namespace: #{namespace_name}!"
+        end
       end
     end
   end

http://git-wip-us.apache.org/repos/asf/hbase/blob/c64debbe/hbase-shell/src/test/ruby/shell/commands_test.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/test/ruby/shell/commands_test.rb b/hbase-shell/src/test/ruby/shell/commands_test.rb
index 3f6a802..f8810ed 100644
--- a/hbase-shell/src/test/ruby/shell/commands_test.rb
+++ b/hbase-shell/src/test/ruby/shell/commands_test.rb
@@ -21,6 +21,9 @@ require 'hbase'
 require 'hbase/table'
 require 'shell'
 
+##
+# Tests whether all registered commands have a help and command method
+
 class ShellCommandsTest < Test::Unit::TestCase
   Shell.commands.each do |name, klass|
     define_test "#{name} command class #{klass} should respond to help" do
@@ -32,3 +35,48 @@ class ShellCommandsTest < Test::Unit::TestCase
     end
   end
 end
+
+##
+# Tests commands from the point of view of the shell to validate
+# that the error messages returned to the user are correct
+
+class ShellCloneSnapshotTest < Test::Unit::TestCase
+  include Hbase::TestHelpers
+
+  def setup
+    setup_hbase
+    @shell.interactive = false
+    # Create test table
+    @test_name = 'hbase_shell_tests_table'
+    drop_test_table(@test_name)
+    create_test_table(@test_name)
+    # Test snapshot name
+    @create_test_snapshot = 'hbase_shell_tests_snapshot'
+    drop_test_snapshot
+  end
+
+  def teardown
+    drop_test_table(@test_name)
+    drop_test_snapshot
+    shutdown
+  end
+
+  define_test 'Clone snapshot with table that already exists' do
+    existing_table = 'existing_table'
+    create_test_table(existing_table)
+    admin.snapshot(@test_name, @create_test_snapshot)
+    error = assert_raise(RuntimeError) do
+      @shell.command(:clone_snapshot, @create_test_snapshot, existing_table)
+    end
+    assert_match(/Table already exists: existing_table!/, error.message)
+  end
+
+  define_test 'Clone snapshot with unknown namespace' do
+    clone_table = 'does_not_exist:test_clone_snapshot_table'
+    admin.snapshot(@test_name, @create_test_snapshot)
+    error = assert_raise(RuntimeError) do
+      @shell.command(:clone_snapshot, @create_test_snapshot, clone_table)
+    end
+    assert_match(/Unknown namespace: does_not_exist!/, error.message)
+  end
+end


Mime
View raw message