You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2017/02/13 21:04:21 UTC

[47/50] [abbrv] ambari git commit: AMBARI-19846. ambari-agent.out getting filled with dummy traceback. (Attila Doroszlai via stoader)

AMBARI-19846. ambari-agent.out getting filled with dummy traceback. (Attila Doroszlai via stoader)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 97f8ba813bd5591694e28ec22e1372464423d519
Parents: 4ce8641
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Mon Feb 6 15:54:55 2017 +0100
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Mon Feb 13 15:45:36 2017 -0500

----------------------------------------------------------------------
 .../ambari_agent/CustomServiceOrchestrator.py     | 12 ++++--------
 .../ambari_agent/TestCustomServiceOrchestrator.py | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/97f8ba81/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
index 9baaf08..e70c2d2 100644
--- a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
+++ b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
@@ -309,14 +309,10 @@ class CustomServiceOrchestrator():
         server_url_prefix = command['hostLevelParams']['jdk_location']
       else:
         server_url_prefix = command['commandParams']['jdk_location']
-        
-      task_id = "status"
-      
-      try:
-        task_id = command['taskId']
-        command_name = command['roleCommand']
-      except KeyError:
-        pass  # Status commands have no taskId
+
+      # Status commands have no taskId nor roleCommand
+      task_id = command['taskId'] if 'taskId' in command else 'status'
+      command_name = command['roleCommand'] if 'roleCommand' in command else None
 
       if forced_command_name is not None:  # If not supplied as an argument
         command_name = forced_command_name

http://git-wip-us.apache.org/repos/asf/ambari/blob/97f8ba81/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
index 3985c5a..8e5e9a3 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
@@ -28,6 +28,7 @@ from unittest import TestCase
 import threading
 import tempfile
 import time
+import traceback
 from threading import Thread
 
 from mock.mock import MagicMock, patch
@@ -278,6 +279,23 @@ class TestCustomServiceOrchestrator(TestCase):
     self.assertTrue(run_file_mock.called)
     self.assertEqual(run_file_mock.call_count, 3)
 
+    # running a status command
+    run_file_mock.reset_mock()
+    def return_traceback(*args, **kwargs):
+      return {
+        'stderr': traceback.format_exc(),
+        'stdout': '',
+        'exitcode': 0,
+      }
+    run_file_mock.side_effect = return_traceback
+
+    status_command = dict(command)
+    status_command['commandType'] = 'STATUS_COMMAND'
+    del status_command['taskId']
+    del status_command['roleCommand']
+    ret = orchestrator.runCommand(status_command, "out.txt", "err.txt")
+    self.assertEqual('None\n', ret['stderr'])
+
     run_file_mock.reset_mock()
 
     # Case when we force another command