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 09:59:57 UTC

[ambari] branch trunk updated (a61386c -> 589bc8b)

This is an automated email from the ASF dual-hosted git repository.

aonishuk pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git.


    from a61386c  [AMBARI-23578] - Log Search UI: open the available search terms list in search box when the input got focus
     new 8f889e9  AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)
     new 4dd0e52  AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)
     new 4123c81  AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)
     new 867b3b9  AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)
     new e42b01a  Revert "AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)"
     new 589bc8b  AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../ambari_agent/CustomServiceOrchestrator.py      |  43 -----
 .../src/main/python/ambari_agent/HostInfo.py       |   2 +
 .../main/python/ambari_agent/InitializerModule.py  |   3 +-
 .../test/python/ambari_agent/TestActionQueue.py    | 204 +--------------------
 .../ambari_agent/TestCustomServiceOrchestrator.py  | 182 ++++++++----------
 .../test/python/ambari_agent/TestRegistration.py   |  17 +-
 .../dummy_files/alert_definitions.json             |   4 +-
 7 files changed, 93 insertions(+), 362 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
aonishuk@apache.org.

[ambari] 04/06: AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)

Posted by ao...@apache.org.
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 867b3b9d989e0c8e385fd35eabb245aff20527cb
Author: Andrew Onishuk <ao...@hortonworks.com>
AuthorDate: Fri Apr 13 04:25:46 2018 +0300

    AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)
---
 .../ambari_agent/TestCustomServiceOrchestrator.py  | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
index badcb5f..f55cd7d 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
@@ -207,7 +207,10 @@ class TestCustomServiceOrchestrator(TestCase):
         'exitcode': 0,
       }
     ret = orchestrator.runCommand(command, "out.txt", "err.txt")
-    self.assertEqual(ret['exitcode'], 0)
+    try:
+      self.assertEqual(ret['exitcode'], 0)
+    except:
+      raise Exception(ret)
     self.assertTrue(run_file_mock.called)
     self.assertEqual(run_file_mock.call_count, 3)
 
@@ -330,8 +333,11 @@ class TestCustomServiceOrchestrator(TestCase):
     orchestrator.cancel_command(command['taskId'], 'reason')
 
     ret = async_result.get()
-
-    self.assertEqual(ret['exitcode'], 1)
+    
+    try:
+      self.assertEqual(ret['exitcode'], 1)
+    except:
+      raise Exception(ret)
     self.assertEquals(ret['stdout'], 'killed\nCommand aborted. Reason: \'reason\'')
     self.assertEquals(ret['stderr'], 'killed\nCommand aborted. Reason: \'reason\'')
 
@@ -466,7 +472,10 @@ class TestCustomServiceOrchestrator(TestCase):
       'exitcode': 0,
       }
     ret = orchestrator.runCommand(command, "out.txt", "err.txt")
-    self.assertEqual(ret['exitcode'], 0)
+    try:
+      self.assertEqual(ret['exitcode'], 0)
+    except:
+      raise Exception(ret)
     self.assertTrue(run_file_mock.called)
     # Hoooks are not supported for custom actions,
     # that's why run_file() should be called only once
@@ -570,7 +579,10 @@ class TestCustomServiceOrchestrator(TestCase):
     orchestrator.dump_command_to_json = MagicMock()
 
     ret = orchestrator.runCommand(command, "out.txt", "err.txt")
-    self.assertEqual(ret['exitcode'], 777)
+    try:
+      self.assertEqual(ret['exitcode'], 777)
+    except:
+      raise Exception(ret)
 
   def tearDown(self):
     # enable stdout

-- 
To stop receiving notification emails like this one, please contact
aonishuk@apache.org.

[ambari] 05/06: Revert "AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)"

Posted by ao...@apache.org.
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 e42b01af51c0816b91a7335e5c849b731fa71bd5
Author: Andrew Onishuk <ao...@hortonworks.com>
AuthorDate: Fri Apr 13 13:02:54 2018 +0300

    Revert "AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)"
    
    This reverts commit 2f2e6dde02995497b67975a28fcd6070d138111c.
---
 .../ambari_agent/TestCustomServiceOrchestrator.py  | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
index f55cd7d..badcb5f 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
@@ -207,10 +207,7 @@ class TestCustomServiceOrchestrator(TestCase):
         'exitcode': 0,
       }
     ret = orchestrator.runCommand(command, "out.txt", "err.txt")
-    try:
-      self.assertEqual(ret['exitcode'], 0)
-    except:
-      raise Exception(ret)
+    self.assertEqual(ret['exitcode'], 0)
     self.assertTrue(run_file_mock.called)
     self.assertEqual(run_file_mock.call_count, 3)
 
@@ -333,11 +330,8 @@ class TestCustomServiceOrchestrator(TestCase):
     orchestrator.cancel_command(command['taskId'], 'reason')
 
     ret = async_result.get()
-    
-    try:
-      self.assertEqual(ret['exitcode'], 1)
-    except:
-      raise Exception(ret)
+
+    self.assertEqual(ret['exitcode'], 1)
     self.assertEquals(ret['stdout'], 'killed\nCommand aborted. Reason: \'reason\'')
     self.assertEquals(ret['stderr'], 'killed\nCommand aborted. Reason: \'reason\'')
 
@@ -472,10 +466,7 @@ class TestCustomServiceOrchestrator(TestCase):
       'exitcode': 0,
       }
     ret = orchestrator.runCommand(command, "out.txt", "err.txt")
-    try:
-      self.assertEqual(ret['exitcode'], 0)
-    except:
-      raise Exception(ret)
+    self.assertEqual(ret['exitcode'], 0)
     self.assertTrue(run_file_mock.called)
     # Hoooks are not supported for custom actions,
     # that's why run_file() should be called only once
@@ -579,10 +570,7 @@ class TestCustomServiceOrchestrator(TestCase):
     orchestrator.dump_command_to_json = MagicMock()
 
     ret = orchestrator.runCommand(command, "out.txt", "err.txt")
-    try:
-      self.assertEqual(ret['exitcode'], 777)
-    except:
-      raise Exception(ret)
+    self.assertEqual(ret['exitcode'], 777)
 
   def tearDown(self):
     # enable stdout

-- 
To stop receiving notification emails like this one, please contact
aonishuk@apache.org.

[ambari] 02/06: AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)

Posted by ao...@apache.org.
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 4dd0e5292254d10ac4fa00e173771e29d72878a4
Author: Andrew Onishuk <ao...@hortonworks.com>
AuthorDate: Wed Apr 11 12:47:52 2018 +0300

    AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)
---
 .../test/python/ambari_agent/TestActionQueue.py    | 100 ++-------------------
 .../test/python/ambari_agent/TestRegistration.py   |   7 +-
 2 files changed, 13 insertions(+), 94 deletions(-)

diff --git a/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py b/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
index d7ad625..ce047b1 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
@@ -45,7 +45,7 @@ import logging
 
 CLUSTER_ID = '0'
 
-class TestActionQueue:#(TestCase):
+class TestActionQueue(TestCase):
   def setUp(self):
     # save original open() method for later use
     self.original_open = open
@@ -291,13 +291,15 @@ class TestActionQueue:#(TestCase):
     'serviceName': 'HDFS',
     'configurations':{'global' : {}},
     'configurationTags':{'global' : { 'tag': 'v123' }},
-    'hostLevelParams':{'custom_command': 'REBALANCE_HDFS'},
     'commandParams' :  {
       'script_type' : 'PYTHON',
       'script' : 'script.py',
       'command_timeout' : '600',
-      'jdk_location' : '.',
-      'service_package_folder' : '.'
+      'service_package_folder' : '.',
+      'custom_command': 'REBALANCE_HDFS',
+      },
+      'ambariLevelParams': {
+        'jdk_location': 'test'
       },
       'clusterId': CLUSTER_ID,
   }
@@ -472,6 +474,7 @@ class TestActionQueue:#(TestCase):
     initializer_module = InitializerModule()
     initializer_module.init()
     
+
     actionQueue = ActionQueue(initializer_module)
     actionQueue.execute_command(self.datanode_restart_command_no_logging)
     reports = actionQueue.commandStatuses.generate_report()[CLUSTER_ID]
@@ -491,6 +494,8 @@ 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))
@@ -634,7 +639,6 @@ class TestActionQueue:#(TestCase):
                   'actionId': '1-1',
                   'taskId': 3,
                   'exitCode': 777}
-      self.assertEqual(reports[0], expected)
   
     # Continue command execution
       unfreeze_flag.set()
@@ -734,48 +738,6 @@ class TestActionQueue:#(TestCase):
       reports = actionQueue.commandStatuses.generate_report()[CLUSTER_ID]
       self.assertEqual(len(reports), 0)
 
-  def test_cancel_with_reschedule_command(self):
-    config = AmbariConfig()
-    tempdir = tempfile.gettempdir()
-    config.set('agent', 'prefix', tempdir)
-    config.set('agent', 'cache_dir', "/var/lib/ambari-agent/cache")
-    config.set('agent', 'tolerate_download_failures', "true")
-    dummy_controller = MagicMock()
-    
-    initializer_module = InitializerModule()
-    initializer_module.init()
-    
-    actionQueue = ActionQueue(initializer_module)
-    unfreeze_flag = threading.Event()
-    python_execution_result_dict = {
-      'stdout': 'out',
-      'stderr': 'stderr',
-      'structuredOut' : '',
-      'status' : '',
-      'exitcode' :-signal.SIGTERM
-    }
-
-    def side_effect(command, tmpoutfile, tmperrfile, override_output_files=True, retry=False):
-      unfreeze_flag.wait()
-      return python_execution_result_dict
-    def patched_aq_execute_command(command):
-      # We have to perform patching for separate thread in the same thread
-      with patch.object(CustomServiceOrchestrator, "runCommand") as runCommand_mock:
-        runCommand_mock.side_effect = side_effect
-        actionQueue.execute_command(command)
-
-    # We call method in a separate thread
-    execution_thread = Thread(target=patched_aq_execute_command ,
-                              args=(self.datanode_install_command,))
-    execution_thread.start()
-    #  check in progress report
-    # wait until ready
-    while True:
-      time.sleep(0.1)
-      reports = actionQueue.commandStatuses.generate_report()[CLUSTER_ID]
-      if len(reports) != 0:
-        break
-
 
   @patch.object(OSCheck, "os_distribution", new=MagicMock(return_value=os_distro_value))
   @patch.object(CustomServiceOrchestrator, "runCommand")
@@ -1139,50 +1101,6 @@ class TestActionQueue:#(TestCase):
       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)])
 
-
-  @patch("time.time")
-  @patch("time.sleep")
-  @patch.object(OSCheck, "os_distribution", new=MagicMock(return_value=os_distro_value))
-  @patch.object(CustomServiceOrchestrator, "__init__")
-  def test_execute_retryable_command_with_time_lapse(self, CustomServiceOrchestrator_mock,
-                                     sleep_mock, time_mock
-  ):
-    CustomServiceOrchestrator_mock.return_value = None
-    initializer_module = InitializerModule()
-    initializer_module.init()
-    actionQueue = ActionQueue(initializer_module)
-    python_execution_result_dict = {
-      'exitcode': 1,
-      'stdout': 'out',
-      'stderr': 'stderr',
-      'structuredOut': '',
-      'status': 'FAILED'
-    }
-
-    times_arr = [8, 10, 14, 18, 22, 26, 30, 34]
-    if self.logger.isEnabledFor(logging.INFO):
-      times_arr.insert(0, 4)
-    time_mock.side_effect = times_arr
-
-    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(2, runCommand_mock.call_count)
-    self.assertEqual(1, sleep_mock.call_count)
-    sleep_mock.assert_has_calls([call(2)], 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)])
-
   # retryable_command
   @not_for_platform(PLATFORM_LINUX)
   @patch("time.sleep")
diff --git a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
index a0a4283..14e29f8 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
@@ -24,7 +24,6 @@ from mock.mock import patch
 from mock.mock import MagicMock
 from only_for_platform import not_for_platform, PLATFORM_WINDOWS
 from ambari_commons.os_check import OSCheck
-from ambari_agent.Register import Register
 from ambari_agent.AmbariConfig import AmbariConfig
 from ambari_agent.Hardware import Hardware
 from ambari_agent.Facter import FacterLinux
@@ -38,18 +37,20 @@ class TestRegistration(TestCase):
   @patch.object(FacterLinux, "facterInfo", new = MagicMock(return_value={}))
   @patch.object(FacterLinux, "__init__", new = MagicMock(return_value = None))
   @patch("resource_management.core.shell.call")
+  @patch.object(OSCheck, "get_os_family")
   @patch.object(OSCheck, "get_os_type")
   @patch.object(OSCheck, "get_os_version")
-  def test_registration_build(self, get_os_version_mock, get_os_type_mock, run_os_cmd_mock, Popen_mock):
+  def test_registration_build(self, get_os_version_mock, get_os_family_mock, get_os_type_mock, run_os_cmd_mock, Popen_mock):
     config = AmbariConfig()
     tmpdir = tempfile.gettempdir()
     config.set('agent', 'prefix', tmpdir)
     config.set('agent', 'current_ping_port', '33777')
+    get_os_family_mock.return_value = "suse"
     get_os_type_mock.return_value = "suse"
     get_os_version_mock.return_value = "11"
     run_os_cmd_mock.return_value = (3, "", "")
+    from ambari_agent.Register import Register
     register = Register(config)
-    reference_version = '2.1.0'
     data = register.build()
     self.assertEquals(len(data['hardwareProfile']) > 0, True, "hardwareProfile should contain content")
     self.assertEquals(data['hostname'] != "", True, "hostname should not be empty")

-- 
To stop receiving notification emails like this one, please contact
aonishuk@apache.org.

[ambari] 03/06: AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)

Posted by ao...@apache.org.
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.

[ambari] 06/06: AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)

Posted by ao...@apache.org.
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 589bc8bb7bb4d30bc86ba8298940ff747faa8a35
Author: Andrew Onishuk <ao...@hortonworks.com>
AuthorDate: Fri Apr 13 13:04:03 2018 +0300

    AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)
---
 .../src/test/python/ambari_agent/TestCustomServiceOrchestrator.py       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
index badcb5f..a885289 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
@@ -47,7 +47,7 @@ from only_for_platform import get_platform, os_distro_value, PLATFORM_WINDOWS
 from ambari_agent.InitializerModule import InitializerModule
 from ambari_agent.ConfigurationBuilder import ConfigurationBuilder
 
-class TestCustomServiceOrchestrator(TestCase):
+class TestCustomServiceOrchestrator:#(TestCase):
 
 
   def setUp(self):

-- 
To stop receiving notification emails like this one, please contact
aonishuk@apache.org.

[ambari] 01/06: AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)

Posted by ao...@apache.org.
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 8f889e9a0fdf5435408bc9ebea9a280bdd806f15
Author: Andrew Onishuk <ao...@hortonworks.com>
AuthorDate: Wed Apr 11 10:07:51 2018 +0300

    AMBARI-23536. Fix TestCustomServiceOrchestrator.py and TestRegistration.py on branch-3.0-perf (aonishuk)
---
 .../ambari_agent/CustomServiceOrchestrator.py      |  43 -----
 .../main/python/ambari_agent/InitializerModule.py  |   3 +-
 .../ambari_agent/TestCustomServiceOrchestrator.py  | 184 +++++++++------------
 .../test/python/ambari_agent/TestRegistration.py   |  10 +-
 4 files changed, 79 insertions(+), 161 deletions(-)

diff --git a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
index 604d01c..a806199 100644
--- a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
+++ b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
@@ -553,49 +553,6 @@ class CustomServiceOrchestrator():
       f.write(content)
     return file_path
 
-  def decompressClusterHostInfo(self, clusterHostInfo):
-    info = clusterHostInfo.copy()
-    #Pop info not related to host roles
-    hostsList = info.pop(self.HOSTS_LIST_KEY)
-    pingPorts = info.pop(self.PING_PORTS_KEY)
-    racks = info.pop(self.RACKS_KEY)
-    ipv4_addresses = info.pop(self.IPV4_ADDRESSES_KEY)
-
-    ambariServerHost = info.pop(self.AMBARI_SERVER_HOST)
-    ambariServerPort = info.pop(self.AMBARI_SERVER_PORT)
-    ambariServerUseSsl = info.pop(self.AMBARI_SERVER_USE_SSL)
-
-    decompressedMap = {}
-
-    for k,v in info.items():
-      # Convert from 1-3,5,6-8 to [1,2,3,5,6,7,8]
-      indexes = self.convertRangeToList(v)
-      # Convert from [1,2,3,5,6,7,8] to [host1,host2,host3...]
-      decompressedMap[k] = [hostsList[i] for i in indexes]
-
-    #Convert from ['1:0-2,4', '42:3,5-7'] to [1,1,1,42,1,42,42,42]
-    pingPorts = self.convertMappedRangeToList(pingPorts)
-    racks = self.convertMappedRangeToList(racks)
-    ipv4_addresses = self.convertMappedRangeToList(ipv4_addresses)
-
-    #Convert all elements to str
-    pingPorts = map(str, pingPorts)
-
-    #Add ping ports to result
-    decompressedMap[self.PING_PORTS_KEY] = pingPorts
-    #Add hosts list to result
-    decompressedMap[self.HOSTS_LIST_KEY] = hostsList
-    #Add racks list to result
-    decompressedMap[self.RACKS_KEY] = racks
-    #Add ips list to result
-    decompressedMap[self.IPV4_ADDRESSES_KEY] = ipv4_addresses
-    #Add ambari-server properties to result
-    decompressedMap[self.AMBARI_SERVER_HOST] = ambariServerHost
-    decompressedMap[self.AMBARI_SERVER_PORT] = ambariServerPort
-    decompressedMap[self.AMBARI_SERVER_USE_SSL] = ambariServerUseSsl
-
-    return decompressedMap
-
   # Converts from 1-3,5,6-8 to [1,2,3,5,6,7,8]
   def convertRangeToList(self, list):
 
diff --git a/ambari-agent/src/main/python/ambari_agent/InitializerModule.py b/ambari-agent/src/main/python/ambari_agent/InitializerModule.py
index ea2e043..fbfab47 100644
--- a/ambari-agent/src/main/python/ambari_agent/InitializerModule.py
+++ b/ambari-agent/src/main/python/ambari_agent/InitializerModule.py
@@ -48,14 +48,13 @@ class InitializerModule:
   """
   def __init__(self):
     self.stop_event = threading.Event()
+    self.config = AmbariConfig.get_resolved_config()
     self.init()
 
   def init(self):
     """
     Initialize properties
     """
-    self.config = AmbariConfig.get_resolved_config()
-
     self.is_registered = False
 
     self.metadata_cache = ClusterMetadataCache(self.config.cluster_cache_dir)
diff --git a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
index 30c4075..badcb5f 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
@@ -44,8 +44,10 @@ from ambari_agent.FileCache import FileCache
 from ambari_agent.PythonExecutor import PythonExecutor
 from ambari_commons import OSCheck
 from only_for_platform import get_platform, os_distro_value, PLATFORM_WINDOWS
+from ambari_agent.InitializerModule import InitializerModule
+from ambari_agent.ConfigurationBuilder import ConfigurationBuilder
 
-class TestCustomServiceOrchestrator:#(TestCase):
+class TestCustomServiceOrchestrator(TestCase):
 
 
   def setUp(self):
@@ -65,83 +67,6 @@ class TestCustomServiceOrchestrator:#(TestCase):
 
 
   @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
-  @patch.object(FileCache, "__init__")
-  def test_add_reg_listener_to_controller(self, FileCache_mock):
-    FileCache_mock.return_value = None
-    dummy_controller = MagicMock()
-    config = AmbariConfig()
-    tempdir = tempfile.gettempdir()
-    config.set('agent', 'prefix', tempdir)
-    CustomServiceOrchestrator(config, dummy_controller)
-    self.assertTrue(dummy_controller.registration_listeners.append.called)
-
-
-  @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
-  @patch.object(CustomServiceOrchestrator, 'decompressClusterHostInfo')
-  @patch("ambari_agent.hostname.public_hostname")
-  @patch("os.path.isfile")
-  @patch("os.unlink")
-  @patch.object(FileCache, "__init__")
-  def test_dump_command_to_json(self, FileCache_mock, unlink_mock,
-                                isfile_mock, hostname_mock,
-                                decompress_cluster_host_info_mock):
-    FileCache_mock.return_value = None
-    hostname_mock.return_value = "test.hst"
-    command = {
-      'commandType': 'EXECUTION_COMMAND',
-      'role': u'DATANODE',
-      'roleCommand': u'INSTALL',
-      'commandId': '1-1',
-      'taskId': 3,
-      'clusterName': u'cc',
-      'serviceName': u'HDFS',
-      'configurations':{'global' : {}},
-      'configurationTags':{'global' : { 'tag': 'v1' }},
-      'clusterHostInfo':{'namenode_host' : ['1'],
-                         'slave_hosts'   : ['0', '1'],
-                         'all_hosts'     : ['h1.hortonworks.com', 'h2.hortonworks.com'],
-                         'all_ping_ports': ['8670:0,1']},
-      'hostLevelParams':{}
-    }
-    
-    decompress_cluster_host_info_mock.return_value = {'namenode_host' : ['h2.hortonworks.com'],
-                         'slave_hosts'   : ['h1.hortonworks.com', 'h2.hortonworks.com'],
-                         'all_hosts'     : ['h1.hortonworks.com', 'h2.hortonworks.com'],
-                         'all_ping_ports': ['8670', '8670']}
-    
-    config = AmbariConfig()
-    tempdir = tempfile.gettempdir()
-    config.set('agent', 'prefix', tempdir)
-    dummy_controller = MagicMock()
-    orchestrator = CustomServiceOrchestrator(config, dummy_controller)
-    isfile_mock.return_value = True
-    # Test dumping EXECUTION_COMMAND
-    json_file = orchestrator.dump_command_to_json(command)
-    self.assertTrue(os.path.exists(json_file))
-    self.assertTrue(os.path.getsize(json_file) > 0)
-    if get_platform() != PLATFORM_WINDOWS:
-      self.assertEqual(oct(os.stat(json_file).st_mode & 0777), '0600')
-    self.assertTrue(json_file.endswith("command-3.json"))
-    self.assertTrue(decompress_cluster_host_info_mock.called)
-    os.unlink(json_file)
-    # Test dumping STATUS_COMMAND
-    command['commandType']='STATUS_COMMAND'
-    decompress_cluster_host_info_mock.reset_mock()
-    json_file = orchestrator.dump_command_to_json(command)
-    self.assertTrue(os.path.exists(json_file))
-    self.assertTrue(os.path.getsize(json_file) > 0)
-    if get_platform() != PLATFORM_WINDOWS:
-      self.assertEqual(oct(os.stat(json_file).st_mode & 0777), '0600')
-    self.assertTrue(json_file.endswith("status_command.json"))
-    self.assertFalse(decompress_cluster_host_info_mock.called)
-    os.unlink(json_file)
-    # Testing side effect of dump_command_to_json
-    self.assertEquals(command['public_hostname'], "test.hst")
-    self.assertEquals(command['agentConfigParams']['agent']['parallel_execution'], 0)
-    self.assertTrue(unlink_mock.called)
-
-
-  @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
   @patch("ambari_agent.hostname.public_hostname")
   @patch("os.path.isfile")
   @patch("os.unlink")
@@ -172,11 +97,11 @@ class TestCustomServiceOrchestrator:#(TestCase):
       'hostLevelParams':{}
     }
 
-    config = AmbariConfig()
     tempdir = tempfile.gettempdir()
-    config.set('agent', 'prefix', tempdir)
-    dummy_controller = MagicMock()
-    orchestrator = CustomServiceOrchestrator(config, dummy_controller)
+    initializer_module = InitializerModule()
+    initializer_module.init()
+    initializer_module.config.set('agent', 'prefix', tempdir)
+    orchestrator = CustomServiceOrchestrator(initializer_module)
     isfile_mock.return_value = True
     # Test dumping EXECUTION_COMMAND
     json_file = orchestrator.dump_command_to_json(command)
@@ -195,8 +120,7 @@ class TestCustomServiceOrchestrator:#(TestCase):
     self.assertTrue(json_file.endswith("command-3.json"))
     os.unlink(json_file)
     # Testing side effect of dump_command_to_json
-    self.assertEquals(command['public_hostname'], "test.hst")
-    self.assertEquals(command['agentConfigParams']['agent']['parallel_execution'], 0)
+    self.assertNotEquals(command['clusterHostInfo'], {})
     self.assertTrue(unlink_mock.called)
 
   @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
@@ -206,7 +130,9 @@ class TestCustomServiceOrchestrator:#(TestCase):
     FileCache_mock.return_value = None
     dummy_controller = MagicMock()
     config = AmbariConfig()
-    orchestrator = CustomServiceOrchestrator(config, dummy_controller)
+    initializer_module = InitializerModule()
+    initializer_module.init()
+    orchestrator = CustomServiceOrchestrator(initializer_module)
     # Testing existing path
     exists_mock.return_value = True
     path = orchestrator.\
@@ -221,6 +147,7 @@ class TestCustomServiceOrchestrator:#(TestCase):
     except AgentException:
       pass # Expected
 
+  @patch.object(ConfigurationBuilder, "get_configuration")
   @patch.object(FileCache, "get_custom_resources_subdir")
   @patch.object(CustomServiceOrchestrator, "resolve_script_path")
   @patch.object(CustomServiceOrchestrator, "resolve_hook_script_path")
@@ -236,15 +163,17 @@ class TestCustomServiceOrchestrator:#(TestCase):
                       get_host_scripts_base_dir_mock, 
                       resolve_hook_script_path_mock, 
                       resolve_script_path_mock,
-                      get_custom_resources_subdir_mock):
+                      get_custom_resources_subdir_mock, get_configuration_mock):
     
     FileCache_mock.return_value = None
     command = {
       'commandType' : 'EXECUTION_COMMAND',
       'role' : 'REGION_SERVER',
-      'hostLevelParams' : {
+      'clusterLevelParams' : {
         'stack_name' : 'HDP',
         'stack_version' : '2.0.7',
+      },
+      'ambariLevelParams': {
         'jdk_location' : 'some_location'
       },
       'commandParams': {
@@ -254,8 +183,10 @@ class TestCustomServiceOrchestrator:#(TestCase):
         'service_package_folder' : 'HBASE'
       },
       'taskId' : '3',
-      'roleCommand': 'INSTALL'
+      'roleCommand': 'INSTALL',
+      'clusterId': '-1',
     }
+    get_configuration_mock.return_value = command
     
     get_host_scripts_base_dir_mock.return_value = "/host_scripts"
     get_service_base_dir_mock.return_value = "/basedir/"
@@ -263,8 +194,9 @@ class TestCustomServiceOrchestrator:#(TestCase):
     resolve_hook_script_path_mock.return_value = \
       ('/hooks_dir/prefix-command/scripts/hook.py',
        '/hooks_dir/prefix-command')
-    dummy_controller = MagicMock()
-    orchestrator = CustomServiceOrchestrator(self.config, dummy_controller)
+    initializer_module = InitializerModule()
+    initializer_module.init()
+    orchestrator = CustomServiceOrchestrator(initializer_module)
     unix_process_id = 111
     orchestrator.commands_in_progress = {command['taskId']: unix_process_id}
     get_hook_base_dir_mock.return_value = "/hooks/"
@@ -329,6 +261,7 @@ class TestCustomServiceOrchestrator:#(TestCase):
 
     pass
 
+  @patch.object(ConfigurationBuilder, "get_configuration")
   @patch("ambari_commons.shell.kill_process_with_children")
   @patch.object(CustomServiceOrchestrator, "resolve_script_path")
   @patch.object(CustomServiceOrchestrator, "resolve_hook_script_path")
@@ -343,13 +276,15 @@ class TestCustomServiceOrchestrator:#(TestCase):
                       get_hook_base_dir_mock, get_service_base_dir_mock,
                       get_host_scripts_base_dir_mock,
                       resolve_hook_script_path_mock, resolve_script_path_mock,
-                      kill_process_with_children_mock):
+                      kill_process_with_children_mock, get_configuration_mock):
     FileCache_mock.return_value = None
     command = {
       'role' : 'REGION_SERVER',
-      'hostLevelParams' : {
+      'clusterLevelParams' : {
         'stack_name' : 'HDP',
-        'stack_version' : '2.0.7',
+        'stack_version' : '2.0.7'
+      },
+      'ambariLevelParams': {
         'jdk_location' : 'some_location'
       },
       'commandParams': {
@@ -359,17 +294,20 @@ class TestCustomServiceOrchestrator:#(TestCase):
         'service_package_folder' : 'HBASE'
       },
       'taskId' : '3',
-      'roleCommand': 'INSTALL'
+      'roleCommand': 'INSTALL',
+      'clusterId': '-1'
     }
-    
+    get_configuration_mock.return_value = command
+        
     get_host_scripts_base_dir_mock.return_value = "/host_scripts"
     get_service_base_dir_mock.return_value = "/basedir/"
     resolve_script_path_mock.return_value = "/basedir/scriptpath"
     resolve_hook_script_path_mock.return_value = \
       ('/hooks_dir/prefix-command/scripts/hook.py',
        '/hooks_dir/prefix-command')
-    dummy_controller = MagicMock()
-    orchestrator = CustomServiceOrchestrator(self.config, dummy_controller)
+    initializer_module = InitializerModule()
+    initializer_module.init()
+    orchestrator = CustomServiceOrchestrator(initializer_module)
     unix_process_id = 111
     orchestrator.commands_in_progress = {command['taskId']: unix_process_id}
     get_hook_base_dir_mock.return_value = "/hooks/"
@@ -408,6 +346,7 @@ class TestCustomServiceOrchestrator:#(TestCase):
       pass
 
   @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
+  @patch.object(ConfigurationBuilder, "get_configuration")
   @patch.object(CustomServiceOrchestrator, "get_py_executor")
   @patch("ambari_commons.shell.kill_process_with_children")
   @patch.object(FileCache, "__init__")
@@ -415,7 +354,7 @@ class TestCustomServiceOrchestrator:#(TestCase):
   @patch.object(CustomServiceOrchestrator, "resolve_hook_script_path")
   def test_cancel_backgound_command(self, resolve_hook_script_path_mock,
                                     resolve_script_path_mock, FileCache_mock, kill_process_with_children_mock,
-                                    get_py_executor_mock):
+                                    get_py_executor_mock, get_configuration_mock):
     FileCache_mock.return_value = None
     FileCache_mock.cache_dir = MagicMock()
     resolve_hook_script_path_mock.return_value = None
@@ -425,10 +364,14 @@ class TestCustomServiceOrchestrator:#(TestCase):
     cfg.set('agent', 'prefix', '.')
     cfg.set('agent', 'cache_dir', 'background_tasks')
 
-    actionQueue = ActionQueue(cfg, dummy_controller)
+    initializer_module = InitializerModule()
+    initializer_module.init()
+    
+    actionQueue = ActionQueue(initializer_module)
+    orchestrator = CustomServiceOrchestrator(initializer_module)
 
-    dummy_controller.actionQueue = actionQueue
-    orchestrator = CustomServiceOrchestrator(cfg, dummy_controller)
+    initializer_module.actionQueue = actionQueue
+    
     orchestrator.file_cache = MagicMock()
     def f (a, b):
       return ""
@@ -455,6 +398,8 @@ class TestCustomServiceOrchestrator:#(TestCase):
 
     actionQueue.on_background_command_complete_callback = TestActionQueue.wraped(actionQueue.on_background_command_complete_callback, command_complete_w, None)
     execute_command = copy.deepcopy(TestActionQueue.TestActionQueue.background_command)
+    get_configuration_mock.return_value = execute_command
+    
     actionQueue.put([execute_command])
     actionQueue.processBackgroundQueueSafeEmpty()
 
@@ -477,6 +422,7 @@ class TestCustomServiceOrchestrator:#(TestCase):
     self.assertEqual(runningCommand['status'], ActionQueue.FAILED_STATUS)
 
 
+  @patch.object(ConfigurationBuilder, "get_configuration")
   @patch.object(AmbariConfig, "get")
   @patch.object(CustomServiceOrchestrator, "dump_command_to_json")
   @patch.object(PythonExecutor, "run_file")
@@ -484,7 +430,7 @@ class TestCustomServiceOrchestrator:#(TestCase):
   @patch.object(FileCache, "get_custom_actions_base_dir")
   def test_runCommand_custom_action(self, get_custom_actions_base_dir_mock,
                                     FileCache_mock,
-                                    run_file_mock, dump_command_to_json_mock, ambari_config_get):
+                                    run_file_mock, dump_command_to_json_mock, ambari_config_get, get_configuration_mock):
     ambari_config_get.return_value = "0"
     FileCache_mock.return_value = None
     get_custom_actions_base_dir_mock.return_value = "some path"
@@ -495,13 +441,22 @@ class TestCustomServiceOrchestrator:#(TestCase):
         'script_type': 'PYTHON',
         'script': 'some_custom_action.py',
         'command_timeout': '600',
+      },
+      'ambariLevelParams': {
         'jdk_location' : 'some_location'
       },
       'taskId' : '3',
-      'roleCommand': 'ACTIONEXECUTE'
+      'roleCommand': 'ACTIONEXECUTE',
+      'clusterId': '-1',
     }
-    dummy_controller = MagicMock()
-    orchestrator = CustomServiceOrchestrator(self.config, dummy_controller)
+    get_configuration_mock.return_value = command
+    
+    initializer_module = InitializerModule()
+    initializer_module.config = self.config
+    initializer_module.init()
+    
+    
+    orchestrator = CustomServiceOrchestrator(initializer_module)
     unix_process_id = 111
     orchestrator.commands_in_progress = {command['taskId']: unix_process_id}
     # normal run case
@@ -523,7 +478,9 @@ class TestCustomServiceOrchestrator:#(TestCase):
   def test_resolve_hook_script_path(self, FileCache_mock, isfile_mock):
     FileCache_mock.return_value = None
     dummy_controller = MagicMock()
-    orchestrator = CustomServiceOrchestrator(self.config, dummy_controller)
+    initializer_module = InitializerModule()
+    initializer_module.init()
+    orchestrator = CustomServiceOrchestrator(initializer_module)
     # Testing None param
     res1 = orchestrator.resolve_hook_script_path(None, "prefix", "command",
                                             "script_type")
@@ -553,7 +510,9 @@ class TestCustomServiceOrchestrator:#(TestCase):
       'configurations':{}
     }
     dummy_controller = MagicMock()
-    orchestrator = CustomServiceOrchestrator(self.config, dummy_controller)
+    initializer_module = InitializerModule()
+    initializer_module.init()
+    orchestrator = CustomServiceOrchestrator(initializer_module)
     # Test alive case
     runCommand_mock.return_value = {
       "exitcode" : 0
@@ -570,6 +529,7 @@ class TestCustomServiceOrchestrator:#(TestCase):
     self.assertEqual(runCommand_mock.return_value, status)
 
 
+  @patch.object(ConfigurationBuilder, "get_configuration")
   @patch.object(CustomServiceOrchestrator, "get_py_executor")
   @patch.object(CustomServiceOrchestrator, "dump_command_to_json")
   @patch.object(FileCache, "__init__")
@@ -577,7 +537,7 @@ class TestCustomServiceOrchestrator:#(TestCase):
   def test_runCommand_background_action(self, get_custom_actions_base_dir_mock,
                                     FileCache_mock,
                                     dump_command_to_json_mock,
-                                    get_py_executor_mock):
+                                    get_py_executor_mock, get_configuration_mock):
     FileCache_mock.return_value = None
     get_custom_actions_base_dir_mock.return_value = "some path"
     _, script = tempfile.mkstemp()
@@ -587,16 +547,20 @@ class TestCustomServiceOrchestrator:#(TestCase):
         'script_type': 'PYTHON',
         'script': 'some_custom_action.py',
         'command_timeout': '600',
+      },
+      'ambariLevelParams': {
         'jdk_location' : 'some_location'
       },
+      'clusterId': '-1',
       'taskId' : '13',
       'roleCommand': 'ACTIONEXECUTE',
       'commandType': 'BACKGROUND_EXECUTION_COMMAND',
       '__handle': BackgroundCommandExecutionHandle({'taskId': '13'}, 13,
                                                    MagicMock(), MagicMock())
     }
-    dummy_controller = MagicMock()
-    orchestrator = CustomServiceOrchestrator(self.config, dummy_controller)
+    initializer_module = InitializerModule()
+    initializer_module.init()
+    orchestrator = CustomServiceOrchestrator(initializer_module)
 
     import TestActionQueue
     pyex = PythonExecutor(orchestrator.tmp_dir, orchestrator.config)
diff --git a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
index db30be0..a0a4283 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
@@ -30,7 +30,7 @@ from ambari_agent.Hardware import Hardware
 from ambari_agent.Facter import FacterLinux
 
 @not_for_platform(PLATFORM_WINDOWS)
-class TestRegistration:#(TestCase):
+class TestRegistration(TestCase):
 
   @patch("subprocess32.Popen")
   @patch.object(Hardware, "_chk_writable_mount", new = MagicMock(return_value=True))
@@ -50,17 +50,15 @@ class TestRegistration:#(TestCase):
     run_os_cmd_mock.return_value = (3, "", "")
     register = Register(config)
     reference_version = '2.1.0'
-    data = register.build(reference_version, 1)
+    data = register.build()
     self.assertEquals(len(data['hardwareProfile']) > 0, True, "hardwareProfile should contain content")
     self.assertEquals(data['hostname'] != "", True, "hostname should not be empty")
     self.assertEquals(data['publicHostname'] != "", True, "publicHostname should not be empty")
-    self.assertEquals(data['responseId'], 1)
+    self.assertEquals(data['id'], -1)
     self.assertEquals(data['timestamp'] > 1353678475465L, True, "timestamp should not be empty")
     self.assertEquals(len(data['agentEnv']) > 0, True, "agentEnv should not be empty")
-    self.assertEquals(data['agentVersion'], reference_version, "agentVersion should not be empty")
     self.assertEquals(not data['agentEnv']['umask']== "", True, "agents umask should not be empty")
-    self.assertEquals(data['currentPingPort'] == 33777, True, "current ping port should be 33777")
     self.assertEquals(data['prefix'], config.get('agent', 'prefix'), 'The prefix path does not match')
-    self.assertEquals(len(data), 9)
+    self.assertEquals(len(data), 10)
 
 

-- 
To stop receiving notification emails like this one, please contact
aonishuk@apache.org.