Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0F63F189C1 for ; Wed, 2 Mar 2016 16:22:29 +0000 (UTC) Received: (qmail 67119 invoked by uid 500); 2 Mar 2016 16:22:29 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 67089 invoked by uid 500); 2 Mar 2016 16:22:29 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 67080 invoked by uid 99); 2 Mar 2016 16:22:28 -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; Wed, 02 Mar 2016 16:22:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A7375E2F34; Wed, 2 Mar 2016 16:22:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aonishuk@apache.org To: commits@ambari.apache.org Message-Id: <7a6a40a39fa6473194a9d36928a29bfa@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-15262. Python UT fail on trunk (aonishuk) Date: Wed, 2 Mar 2016 16:22:28 +0000 (UTC) Repository: ambari Updated Branches: refs/heads/trunk d6fddcddf -> 464c3ac45 AMBARI-15262. Python UT fail on trunk (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/464c3ac4 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/464c3ac4 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/464c3ac4 Branch: refs/heads/trunk Commit: 464c3ac4559b795f846362d0b36c1aacd842ecf2 Parents: d6fddcd Author: Andrew Onishuk Authored: Wed Mar 2 18:22:24 2016 +0200 Committer: Andrew Onishuk Committed: Wed Mar 2 18:22:24 2016 +0200 ---------------------------------------------------------------------- .../ambari_server/dbConfiguration_linux.py | 3 +- .../src/test/python/TestAmbariServer.py | 31 +++++--------------- 2 files changed, 10 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/464c3ac4/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py b/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py index 1690708..766c089 100644 --- a/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py +++ b/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py @@ -678,7 +678,7 @@ class PGConfig(LinuxDBMSConfig): def _configure_pg_hba_postgres_user(): postgresString = "all postgres" pg_hba_conf_file_content_in = sudo.read_file(PGConfig.PG_HBA_CONF_FILE) - pg_hba_conf_file_content_out = re.sub('all\s*all', postgresString, postgresString) + pg_hba_conf_file_content_out = re.sub('all\s*all', postgresString, pg_hba_conf_file_content_in) sudo.create_file(PGConfig.PG_HBA_CONF_FILE, pg_hba_conf_file_content_out) sudo.chmod(PGConfig.PG_HBA_CONF_FILE, 0644) @@ -687,6 +687,7 @@ class PGConfig(LinuxDBMSConfig): listenAddress = "listen_addresses = '*' #" postgresql_conf_file_in = sudo.read_file(PGConfig.POSTGRESQL_CONF_FILE) postgresql_conf_file_out = re.sub('#+listen_addresses.*?(#|$)', listenAddress, postgresql_conf_file_in) + sudo.create_file(PGConfig.POSTGRESQL_CONF_FILE, postgresql_conf_file_out) sudo.chmod(PGConfig.POSTGRESQL_CONF_FILE, 0644) def _configure_postgres(self): http://git-wip-us.apache.org/repos/asf/ambari/blob/464c3ac4/ambari-server/src/test/python/TestAmbariServer.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py index 901867c..125868b 100644 --- a/ambari-server/src/test/python/TestAmbariServer.py +++ b/ambari-server/src/test/python/TestAmbariServer.py @@ -15,15 +15,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' +import os +from mock.mock import patch, MagicMock, create_autospec, call +import sys + +with patch.object(os, "geteuid", new=MagicMock(return_value=0)): + from resource_management.core import sudo + reload(sudo) + from stacks.utils.RMFTestCase import * -import sys import traceback -import os import datetime import errno import json -from mock.mock import patch, MagicMock, create_autospec, call import operator from optparse import OptionParser import platform @@ -2101,16 +2106,6 @@ class TestAmbariServer(TestCase): open_Mock.return_value = file p = get_ambari_properties_mock.return_value - # Testing call under non-root - is_root_mock.return_value = False - try: - setup_https(args) - self.fail("Should throw exception") - except FatalException as fe: - # Expected - self.assertTrue("root-level" in fe.reason) - pass - # Testing call under root is_root_mock.return_value = True read_ambari_user_method.return_value = "user" @@ -6813,16 +6808,6 @@ class TestAmbariServer(TestCase): read_ambari_user_method, exists_mock, remove_password_file_method, read_master_key_method): - # Testing call under non-root - is_root_method.return_value = False - try: - setup_master_key(MagicMock()) - self.fail("Should throw exception") - except FatalException as fe: - # Expected - self.assertTrue("root-level" in fe.reason) - pass - # Testing call under root is_root_method.return_value = True