Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9AEE1200D1A for ; Mon, 9 Oct 2017 23:40:20 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 996B61609CE; Mon, 9 Oct 2017 21:40:20 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DB7471609B8 for ; Mon, 9 Oct 2017 23:40:19 +0200 (CEST) Received: (qmail 59248 invoked by uid 500); 9 Oct 2017 21:40:19 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 59239 invoked by uid 99); 9 Oct 2017 21:40:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Oct 2017 21:40:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CC414F5C0C; Mon, 9 Oct 2017 21:40:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jyates@apache.org To: commits@hbase.apache.org Message-Id: <98bad7959fc34d92bfc2b67f6eb50f34@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hbase git commit: HBASE-18842 Fix unknown namespace message in clone_snapshot Date: Mon, 9 Oct 2017 21:40:18 +0000 (UTC) archived-at: Mon, 09 Oct 2017 21:40:20 -0000 Repository: hbase Updated Branches: refs/heads/master 087edf017 -> 0ff4f5fba HBASE-18842 Fix unknown namespace message in clone_snapshot Signed-off-by: Jesse Yates Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/0ff4f5fb Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0ff4f5fb Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0ff4f5fb Branch: refs/heads/master Commit: 0ff4f5fba9cef8b4dea599357d935b47f6151152 Parents: 087edf0 Author: Thoralf Gutierrez Authored: Tue Sep 26 10:01:53 2017 -0700 Committer: Jesse Yates Committed: Mon Oct 9 14:39:59 2017 -0700 ---------------------------------------------------------------------- .../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/0ff4f5fb/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 6d9c5de..8f0b35b 100644 --- a/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb @@ -47,6 +47,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/0ff4f5fb/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 9fa291a..5daf9fa 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_constants' 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