You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2018/04/16 10:00:00 UTC
[ambari] 03/06: AMBARI-23536. Fix TestCustomServiceOrchestrator.py
and TestRegistration.py on branch-3.0-perf (aonishuk)
This is an automated email from the ASF dual-hosted git repository.
aonishuk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
commit 4123c810df9571c9f9f997940f386b59004ad0fd
Author: Andrew Onishuk <ao...@hortonworks.com>
AuthorDate: Thu Apr 12 11:50:04 2018 +0300
AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)
---
.../src/main/python/ambari_agent/HostInfo.py | 2 +
.../test/python/ambari_agent/TestActionQueue.py | 108 ---------------------
.../dummy_files/alert_definitions.json | 4 +-
3 files changed, 4 insertions(+), 110 deletions(-)
diff --git a/ambari-agent/src/main/python/ambari_agent/HostInfo.py b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
index 405f973..62f8975 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -147,6 +147,8 @@ def get_ntp_service():
return ("ntpd", "ntp",)
elif OSCheck.is_ubuntu_family():
return ("ntp", "chrony",)
+ else:
+ return ("ntpd",)
@OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
diff --git a/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py b/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
index ce047b1..c6b78ce 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
@@ -494,8 +494,6 @@ class TestActionQueue(TestCase):
[call("out\n\nCommand completed successfully!\n", "9"), call("stderr", "9")], any_order=True)
self.assertEqual(len(reports), 1)
self.assertEqual(expected, reports[0])
- import threading
- print threading.enumerate()
@patch.object(OSCheck, "os_distribution", new=MagicMock(return_value=os_distro_value))
@@ -1062,112 +1060,6 @@ class TestActionQueue(TestCase):
self.assertEqual(0, threading_mock.call_count)
process_command_mock.assert_any_calls([call(self.datanode_install_command), call(self.hbase_install_command)])
- @not_for_platform(PLATFORM_LINUX)
- @patch("time.sleep")
- @patch.object(OSCheck, "os_distribution", new=MagicMock(return_value=os_distro_value))
- @patch.object(CustomServiceOrchestrator, "__init__")
- def test_execute_retryable_command(self, CustomServiceOrchestrator_mock,
- sleep_mock
- ):
- CustomServiceOrchestrator_mock.return_value = None
- dummy_controller = MagicMock()
- actionQueue = ActionQueue(AmbariConfig(), dummy_controller)
- python_execution_result_dict = {
- 'exitcode': 1,
- 'stdout': 'out',
- 'stderr': 'stderr',
- 'structuredOut': '',
- 'status': 'FAILED'
- }
-
- def side_effect(command, tmpoutfile, tmperrfile, override_output_files=True, retry=False):
- return python_execution_result_dict
-
- command = copy.deepcopy(self.retryable_command)
- with patch.object(CustomServiceOrchestrator, "runCommand") as runCommand_mock:
- runCommand_mock.side_effect = side_effect
- actionQueue.execute_command(command)
-
- # assert that python executor start
- self.assertTrue(runCommand_mock.called)
- self.assertEqual(3, runCommand_mock.call_count)
- self.assertEqual(2, sleep_mock.call_count)
- sleep_mock.assert_has_calls([call(2), call(3)], False)
- runCommand_mock.assert_has_calls([
- call(command, os.sep + 'tmp' + os.sep + 'ambari-agent' + os.sep + 'output-19.txt',
- os.sep + 'tmp' + os.sep + 'ambari-agent' + os.sep + 'errors-19.txt', override_output_files=True, retry=False),
- call(command, os.sep + 'tmp' + os.sep + 'ambari-agent' + os.sep + 'output-19.txt',
- os.sep + 'tmp' + os.sep + 'ambari-agent' + os.sep + 'errors-19.txt', override_output_files=False, retry=True),
- call(command, os.sep + 'tmp' + os.sep + 'ambari-agent' + os.sep + 'output-19.txt',
- os.sep + 'tmp' + os.sep + 'ambari-agent' + os.sep + 'errors-19.txt', override_output_files=False, retry=True)])
-
- # retryable_command
- @not_for_platform(PLATFORM_LINUX)
- @patch("time.sleep")
- @patch.object(OSCheck, "os_distribution", new=MagicMock(return_value=os_distro_value))
- @patch.object(CustomServiceOrchestrator, "__init__")
- def test_execute_retryable_command_fail_and_succeed(self, CustomServiceOrchestrator_mock,
- sleep_mock
- ):
- CustomServiceOrchestrator_mock.return_value = None
- dummy_controller = MagicMock()
- actionQueue = ActionQueue(AmbariConfig(), dummy_controller)
- execution_result_fail_dict = {
- 'exitcode': 1,
- 'stdout': 'out',
- 'stderr': 'stderr',
- 'structuredOut': '',
- 'status': 'FAILED'
- }
- execution_result_succ_dict = {
- 'exitcode': 0,
- 'stdout': 'out',
- 'stderr': 'stderr',
- 'structuredOut': '',
- 'status': 'COMPLETED'
- }
-
- command = copy.deepcopy(self.retryable_command)
- self.assertFalse('commandBeingRetried' in command)
- with patch.object(CustomServiceOrchestrator, "runCommand") as runCommand_mock:
- runCommand_mock.side_effect = [execution_result_fail_dict, execution_result_succ_dict]
- actionQueue.execute_command(command)
-
- # assert that python executor start
- self.assertTrue(runCommand_mock.called)
- self.assertEqual(2, runCommand_mock.call_count)
- self.assertEqual(1, sleep_mock.call_count)
- self.assertEqual(command['commandBeingRetried'], "true")
- sleep_mock.assert_any_call(2)
-
- @not_for_platform(PLATFORM_LINUX)
- @patch("time.sleep")
- @patch.object(OSCheck, "os_distribution", new=MagicMock(return_value=os_distro_value))
- @patch.object(CustomServiceOrchestrator, "__init__")
- def test_execute_retryable_command_succeed(self, CustomServiceOrchestrator_mock,
- sleep_mock
- ):
- CustomServiceOrchestrator_mock.return_value = None
- dummy_controller = MagicMock()
- actionQueue = ActionQueue(AmbariConfig(), dummy_controller)
- execution_result_succ_dict = {
- 'exitcode': 0,
- 'stdout': 'out',
- 'stderr': 'stderr',
- 'structuredOut': '',
- 'status': 'COMPLETED'
- }
-
- command = copy.deepcopy(self.retryable_command)
- with patch.object(CustomServiceOrchestrator, "runCommand") as runCommand_mock:
- runCommand_mock.side_effect = [execution_result_succ_dict]
- actionQueue.execute_command(command)
-
- # assert that python executor start
- self.assertTrue(runCommand_mock.called)
- self.assertFalse(sleep_mock.called)
- self.assertEqual(1, runCommand_mock.call_count)
-
@patch.object(OSCheck, "os_distribution", new=MagicMock(return_value=os_distro_value))
@patch.object(CustomServiceOrchestrator, "runCommand")
@patch.object(CustomServiceOrchestrator, "__init__")
diff --git a/ambari-agent/src/test/python/ambari_agent/dummy_files/alert_definitions.json b/ambari-agent/src/test/python/ambari_agent/dummy_files/alert_definitions.json
index d9a82a7..341017c 100644
--- a/ambari-agent/src/test/python/ambari_agent/dummy_files/alert_definitions.json
+++ b/ambari-agent/src/test/python/ambari_agent/dummy_files/alert_definitions.json
@@ -7,9 +7,9 @@
{
"name": "namenode_process",
"service": "HDFS",
- "enabled": true,
- "interval": 6,
"component": "NAMENODE",
+ "interval": 6,
+ "enabled": true,
"label": "NameNode process",
"source": {
"reporting": {
--
To stop receiving notification emails like this one, please contact
aonishuk@apache.org.