Parcourir la source

AMBARI-5111. Host confirmation failed on suse.(vbrodetskyi)

Vitaly Brodetskyi il y a 11 ans
Parent
commit
c1d73a6148

+ 3 - 0
ambari-server/src/main/python/setupAgent.py

@@ -68,6 +68,9 @@ def runAgent(passPhrase, expected_hostname):
   os.environ[AMBARI_PASSPHRASE_VAR] = passPhrase
   agent_retcode = subprocess.call("/usr/sbin/ambari-agent restart --expected-hostname=" +\
                                   expected_hostname, shell=True)
+  # need this, because, very rarely,
+  # main.py(ambari-agent) starts a bit later then it should be started
+  time.sleep(1)
   try:
     ret = execOsCommand(["tail", "-20", "/var/log/ambari-agent/ambari-agent.log"])
     try:

+ 3 - 1
ambari-server/src/test/python/TestSetupAgent.py

@@ -55,7 +55,8 @@ class TestSetupAgent(TestCase):
   @patch.object(setup_agent, 'execOsCommand')
   @patch("os.environ")
   @patch("subprocess.call")
-  def test_runAgent(self, call_mock, environ_mock, execOsCommand_mock):
+  @patch("time.sleep")
+  def test_runAgent(self, sleep_mock, call_mock, environ_mock, execOsCommand_mock):
     expected_hostname = "test.hst"
     passphrase = "passphrase"
     call_mock.return_value = 0
@@ -65,6 +66,7 @@ class TestSetupAgent(TestCase):
     cmdStr = str(call_mock.call_args_list[0][0])
     self.assertTrue(expected_hostname in cmdStr)
     self.assertEqual(ret, 0)
+    self.assertTrue(sleep_mock.called)
     # Key 'log' not found
     execOsCommand_mock.return_value = None
     ret = setup_agent.runAgent(passphrase, expected_hostname)