ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [2/4] git commit: AMBARI-6226. ambari-agent start command fails. (dlysnichenko)
Date Mon, 23 Jun 2014 13:14:17 GMT
AMBARI-6226. ambari-agent start command fails. (dlysnichenko)


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

Branch: refs/heads/branch-1.6.1
Commit: aaddd0608f311df09eff7808df71e8fc3eecac3d
Parents: a878293
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Mon Jun 23 16:10:20 2014 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Mon Jun 23 16:10:20 2014 +0300

----------------------------------------------------------------------
 ambari-server/src/main/python/setupAgent.py     | 7 ++++++-
 ambari-server/src/test/python/TestSetupAgent.py | 4 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aaddd060/ambari-server/src/main/python/setupAgent.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/setupAgent.py b/ambari-server/src/main/python/setupAgent.py
index 6edbdc4..1fad46a 100755
--- a/ambari-server/src/main/python/setupAgent.py
+++ b/ambari-server/src/main/python/setupAgent.py
@@ -78,6 +78,9 @@ def runAgent(passPhrase, expected_hostname):
       return agent_retcode
   return agent_retcode
 
+def tryStopAgent():
+  subprocess.call("/usr/sbin/ambari-agent stop", shell=True)
+
 def getOptimalVersion(initialProjectVersion):
   optimalVersion = initialProjectVersion
   ret = findNearestAgentPackageVersion(optimalVersion)
@@ -197,7 +200,9 @@ def main(argv=None):
     retcode = getOptimalVersion("")
   else:
     retcode = getOptimalVersion(projectVersion)
-
+  
+  tryStopAgent()
+  
   if retcode["exitstatus"] == 0 and retcode["log"] != None and retcode["log"] != "" and retcode["log"][0].strip()
!= "":
       availiableProjectVersion = retcode["log"].strip()
       if not isAgentPackageAlreadyInstalled(availiableProjectVersion):

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaddd060/ambari-server/src/test/python/TestSetupAgent.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestSetupAgent.py b/ambari-server/src/test/python/TestSetupAgent.py
index c6f8466..1bbe62e 100644
--- a/ambari-server/src/test/python/TestSetupAgent.py
+++ b/ambari-server/src/test/python/TestSetupAgent.py
@@ -202,6 +202,7 @@ class TestSetupAgent(TestCase):
   def test_execOsCommand(self, Popen_mock):
     self.assertFalse(setup_agent.execOsCommand("hostname -f") == None)
 
+  @patch.object(setup_agent, 'tryStopAgent')
   @patch.object(setup_agent, 'isAgentPackageAlreadyInstalled')
   @patch.object(setup_agent, 'runAgent')
   @patch.object(setup_agent, 'configureAgent')
@@ -216,11 +217,12 @@ class TestSetupAgent(TestCase):
   def test_setup_agent_main(self, dirname_mock, realpath_mock, exit_mock, checkServerReachability_mock,
                             getOptimalVersion_mock, is_debian_family_mock, is_suse_family_mock,
                             installAgent_mock, configureAgent_mock, runAgent_mock,
-                            isAgentPackageAlreadyInstalled_mock):
+                            isAgentPackageAlreadyInstalled_mock, tryStopAgent_mock):
     installAgent_mock.return_value = {'log': 'log', 'exitstatus': 0}
     runAgent_mock.return_value = 0
     getOptimalVersion_mock.return_value = {'log': '1.1.2, 1.1.3, ', 'exitstatus': 1}
     setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","1.1.1","8080"))
+    self.assertTrue(tryStopAgent_mock.called)
     self.assertTrue(exit_mock.called)
     self.assertTrue(getOptimalVersion_mock.called)
     exit_mock.reset_mock()


Mime
View raw message