ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject git commit: AMBARI-6749 - Flume service should be in STARTED state when no agents configured (jonathanhurley)
Date Tue, 05 Aug 2014 23:28:27 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 24be62564 -> 5a0b5810f


AMBARI-6749 - Flume service should be in STARTED state when no agents configured (jonathanhurley)


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

Branch: refs/heads/trunk
Commit: 5a0b5810fe4881a791bb9017cf7bb4937ae519d7
Parents: 24be625
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Tue Aug 5 16:31:03 2014 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Tue Aug 5 19:27:57 2014 -0400

----------------------------------------------------------------------
 .../FLUME/package/scripts/flume_handler.py      | 10 +++++----
 .../python/stacks/2.0.6/FLUME/test_flume.py     | 22 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5a0b5810/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume_handler.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume_handler.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume_handler.py
index c29dd93..adc7a35 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume_handler.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume_handler.py
@@ -57,12 +57,13 @@ class FlumeHandler(Script):
     env.set_params(params)
 
     processes = flume_status()
+    expected_agents = find_expected_agent_names()
 
     json = {}
     json['processes'] = processes
     json['alerts'] = []
 
-    if len(processes) == 0 and len(find_expected_agent_names()) == 0:
+    if len(processes) == 0 and len(expected_agents) == 0:
       alert = {}
       alert['name'] = 'flume_agent'
       alert['label'] = 'Flume Agent process'
@@ -87,9 +88,10 @@ class FlumeHandler(Script):
 
     self.put_structured_out(json)
 
-    if 0 == len(processes):
-      raise ComponentIsNotRunning()
-    else:
+    # only throw an exception if there are agents defined and there is a 
+    # problem with the processes; if there are no agents defined, then 
+    # the service should report STARTED (green) instead of INSTALLED (red)
+    if len(expected_agents) > 0:
       for proc in processes:
         if not proc.has_key('status') or proc['status'] == 'NOT_RUNNING':
           raise ComponentIsNotRunning()

http://git-wip-us.apache.org/repos/asf/ambari/blob/5a0b5810/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py b/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
index f421bf5..78f4246 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
@@ -124,6 +124,28 @@ class TestFlumeHandler(RMFTestCase):
     self.assertTrue(struct_out.has_key('alerts'))
 
     self.assertNoMoreResources()
+    
+  @patch("resource_management.libraries.script.Script.put_structured_out")
+  @patch("glob.glob")
+  @patch("sys.exit")
+  def test_status_no_agents(self, sys_exit_mock, glob_mock, structured_out_mock):
+    glob_mock.return_value = []
+
+    try:
+      self.executeScript("2.0.6/services/FLUME/package/scripts/flume_handler.py",
+       classname = "FlumeHandler",
+       command = "status",
+       config_file="default.json")
+    except:
+      self.fail("Exception not expected when no agents are defined")
+      
+    self.assertTrue(structured_out_mock.called)
+
+    # call_args[0] is a tuple, whose first element is the actual call argument
+    struct_out = structured_out_mock.call_args[0][0]
+    self.assertTrue(struct_out.has_key('processes'))
+    self.assertTrue(struct_out.has_key('alerts'))
+    self.assertNoMoreResources()    
 
   def assert_configure_default(self):
 


Mime
View raw message