You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2015/09/02 22:28:21 UTC

ambari git commit: AMBARI-12953: Ambari Agent logging set up incorrect (Nahappan Somasundaram via jluniya)

Repository: ambari
Updated Branches:
  refs/heads/trunk 58fdcb5c9 -> 50b129498


AMBARI-12953: Ambari Agent logging set up incorrect (Nahappan Somasundaram via jluniya)


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

Branch: refs/heads/trunk
Commit: 50b1294985c1c17d74ce12f4a814d51b8d0ad8c6
Parents: 58fdcb5
Author: Jayush Luniya <jl...@hortonworks.com>
Authored: Wed Sep 2 13:28:19 2015 -0700
Committer: Jayush Luniya <jl...@hortonworks.com>
Committed: Wed Sep 2 13:28:19 2015 -0700

----------------------------------------------------------------------
 ambari-agent/conf/unix/ambari-agent             |  8 +++-
 .../test/python/ambari_agent/TestAmbariAgent.py | 43 ++++++++++++++++++++
 2 files changed, 49 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/50b12949/ambari-agent/conf/unix/ambari-agent
----------------------------------------------------------------------
diff --git a/ambari-agent/conf/unix/ambari-agent b/ambari-agent/conf/unix/ambari-agent
index 9659014..f894c8e 100755
--- a/ambari-agent/conf/unix/ambari-agent
+++ b/ambari-agent/conf/unix/ambari-agent
@@ -93,8 +93,12 @@ if [ -a /var/lib/ambari-agent/ambari-env.sh ]; then
   . /var/lib/ambari-agent/ambari-env.sh
 fi
 
-if [ ! -z $AMBARI_LOG_DIR ]; then
-  LOGFILE=$AMBARI_LOG_DIR/ambari-agent.log
+if [ ! -z $AMBARI_AGENT_LOG_DIR ]; then
+  LOGFILE=$AMBARI_AGENT_LOG_DIR/ambari-agent.log
+fi
+
+if [ ! -z $AMBARI_AGENT_OUT_DIR ]; then
+  OUTFILE=$AMBARI_AGENT_OUT_DIR/ambari-agent.out
 fi
 
 if [ -z $RESOLVED_AMBARI_PASSPHRASE ] &&  [ ! -z $AMBARI_PASSPHRASE ]; then

http://git-wip-us.apache.org/repos/asf/ambari/blob/50b12949/ambari-agent/src/test/python/ambari_agent/TestAmbariAgent.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestAmbariAgent.py b/ambari-agent/src/test/python/ambari_agent/TestAmbariAgent.py
index a7ee104..a354572 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestAmbariAgent.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestAmbariAgent.py
@@ -22,6 +22,7 @@ import unittest
 import subprocess
 import os
 import sys
+import AmbariConfig
 from mock.mock import MagicMock, patch, ANY
 with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
   from ambari_agent.Controller import AGENT_AUTO_RESTART_EXIT_CODE
@@ -52,3 +53,45 @@ class TestAmbariAgent(unittest.TestCase):
     self.assertTrue(os_path_isfile_mock.called)
     self.assertTrue(os_path_isfile_mock.call_count == 2)
     self.assertTrue(os_remove_mock.called)
+
+  #
+  # Test AmbariConfig.getLogFile() for ambari-agent
+  #
+  def test_logfile_location(self):
+    #
+    # Test without $AMBARI_AGENT_LOG_DIR
+    #
+    log_folder = '/var/log/ambari-agent'
+    log_file = 'ambari-agent.log'
+    with patch.dict('os.environ', {}):
+      self.assertEqual(os.path.join(log_folder, log_file), AmbariConfig.AmbariConfig.getLogFile())
+
+    #
+    # Test with $AMBARI_AGENT_LOG_DIR
+    #
+    log_folder = '/myloglocation/log'
+    log_file = 'ambari-agent.log'
+    with patch.dict('os.environ', {'AMBARI_AGENT_LOG_DIR': log_folder}):
+      self.assertEqual(os.path.join(log_folder, log_file), AmbariConfig.AmbariConfig.getLogFile())
+    pass
+
+  #
+  # Test AmbariConfig.getOutFile() for ambari-agent
+  #
+  def test_outfile_location(self):
+    #
+    # Test without $AMBARI_AGENT_OUT_DIR
+    #
+    out_folder = '/var/log/ambari-agent'
+    out_file = 'ambari-agent.out'
+    with patch.dict('os.environ', {}):
+      self.assertEqual(os.path.join(out_folder, out_file), AmbariConfig.AmbariConfig.getOutFile())
+
+    #
+    # Test with $AMBARI_AGENT_OUT_DIR
+    #
+    out_folder = '/myoutlocation/out'
+    out_file = 'ambari-agent.out'
+    with patch.dict('os.environ', {'AMBARI_AGENT_OUT_DIR': out_folder}):
+      self.assertEqual(os.path.join(out_folder, out_file), AmbariConfig.AmbariConfig.getOutFile())
+    pass