AMBARI-7864. HiveServer2 doesn't start from Ambari when hive authorization is true (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/de41d70a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/de41d70a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/de41d70a Branch: refs/heads/branch-1.7.0 Commit: de41d70a906770558d28fe8e3b082ae56ab5a08a Parents: 50948ae Author: Lisnichenko Dmitro <dlysniche...@hortonworks.com> Authored: Mon Oct 20 21:00:29 2014 +0300 Committer: Lisnichenko Dmitro <dlysniche...@hortonworks.com> Committed: Mon Oct 20 21:01:38 2014 +0300 ---------------------------------------------------------------------- .../2.0.6/services/HIVE/package/scripts/hive_service.py | 4 ++-- .../test/python/stacks/2.0.6/HIVE/test_hive_server.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/de41d70a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive_service.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive_service.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive_service.py index 5463df4..294121d 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive_service.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive_service.py @@ -97,10 +97,10 @@ def hive_service( def check_fs_root(): import params fs_root_url = format("{fs_root}{hive_apps_whs_dir}") - cmd = format("metatool -listFSRoot 2>/dev/null | grep hdfs://") + cmd = format("metatool -listFSRoot 2>/dev/null | grep hdfs:// | grep -v '.db$'") code, out = call(cmd, user=params.hive_user) if code == 0 and fs_root_url.strip() != out.strip(): cmd = format("metatool -updateLocation {fs_root}{hive_apps_whs_dir} {out}") Execute(cmd, environment= {'PATH' : params.execute_path }, - user=params.hive_user) \ No newline at end of file + user=params.hive_user) http://git-wip-us.apache.org/repos/asf/ambari/blob/de41d70a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py index ed759ac..f0f1675 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py @@ -18,6 +18,7 @@ See the License for the specific language governing permissions and limitations under the License. ''' import os +import subprocess from mock.mock import MagicMock, call, patch from stacks.utils.RMFTestCase import * @@ -34,9 +35,9 @@ class TestHiveServer(RMFTestCase): self.assert_configure_default() self.assertNoMoreResources() - @patch("hive_service.check_fs_root") + @patch.object(subprocess,"Popen") @patch("socket.socket") - def test_start_default(self, socket_mock, check_fs_root_mock): + def test_start_default(self, socket_mock, popen_mock): s = socket_mock.return_value self.executeScript("2.0.6/services/HIVE/package/scripts/hive_server.py", @@ -112,7 +113,11 @@ class TestHiveServer(RMFTestCase): ) self.assertNoMoreResources() - self.assertTrue(check_fs_root_mock.called) + self.assertTrue(popen_mock.called) + popen_mock.assert_called_with( + ['su', '-s', '/bin/bash', '-', u'hive', '-c', "metatool -listFSRoot 2>/dev/null | grep hdfs:// | grep -v '.db$'"], + shell=False, preexec_fn=None, stderr=-2, stdout=-1, env=None, cwd=None + ) self.assertTrue(socket_mock.called) self.assertTrue(s.close.called)