AMBARI-18960 - Dashboards directory only needs to be sync'd for METRICS_GRAFANA


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

Branch: refs/heads/branch-feature-AMBARI-18634
Commit: 48715331207b73978803aa666209b84c26224fde
Parents: 4a7cbcb
Author: Tim Thorpe <ttho...@apache.org>
Authored: Tue Nov 22 08:56:34 2016 -0800
Committer: Tim Thorpe <ttho...@apache.org>
Committed: Tue Nov 22 08:56:34 2016 -0800

----------------------------------------------------------------------
 .../ambari_agent/CustomServiceOrchestrator.py   |  4 +++-
 .../TestCustomServiceOrchestrator.py            | 21 ++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/48715331/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 fbc1509..b814334 100644
--- a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
+++ b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
@@ -58,6 +58,7 @@ class CustomServiceOrchestrator():
   AMBARI_SERVER_HOST = "ambari_server_host"
   AMBARI_SERVER_PORT = "ambari_server_port"
   AMBARI_SERVER_USE_SSL = "ambari_server_use_ssl"
+  METRICS_GRAFANA = "METRICS_GRAFANA"
 
   FREQUENT_COMMANDS = [COMMAND_NAME_SECURITY_STATUS, COMMAND_NAME_STATUS]
   DONT_DEBUG_FAILURES_FOR_COMMANDS = FREQUENT_COMMANDS
@@ -153,7 +154,8 @@ class CustomServiceOrchestrator():
         self.file_cache.get_host_scripts_base_dir(server_url_prefix)          
         hook_dir = self.file_cache.get_hook_base_dir(command, 
server_url_prefix)
         base_dir = self.file_cache.get_service_base_dir(command, 
server_url_prefix)
-        self.file_cache.get_dashboard_base_dir(server_url_prefix)
+        if command['role'] == self.METRICS_GRAFANA:
+          self.file_cache.get_dashboard_base_dir(server_url_prefix)
 
         script_path = self.resolve_script_path(base_dir, script)
         script_tuple = (script_path, base_dir)

http://git-wip-us.apache.org/repos/asf/ambari/blob/48715331/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 9f1241e..d0d6ac4 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
@@ -277,6 +277,8 @@ class TestCustomServiceOrchestrator(TestCase):
     self.assertEqual(ret['exitcode'], 0)
     self.assertTrue(run_file_mock.called)
     self.assertEqual(run_file_mock.call_count, 3)
+    # Should only be called for METRICS_GRAFANA
+    self.assertFalse(get_dashboard_base_dir_mock.called)
 
     run_file_mock.reset_mock()
 
@@ -299,6 +301,25 @@ class TestCustomServiceOrchestrator(TestCase):
 
     run_file_mock.reset_mock()
 
+    # For role=METRICS_GRAFANA, dashboards should be sync'd
+    command['role'] = 'METRICS_GRAFANA'
+    get_dashboard_base_dir_mock.reset_mock()
+    get_dashboard_base_dir_mock.return_value = "/dashboards/"
+
+    run_file_mock.return_value = {
+        'stdout' : 'sss',
+        'stderr' : 'eee',
+        'exitcode': 0,
+      }
+    ret = orchestrator.runCommand(command, "out.txt", "err.txt")
+    self.assertEqual(ret['exitcode'], 0)
+    self.assertTrue(run_file_mock.called)
+    self.assertEqual(run_file_mock.call_count, 3)
+    self.assertTrue(get_dashboard_base_dir_mock.called)
+
+    command['role'] = 'REGION_SERVER'
+    run_file_mock.reset_mock()
+
     # unknown script type case
     command['commandParams']['script_type'] = "SOME_TYPE"
     ret = orchestrator.runCommand(command, "out.txt", "err.txt")

Reply via email to