You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2013/11/19 19:17:21 UTC

[7/7] git commit: AMBARI-3810. Unittests for File resource an all it's attributes (Eugene Chekanskiy via dlysnichenko)

AMBARI-3810. Unittests for File resource an all it's attributes (Eugene Chekanskiy via dlysnichenko)


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

Branch: refs/heads/trunk
Commit: e5c6e113052191a5f677ae9d04997ec0f797234a
Parents: b2571e4
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Tue Nov 19 20:16:06 2013 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Tue Nov 19 20:16:06 2013 +0200

----------------------------------------------------------------------
 .gitignore                                      |   2 +-
 ambari-agent/pom.xml                            |   2 +-
 ambari-agent/src/test/python/TestActionQueue.py | 420 ---------------
 .../src/test/python/TestActualConfigHandler.py  |  82 ---
 .../src/test/python/TestAgentActions.py         |  30 --
 ambari-agent/src/test/python/TestAmbariAgent.py |  53 --
 .../src/test/python/TestCertGeneration.py       |  48 --
 ambari-agent/src/test/python/TestCheckWebUI.py  |  76 ---
 .../src/test/python/TestCommandStatusDict.py    | 125 -----
 ambari-agent/src/test/python/TestController.py  | 408 --------------
 .../python/TestCustomServiceOrchestrator.py     | 144 -----
 ambari-agent/src/test/python/TestDataCleaner.py | 101 ----
 ambari-agent/src/test/python/TestFileCache.py   |  68 ---
 ambari-agent/src/test/python/TestGrep.py        | 117 -----
 ambari-agent/src/test/python/TestHardware.py    | 168 ------
 ambari-agent/src/test/python/TestHeartbeat.py   | 211 --------
 .../python/TestHostCheckReportFileHandler.py    | 161 ------
 ambari-agent/src/test/python/TestHostCleanup.py | 429 ---------------
 ambari-agent/src/test/python/TestHostInfo.py    | 525 -------------------
 ambari-agent/src/test/python/TestHostname.py    |  82 ---
 ambari-agent/src/test/python/TestLiveStatus.py  |  60 ---
 ambari-agent/src/test/python/TestMain.py        | 276 ----------
 .../src/test/python/TestManifestGenerator.py    | 142 -----
 ambari-agent/src/test/python/TestNetUtil.py     |  77 ---
 .../src/test/python/TestPingPortListener.py     |  60 ---
 .../src/test/python/TestProcessHelper.py        |  68 ---
 .../src/test/python/TestPuppetExecutor.py       | 314 -----------
 .../test/python/TestPuppetExecutorManually.py   |  57 --
 .../src/test/python/TestPythonExecutor.py       | 159 ------
 .../src/test/python/TestRegistration.py         |  58 --
 .../src/test/python/TestRepoInstaller.py        |  77 ---
 ambari-agent/src/test/python/TestScript.py      |  90 ----
 ambari-agent/src/test/python/TestSecurity.py    | 347 ------------
 ambari-agent/src/test/python/TestShell.py       |  78 ---
 .../test/python/TestStackVersionsFileHandler.py | 116 ----
 ambari-agent/src/test/python/TestStatusCheck.py | 172 ------
 .../test/python/ambari_agent/TestActionQueue.py | 420 +++++++++++++++
 .../ambari_agent/TestActualConfigHandler.py     |  82 +++
 .../python/ambari_agent/TestAgentActions.py     |  30 ++
 .../test/python/ambari_agent/TestAmbariAgent.py |  53 ++
 .../python/ambari_agent/TestCertGeneration.py   |  48 ++
 .../test/python/ambari_agent/TestCheckWebUI.py  |  76 +++
 .../ambari_agent/TestCommandStatusDict.py       | 125 +++++
 .../test/python/ambari_agent/TestController.py  | 408 ++++++++++++++
 .../TestCustomServiceOrchestrator.py            | 144 +++++
 .../test/python/ambari_agent/TestDataCleaner.py | 101 ++++
 .../test/python/ambari_agent/TestFileCache.py   |  68 +++
 .../src/test/python/ambari_agent/TestGrep.py    | 117 +++++
 .../test/python/ambari_agent/TestHardware.py    | 168 ++++++
 .../test/python/ambari_agent/TestHeartbeat.py   | 211 ++++++++
 .../TestHostCheckReportFileHandler.py           | 161 ++++++
 .../test/python/ambari_agent/TestHostCleanup.py | 429 +++++++++++++++
 .../test/python/ambari_agent/TestHostInfo.py    | 525 +++++++++++++++++++
 .../test/python/ambari_agent/TestHostname.py    |  82 +++
 .../test/python/ambari_agent/TestLiveStatus.py  |  60 +++
 .../src/test/python/ambari_agent/TestMain.py    | 276 ++++++++++
 .../ambari_agent/TestManifestGenerator.py       | 142 +++++
 .../src/test/python/ambari_agent/TestNetUtil.py |  77 +++
 .../python/ambari_agent/TestPingPortListener.py |  60 +++
 .../python/ambari_agent/TestProcessHelper.py    |  68 +++
 .../python/ambari_agent/TestPuppetExecutor.py   | 314 +++++++++++
 .../ambari_agent/TestPuppetExecutorManually.py  |  57 ++
 .../python/ambari_agent/TestPythonExecutor.py   | 159 ++++++
 .../python/ambari_agent/TestRegistration.py     |  58 ++
 .../python/ambari_agent/TestRepoInstaller.py    |  77 +++
 .../src/test/python/ambari_agent/TestScript.py  |  90 ++++
 .../test/python/ambari_agent/TestSecurity.py    | 347 ++++++++++++
 .../src/test/python/ambari_agent/TestShell.py   |  78 +++
 .../TestStackVersionsFileHandler.py             | 116 ++++
 .../test/python/ambari_agent/TestStatusCheck.py | 172 ++++++
 .../dummy_files/dummy_current_stack             |  22 +
 .../ambari_agent/dummy_files/test_rco_data.json |  19 +
 .../ambari_agent/dummy_puppet_output_error.txt  |  45 ++
 .../ambari_agent/dummy_puppet_output_error2.txt |  40 ++
 .../ambari_agent/dummy_puppet_output_error3.txt |  76 +++
 .../ambari_agent/dummy_puppet_output_good.txt   |  47 ++
 .../ambari_agent/examples/ControllerTester.py   | 243 +++++++++
 .../examples/debug_testcase_example.py          |  74 +++
 .../src/test/python/ambari_agent/winpwd.py      |  30 ++
 .../test/python/dummy_files/dummy_current_stack |  22 -
 .../test/python/dummy_files/test_rco_data.json  |  19 -
 .../test/python/dummy_puppet_output_error.txt   |  45 --
 .../test/python/dummy_puppet_output_error2.txt  |  40 --
 .../test/python/dummy_puppet_output_error3.txt  |  76 ---
 .../test/python/dummy_puppet_output_good.txt    |  47 --
 .../test/python/examples/ControllerTester.py    | 243 ---------
 .../python/examples/debug_testcase_example.py   |  74 ---
 .../resource_management/TestFileResource.py     | 332 ++++++++++++
 ambari-agent/src/test/python/unitTests.py       |   5 +-
 ambari-agent/src/test/python/winpwd.py          |  30 --
 90 files changed, 6333 insertions(+), 5998 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 681002b..246e53e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,4 +18,4 @@ target
 .hgtags
 derby.log
 pass.txt
-ambari-agent/src/test/python/dummy_files/current-stack
+ambari-agent/src/test/python/ambari_agent/dummy_files/current-stack

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-agent/pom.xml b/ambari-agent/pom.xml
index e6e8c72..51bda92 100644
--- a/ambari-agent/pom.xml
+++ b/ambari-agent/pom.xml
@@ -124,7 +124,7 @@
                 <argument>unitTests.py</argument>
               </arguments>
               <environmentVariables>
-                <PYTHONPATH>${project.basedir}/../ambari-common/src/test/python:${project.basedir}/../ambari-common/src/main/python:${project.basedir}/src/main/python/ambari_agent:${project.basedir}/src/main/python/resource_management:${project.basedir}/src/main/puppet/modules/hdp-hadoop/files:$PYTHONPATH</PYTHONPATH>
+                <PYTHONPATH>${project.basedir}/../ambari-common/src/test/python:${project.basedir}/../ambari-common/src/main/python:${project.basedir}/src/main/python/ambari_agent:${project.basedir}/src/main/python/resource_management:${project.basedir}/src/test/python/ambari_agent:${project.basedir}/src/test/python/resource_management:${project.basedir}/src/main/python:${project.basedir}/../ambari-agent/src/main/puppet/modules/hdp-hadoop/files:$PYTHONPATH</PYTHONPATH>
               </environmentVariables>
               <skip>${skipTests}</skip>
             </configuration>

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestActionQueue.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestActionQueue.py b/ambari-agent/src/test/python/TestActionQueue.py
deleted file mode 100644
index 98817e9..0000000
--- a/ambari-agent/src/test/python/TestActionQueue.py
+++ /dev/null
@@ -1,420 +0,0 @@
-#!/usr/bin/env python2.6
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-from Queue import Queue
-
-from unittest import TestCase
-from ambari_agent.LiveStatus import LiveStatus
-from ambari_agent.PuppetExecutor import PuppetExecutor
-from ambari_agent.ActionQueue import ActionQueue
-from ambari_agent.AmbariConfig import AmbariConfig
-import os, errno, time, pprint, tempfile, threading
-import StringIO
-import sys
-from threading import Thread
-
-from mock.mock import patch, MagicMock, call
-from ambari_agent.StackVersionsFileHandler import StackVersionsFileHandler
-from ambari_agent.CustomServiceOrchestrator import CustomServiceOrchestrator
-
-
-class TestActionQueue(TestCase):
-
-  def setUp(self):
-    out = StringIO.StringIO()
-    sys.stdout = out
-    # save original open() method for later use
-    self.original_open = open
-
-
-  def tearDown(self):
-    sys.stdout = sys.__stdout__
-
-  datanode_install_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' }}
-  }
-
-  datanode_upgrade_command = {
-      'commandId': 17,
-      'role' : "role",
-      'taskId' : "taskId",
-      'clusterName' : "clusterName",
-      'serviceName' : "serviceName",
-      'roleCommand' : 'UPGRADE',
-      'hostname' : "localhost.localdomain",
-      'hostLevelParams': "hostLevelParams",
-      'clusterHostInfo': "clusterHostInfo",
-      'commandType': "EXECUTION_COMMAND",
-      'configurations':{'global' : {}},
-      'roleParams': {},
-      'commandParams' :	{
-        'source_stack_version' : 'HDP-1.2.1',
-        'target_stack_version' : 'HDP-1.3.0'
-      }
-    }
-
-  namenode_install_command = {
-    'commandType': 'EXECUTION_COMMAND',
-    'role': u'NAMENODE',
-    'roleCommand': u'INSTALL',
-    'commandId': '1-1',
-    'taskId': 4,
-    'clusterName': u'cc',
-    'serviceName': u'HDFS',
-    }
-
-  snamenode_install_command = {
-    'commandType': 'EXECUTION_COMMAND',
-    'role': u'SECONDARY_NAMENODE',
-    'roleCommand': u'INSTALL',
-    'commandId': '1-1',
-    'taskId': 5,
-    'clusterName': u'cc',
-    'serviceName': u'HDFS',
-    }
-
-  nagios_install_command = {
-    'commandType': 'EXECUTION_COMMAND',
-    'role': u'NAGIOS',
-    'roleCommand': u'INSTALL',
-    'commandId': '1-1',
-    'taskId': 6,
-    'clusterName': u'cc',
-    'serviceName': u'HDFS',
-    }
-
-  hbase_install_command = {
-    'commandType': 'EXECUTION_COMMAND',
-    'role': u'HBASE',
-    'roleCommand': u'INSTALL',
-    'commandId': '1-1',
-    'taskId': 7,
-    'clusterName': u'cc',
-    'serviceName': u'HDFS',
-    }
-
-  status_command = {
-    "serviceName" : 'HDFS',
-    "commandType" : "STATUS_COMMAND",
-    "clusterName" : "",
-    "componentName" : "DATANODE",
-    'configurations':{}
-  }
-
-
-  @patch.object(ActionQueue, "process_command")
-  @patch.object(Queue, "get")
-  def test_ActionQueueStartStop(self, get_mock, process_command_mock):
-    actionQueue = ActionQueue(AmbariConfig().getConfig(), 'dummy_controller')
-    actionQueue.start()
-    time.sleep(0.1)
-    actionQueue.stop()
-    actionQueue.join()
-    self.assertEqual(actionQueue.stopped(), True, 'Action queue is not stopped.')
-    self.assertTrue(process_command_mock.call_count > 1)
-
-
-  @patch("traceback.print_exc")
-  @patch.object(ActionQueue, "execute_command")
-  @patch.object(ActionQueue, "execute_status_command")
-  def test_process_command(self, execute_status_command_mock,
-                           execute_command_mock, print_exc_mock):
-    actionQueue = ActionQueue(AmbariConfig().getConfig(), 'dummy_controller')
-    execution_command = {
-      'commandType' : ActionQueue.EXECUTION_COMMAND,
-    }
-    status_command = {
-      'commandType' : ActionQueue.STATUS_COMMAND,
-    }
-    wrong_command = {
-      'commandType' : "SOME_WRONG_COMMAND",
-    }
-    # Try wrong command
-    actionQueue.process_command(wrong_command)
-    self.assertFalse(execute_command_mock.called)
-    self.assertFalse(execute_status_command_mock.called)
-    self.assertFalse(print_exc_mock.called)
-
-    execute_command_mock.reset_mock()
-    execute_status_command_mock.reset_mock()
-    print_exc_mock.reset_mock()
-    # Try normal execution
-    actionQueue.process_command(execution_command)
-    self.assertTrue(execute_command_mock.called)
-    self.assertFalse(execute_status_command_mock.called)
-    self.assertFalse(print_exc_mock.called)
-
-    execute_command_mock.reset_mock()
-    execute_status_command_mock.reset_mock()
-    print_exc_mock.reset_mock()
-
-    actionQueue.process_command(status_command)
-    self.assertFalse(execute_command_mock.called)
-    self.assertTrue(execute_status_command_mock.called)
-    self.assertFalse(print_exc_mock.called)
-
-    execute_command_mock.reset_mock()
-    execute_status_command_mock.reset_mock()
-    print_exc_mock.reset_mock()
-
-    # Try exception to check proper logging
-    def side_effect(self):
-      raise Exception("TerribleException")
-    execute_command_mock.side_effect = side_effect
-    actionQueue.process_command(execution_command)
-    self.assertTrue(print_exc_mock.called)
-
-    print_exc_mock.reset_mock()
-
-    execute_status_command_mock.side_effect = side_effect
-    actionQueue.process_command(execution_command)
-    self.assertTrue(print_exc_mock.called)
-
-
-
-  @patch("__builtin__.open")
-  @patch.object(ActionQueue, "status_update_callback")
-  def test_execute_command(self, status_update_callback_mock, open_mock):
-    # Make file read calls visible
-    def open_side_effect(file, mode):
-      if mode == 'r':
-        file_mock = MagicMock()
-        file_mock.read.return_value = "Read from " + str(file)
-        return file_mock
-      else:
-        return self.original_open(file, mode)
-    open_mock.side_effect = open_side_effect
-
-    config = AmbariConfig().getConfig()
-    tempdir = tempfile.gettempdir()
-    config.set('agent', 'prefix', tempdir)
-    actionQueue = ActionQueue(config, 'dummy_controller')
-    unfreeze_flag = threading.Event()
-    puppet_execution_result_dict = {
-      'stdout': 'out',
-      'stderr': 'stderr',
-      }
-    def side_effect(command, tmpoutfile, tmperrfile):
-      unfreeze_flag.wait()
-      return puppet_execution_result_dict
-    def patched_aq_execute_command(command):
-      # We have to perform patching for separate thread in the same thread
-      with patch.object(PuppetExecutor, "runCommand") as runCommand_mock:
-          runCommand_mock.side_effect = side_effect
-          actionQueue.execute_command(command)
-    ### Test install/start/stop command ###
-    ## Test successful execution with configuration tags
-    puppet_execution_result_dict['status'] = 'COMPLETE'
-    puppet_execution_result_dict['exitcode'] = 0
-    # 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)
-      report = actionQueue.result()
-      if len(report['reports']) != 0:
-        break
-    expected = {'status': 'IN_PROGRESS',
-                'stderr': 'Read from {0}/errors-3.txt'.format(tempdir),
-                'stdout': 'Read from {0}/output-3.txt'.format(tempdir),
-                'clusterName': u'cc',
-                'roleCommand': u'INSTALL',
-                'serviceName': u'HDFS',
-                'role': u'DATANODE',
-                'actionId': '1-1',
-                'taskId': 3,
-                'exitCode': 777}
-    self.assertEqual(report['reports'][0], expected)
-    # Continue command execution
-    unfreeze_flag.set()
-    # wait until ready
-    while report['reports'][0]['status'] == 'IN_PROGRESS':
-      time.sleep(0.1)
-      report = actionQueue.result()
-    # check report
-    configname = os.path.join(tempdir, 'config.json')
-    expected = {'status': 'COMPLETED',
-                'stderr': 'stderr',
-                'stdout': 'out',
-                'clusterName': u'cc',
-                'configurationTags': {'global': {'tag': 'v1'}},
-                'roleCommand': u'INSTALL',
-                'serviceName': u'HDFS',
-                'role': u'DATANODE',
-                'actionId': '1-1',
-                'taskId': 3,
-                'exitCode': 0}
-    self.assertEqual(len(report['reports']), 1)
-    self.assertEqual(report['reports'][0], expected)
-    self.assertTrue(os.path.isfile(configname))
-    # Check that we had 2 status update calls ( IN_PROGRESS and COMPLETE)
-    self.assertEqual(status_update_callback_mock.call_count, 2)
-    os.remove(configname)
-
-    # now should not have reports (read complete/failed reports are deleted)
-    report = actionQueue.result()
-    self.assertEqual(len(report['reports']), 0)
-
-    ## Test failed execution
-    puppet_execution_result_dict['status'] = 'FAILED'
-    puppet_execution_result_dict['exitcode'] = 13
-    # We call method in a separate thread
-    execution_thread = Thread(target = patched_aq_execute_command ,
-                              args = (self.datanode_install_command, ))
-    execution_thread.start()
-    unfreeze_flag.set()
-    #  check in progress report
-    # wait until ready
-    report = actionQueue.result()
-    while len(report['reports']) == 0 or \
-                    report['reports'][0]['status'] == 'IN_PROGRESS':
-      time.sleep(0.1)
-      report = actionQueue.result()
-      # check report
-    expected = {'status': 'FAILED',
-                'stderr': 'stderr',
-                'stdout': 'out',
-                'clusterName': u'cc',
-                'roleCommand': u'INSTALL',
-                'serviceName': u'HDFS',
-                'role': u'DATANODE',
-                'actionId': '1-1',
-                'taskId': 3,
-                'exitCode': 13}
-    self.assertEqual(len(report['reports']), 1)
-    self.assertEqual(report['reports'][0], expected)
-
-    # now should not have reports (read complete/failed reports are deleted)
-    report = actionQueue.result()
-    self.assertEqual(len(report['reports']), 0)
-
-    ### Test upgrade command ###
-    puppet_execution_result_dict['status'] = 'COMPLETE'
-    puppet_execution_result_dict['exitcode'] = 0
-    execution_thread = Thread(target = patched_aq_execute_command ,
-                              args = (self.datanode_upgrade_command, ))
-    execution_thread.start()
-    unfreeze_flag.set()
-    # wait until ready
-    report = actionQueue.result()
-    while len(report['reports']) == 0 or \
-                    report['reports'][0]['status'] == 'IN_PROGRESS':
-      time.sleep(0.1)
-      report = actionQueue.result()
-    # check report
-    expected = {'status': 'COMPLETED',
-                'stderr': 'stderr',
-                'stdout': 'out',
-                'clusterName': 'clusterName',
-                'roleCommand': 'UPGRADE',
-                'serviceName': 'serviceName',
-                'role': 'role',
-                'actionId': 17,
-                'taskId': 'taskId',
-                'exitCode': 0}
-    self.assertEqual(len(report['reports']), 1)
-    self.assertEqual(report['reports'][0], expected)
-
-    # now should not have reports (read complete/failed reports are deleted)
-    report = actionQueue.result()
-    self.assertEqual(len(report['reports']), 0)
-
-
-  @patch.object(ActionQueue, "status_update_callback")
-  @patch.object(StackVersionsFileHandler, "read_stack_version")
-  @patch.object(ActionQueue, "execute_command")
-  @patch.object(LiveStatus, "build")
-  def test_execute_status_command(self, build_mock, execute_command_mock,
-                                  read_stack_version_mock,
-                                  status_update_callback):
-    actionQueue = ActionQueue(AmbariConfig().getConfig(), 'dummy_controller')
-    build_mock.return_value = "dummy report"
-    # Try normal execution
-    actionQueue.execute_status_command(self.status_command)
-    report = actionQueue.result()
-    expected = 'dummy report'
-    self.assertEqual(len(report['componentStatus']), 1)
-    self.assertEqual(report['componentStatus'][0], expected)
-
-
-  def test_determine_command_format_version(self):
-    v1_command = {
-      'commandParams': {
-        'schema_version': '1.0'
-      }
-    }
-    v2_command = {
-      'commandParams': {
-        'schema_version': '2.0'
-      }
-    }
-    current_command = {
-      # Absent 'commandParams' section
-    }
-    actionQueue = ActionQueue(AmbariConfig().getConfig(), 'dummy_controller')
-    self.assertEqual(actionQueue.determine_command_format_version(v1_command),
-                     ActionQueue.COMMAND_FORMAT_V1)
-    self.assertEqual(actionQueue.determine_command_format_version(v2_command),
-                     ActionQueue.COMMAND_FORMAT_V2)
-    self.assertEqual(actionQueue.determine_command_format_version(current_command),
-                     ActionQueue.COMMAND_FORMAT_V1)
-
-
-  @patch.object(ActionQueue, "determine_command_format_version")
-  @patch("__builtin__.open")
-  @patch.object(PuppetExecutor, "runCommand")
-  @patch.object(CustomServiceOrchestrator, "runCommand")
-  @patch.object(ActionQueue, "status_update_callback")
-  def test_command_execution_depending_on_command_format(self,
-                                status_update_callback_mock,
-                                custom_ex_runCommand_mock,
-                                puppet_runCommand_mock, open_mock,
-                                determine_command_format_version_mock):
-    actionQueue = ActionQueue(AmbariConfig().getConfig(), 'dummy_controller')
-    ret = {
-      'stdout' : '',
-      'stderr' : '',
-      'exitcode': 1,
-      }
-    puppet_runCommand_mock.return_value = ret
-    determine_command_format_version_mock.return_value = \
-                                  ActionQueue.COMMAND_FORMAT_V1
-    actionQueue.execute_command(self.datanode_install_command)
-    self.assertTrue(puppet_runCommand_mock.called)
-    self.assertFalse(custom_ex_runCommand_mock.called)
-
-    puppet_runCommand_mock.reset_mock()
-
-    custom_ex_runCommand_mock.return_value = ret
-    determine_command_format_version_mock.return_value = \
-      ActionQueue.COMMAND_FORMAT_V2
-    actionQueue.execute_command(self.datanode_install_command)
-    self.assertFalse(puppet_runCommand_mock.called)
-    self.assertTrue(custom_ex_runCommand_mock.called)

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestActualConfigHandler.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestActualConfigHandler.py b/ambari-agent/src/test/python/TestActualConfigHandler.py
deleted file mode 100644
index 2461499..0000000
--- a/ambari-agent/src/test/python/TestActualConfigHandler.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env python2.6
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-import tempfile
-from unittest import TestCase
-from ambari_agent.AmbariConfig import AmbariConfig
-from ambari_agent.ActualConfigHandler import ActualConfigHandler
-import os
-import logging
-import json
-
-class TestActualConfigHandler(TestCase):
-
-  logger = logging.getLogger()
-
-  def test_read_write(self):
-    config = AmbariConfig().getConfig()
-    tmpdir = tempfile.gettempdir()
-    config.set('agent', 'prefix', tmpdir)
-    handler = ActualConfigHandler(config)
-    
-    tags = { "global": "version1", "core-site": "version2" }
-    handler.write_actual(tags)
-    output = handler.read_actual()
-    self.assertEquals(tags, output)
-    os.remove(os.path.join(tmpdir, ActualConfigHandler.CONFIG_NAME))
-
-  def test_read_empty(self):
-    config = AmbariConfig().getConfig()
-    tmpdir = tempfile.gettempdir()
-    config.set('agent', 'prefix', tmpdir)
-    handler = ActualConfigHandler(config)
-
-    conf_file = open(os.path.join(tmpdir, ActualConfigHandler.CONFIG_NAME), 'w')
-    conf_file.write("")
-    conf_file.close()
-    
-    output = handler.read_actual()
-    self.assertEquals(None, output)
-    os.remove(os.path.join(tmpdir, ActualConfigHandler.CONFIG_NAME))
-
-  def test_read_write_component(self):
-    config = AmbariConfig().getConfig()
-    tmpdir = tempfile.gettempdir()
-    config.set('agent', 'prefix', tmpdir)
-    handler = ActualConfigHandler(config)
-
-    tags1 = { "global": "version1", "core-site": "version2" }
-    handler.write_actual(tags1)
-    handler.copy_to_component('FOO')
-
-    output1 = handler.read_actual_component('FOO')
-    output2 = handler.read_actual_component('GOO') 
-
-    self.assertEquals(tags1, output1)
-    self.assertEquals(None, output2)
-    
-    tags2 = { "global": "version1", "core-site": "version2" }
-    handler.write_actual(tags2)
-
-    output3 = handler.read_actual()
-    output4 = handler.read_actual_component('FOO')
-    self.assertEquals(tags2, output3)
-    self.assertEquals(tags1, output4)
-    os.remove(os.path.join(tmpdir, "FOO_" + ActualConfigHandler.CONFIG_NAME))
-    os.remove(os.path.join(tmpdir, ActualConfigHandler.CONFIG_NAME))

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestAgentActions.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestAgentActions.py b/ambari-agent/src/test/python/TestAgentActions.py
deleted file mode 100644
index dc3c919..0000000
--- a/ambari-agent/src/test/python/TestAgentActions.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python2.6
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-
-from unittest import TestCase
-
-
-class TestAgentActions(TestCase):
-#This feature is not yet implemented in ActionQueue
-  def test_installAndConfigAction(self):
-    pass
-#This feature is not yet implemented in ActionQueue
-  def test_startAndStopAction(self):
-    pass

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestAmbariAgent.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestAmbariAgent.py b/ambari-agent/src/test/python/TestAmbariAgent.py
deleted file mode 100644
index 5a82160..0000000
--- a/ambari-agent/src/test/python/TestAmbariAgent.py
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/env python2.6
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-
-import unittest
-import subprocess
-import os
-import sys
-from mock.mock import MagicMock, patch, ANY
-from ambari_agent.Controller import AGENT_AUTO_RESTART_EXIT_CODE
-from ambari_agent import AmbariAgent
-
-
-class TestAmbariAgent(unittest.TestCase):
-
-  @patch.object(subprocess, "Popen")
-  @patch("os.path.isfile")
-  @patch("os.remove")
-  def test_main(self, os_remove_mock, os_path_isfile_mock, subprocess_popen_mock):
-    facter1 = MagicMock()
-    facter2 = MagicMock()
-    subprocess_popen_mock.side_effect = [facter1, facter2]
-    facter1.returncode = 77
-    facter2.returncode = 55
-    os_path_isfile_mock.return_value = True
-    if not (os.environ.has_key("PYTHON")):
-      os.environ['PYTHON'] = "test/python/path"
-    sys.argv[0] = "test data"
-    AmbariAgent.main()
-
-    self.assertTrue(subprocess_popen_mock.called)
-    self.assertTrue(subprocess_popen_mock.call_count == 2)
-    self.assertTrue(facter1.communicate.called)
-    self.assertTrue(facter2.communicate.called)
-    self.assertTrue(os_path_isfile_mock.called)
-    self.assertTrue(os_path_isfile_mock.call_count == 2)
-    self.assertTrue(os_remove_mock.called)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestCertGeneration.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestCertGeneration.py b/ambari-agent/src/test/python/TestCertGeneration.py
deleted file mode 100644
index 94bb9f6..0000000
--- a/ambari-agent/src/test/python/TestCertGeneration.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env python2.6
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-import os
-import tempfile
-import shutil
-from unittest import TestCase
-import ConfigParser
-import security
-from security import CertificateManager
-from ambari_agent import AmbariConfig
-
-class TestCertGeneration(TestCase):
-  def setUp(self):
-    self.tmpdir = tempfile.mkdtemp()
-    config = ConfigParser.RawConfigParser()
-    config.add_section('server')
-    config.set('server', 'hostname', 'example.com')
-    config.set('server', 'url_port', '777')
-    config.add_section('security')
-    config.set('security', 'keysdir', self.tmpdir)
-    config.set('security', 'server_crt', 'ca.crt')
-    self.certMan = CertificateManager(config)
-    
-  def test_generation(self):
-    self.certMan.genAgentCrtReq()
-    self.assertTrue(os.path.exists(self.certMan.getAgentKeyName()))
-    self.assertTrue(os.path.exists(self.certMan.getAgentCrtReqName()))
-  def tearDown(self):
-    shutil.rmtree(self.tmpdir)
-    
-

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestCheckWebUI.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestCheckWebUI.py b/ambari-agent/src/test/python/TestCheckWebUI.py
deleted file mode 100644
index c7d4ac4..0000000
--- a/ambari-agent/src/test/python/TestCheckWebUI.py
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/env python2.6
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-
-import unittest
-import StringIO
-import sys
-
-from mock.mock import MagicMock, patch
-
-import checkWebUI
-
-class TestMain(unittest.TestCase):
-
-  def setUp(self):
-    # disable stdout
-    out = StringIO.StringIO()
-    sys.stdout = out
-
-
-  def tearDown(self):
-    # enable stdout
-    sys.stdout = sys.__stdout__
-
-  @patch("optparse.OptionParser.parse_args")
-  @patch('httplib.HTTPConnection')
-  def test_check_web_ui(self, http_mock, parse_args_mock):
-      
-    #Positive scenario
-    options = MagicMock()
-    options.hosts = 'host1,host2'
-    options.port = '10000' 
-    parse_args_mock.return_value = (options, MagicMock)
-    http_conn = http_mock.return_value
-    http_conn.getresponse.return_value = MagicMock(status=200)
-
-    checkWebUI.main()
-
-    self.assertTrue(http_conn.request.called)
-    self.assertTrue(http_conn.getresponse.called)
-    self.assertTrue(http_conn.close.called)
-    
-    #Negative scenario
-    options = MagicMock()
-    options.hosts = 'host1,host2'
-    options.port = '10000'
-    parse_args_mock.return_value = (options, MagicMock)
-    http_conn.getresponse.return_value = MagicMock(status=404)
-
-    try:
-      checkWebUI.main()
-    except SystemExit, e:
-      self.assertEqual(e.code, 1)
-
-    self.assertTrue(http_conn.request.called)
-    self.assertTrue(http_conn.getresponse.called)
-    self.assertTrue(http_conn.close.called)
-
-if __name__ == "__main__":
-  unittest.main()

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestCommandStatusDict.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestCommandStatusDict.py b/ambari-agent/src/test/python/TestCommandStatusDict.py
deleted file mode 100644
index 07182ad..0000000
--- a/ambari-agent/src/test/python/TestCommandStatusDict.py
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/usr/bin/env python2.6
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-import tempfile
-from unittest import TestCase
-from ambari_agent.CommandStatusDict import CommandStatusDict
-import os
-import logging
-import json, pprint
-from mock.mock import patch, MagicMock, call
-
-class TestCommandStatusDict(TestCase):
-
-  logger = logging.getLogger()
-
-  def test_put_and_generate(self):
-    callback_mock = MagicMock()
-    commandStatuses = CommandStatusDict(callback_action = callback_mock)
-    command_in_progress1 = {
-      'commandType': 'EXECUTION_COMMAND',
-      'commandId': '1-1',
-      'clusterName': u'cc',
-      'exitCode': 777,
-      'role': u'DATANODE',
-      'roleCommand': u'INSTALL',
-      'serviceName': u'HDFS',
-      'stderr': '',
-      'stdout': "notice: /Stage[1]/Hdp::Iptables/Service[iptables]/ensure: ensure changed 'running' to 'stopped'\nnotice: /Stage[1]/Hdp/File[/tmp/changeUid.sh]/ensure: defined content as '{md5}32b994a2e970f8acc3c91c198b484654'\nnotice: /Stage[1]/Hdp::Snappy::Package/Hdp::Package[snappy]/Hdp::Package::Process_pkg[snappy]/Package[snappy]/ensure: created\nnotice: /Stage[1]/Hdp/Hdp::Group[nagios_group]/Group[nagios_group]/ensure: created\nnotice: /Stage[1]/Hdp/Hdp::User[nagios_user]/User[nagios]/ensure: created\nnotice: /Stage[1]/Hdp::Snmp/Hdp::Package[snmp]/Hdp::Package::Process_pkg[snmp]/Package[net-snmp-utils]/ensure: created",
-      'taskId': 5
-    }
-    command_in_progress1_report = {
-      'status': 'IN_PROGRESS',
-      'taskId': 5
-    }
-    command_in_progress2 = {
-      'commandType': 'EXECUTION_COMMAND',
-      'commandId': '1-1',
-      'role': u'DATANODE',
-      'roleCommand': u'INSTALL',
-      'taskId': 6,
-      'clusterName': u'cc',
-      'serviceName': u'HDFS',
-    }
-    command_in_progress2_report = {
-      'status': 'IN_PROGRESS',
-      'taskId': 6
-    }
-    finished_command = {
-      'commandType': 'EXECUTION_COMMAND',
-      'role': u'DATANODE',
-      'roleCommand': u'INSTALL',
-      'commandId': '1-1',
-      'taskId': 4,
-      'clusterName': u'cc',
-      'serviceName': u'HDFS',
-    }
-    finished_command_report = {
-      'status': 'COMPLETE',
-      'taskId': 4,
-    }
-    failed_command = {
-      'commandType': 'EXECUTION_COMMAND',
-      'role': u'DATANODE',
-      'roleCommand': u'INSTALL',
-      'commandId': '1-1',
-      'taskId': 3,
-      'clusterName': u'cc',
-      'serviceName': u'HDFS',
-    }
-    failed_command_report = {
-      'status': 'FAILED',
-      'taskId': 3,
-    }
-    status_command = {
-      'componentName': 'DATANODE',
-      'commandType': 'STATUS_COMMAND',
-    }
-    status_command_report = {
-      'componentName': 'DATANODE',
-      'status': 'HEALTHY'
-    }
-    commandStatuses.put_command_status(command_in_progress1, command_in_progress1_report)
-    commandStatuses.put_command_status(command_in_progress2, command_in_progress2_report)
-    commandStatuses.put_command_status(finished_command, finished_command_report)
-    commandStatuses.put_command_status(failed_command, failed_command_report)
-    commandStatuses.put_command_status(status_command, status_command_report)
-    report = commandStatuses.generate_report()
-    expected = \
-      {'componentStatus': [{'status': 'HEALTHY', 'componentName': 'DATANODE'}],
-       'reports': [{'status': 'FAILED', 'taskId': 3},
-                   {'status': 'COMPLETE', 'taskId': 4},
-                   {'status': 'IN_PROGRESS', 'stderr': '...',
-                    'stdout': '...', 'clusterName': u'cc',
-                    'roleCommand': u'INSTALL', 'serviceName': u'HDFS',
-                    'role': u'DATANODE', 'actionId': '1-1', 'taskId': 5,
-                    'exitCode': 777},
-                   {'status': 'IN_PROGRESS',
-                    'stderr': '...',
-                    'stdout': '...',
-                    'clusterName': u'cc',
-                    'roleCommand': u'INSTALL',
-                    'serviceName': u'HDFS',
-                    'role': u'DATANODE',
-                    'actionId': '1-1',
-                    'taskId': 6,
-                    'exitCode': 777}]
-      }
-    self.assertEquals(report, expected)
-

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestController.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestController.py b/ambari-agent/src/test/python/TestController.py
deleted file mode 100644
index 87e00fe..0000000
--- a/ambari-agent/src/test/python/TestController.py
+++ /dev/null
@@ -1,408 +0,0 @@
-#!/usr/bin/env python2.6
-# -*- coding: utf-8 -*-
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-
-import StringIO
-import ssl
-import unittest, threading
-from ambari_agent import Controller, ActionQueue
-from ambari_agent import hostname
-import sys
-from ambari_agent.Controller import AGENT_AUTO_RESTART_EXIT_CODE
-from mock.mock import patch, MagicMock, call, Mock
-import logging
-from threading import Event
-
-class TestController(unittest.TestCase):
-
-  logger = logging.getLogger()
-
-  @patch("threading.Thread")
-  @patch("threading.Lock")
-  @patch.object(Controller, "NetUtil")
-  @patch.object(hostname, "hostname")
-  def setUp(self, hostname_method, NetUtil_mock, lockMock, threadMock):
-
-    Controller.logger = MagicMock()
-    lockMock.return_value = MagicMock()
-    NetUtil_mock.return_value = MagicMock()
-    hostname_method.return_value = "test_hostname"
-
-
-    config = MagicMock()
-    config.get.return_value = "something"
-
-    self.controller = Controller.Controller(config)
-    self.controller.netutil.MINIMUM_INTERVAL_BETWEEN_HEARTBEATS = 0.1
-    self.controller.netutil.HEARTBEAT_NOT_IDDLE_INTERVAL_SEC = 0.1
-
-
-  @patch("json.dumps")
-  @patch("time.sleep")
-  @patch("pprint.pformat")
-  @patch.object(Controller, "randint")
-  def test_registerWithServer(self, randintMock, pformatMock, sleepMock,
-                              dumpsMock):
-
-    out = StringIO.StringIO()
-    sys.stdout = out
-
-    register = MagicMock()
-    self.controller.register = register
-
-    self.controller.sendRequest = MagicMock()
-
-    dumpsMock.return_value = "request"
-    self.controller.sendRequest.return_value = '{"log":"Error text", "exitstatus":"1"}'
-
-    self.assertEqual({u'exitstatus': u'1', u'log': u'Error text'}, self.controller.registerWithServer())
-
-    self.controller.sendRequest.return_value = '{"responseId":1}'
-    self.assertEqual({"responseId":1}, self.controller.registerWithServer())
-
-    self.controller.sendRequest.return_value = '{"responseId":1, "statusCommands": "commands", "log":"", "exitstatus":"0"}'
-    self.controller.addToQueue = MagicMock(name="addToQueue")
-    self.controller.isRegistered = False
-    self.assertEqual({'exitstatus': '0', 'responseId': 1, 'log': '', 'statusCommands': 'commands'}, self.controller.registerWithServer())
-    self.controller.addToQueue.assert_called_with("commands")
-
-    calls = []
-
-    def side_effect(*args):
-      if len(calls) == 0:
-        calls.append(1)
-        raise Exception("test")
-      return "request"
-
-    self.controller.sendRequest.return_value = '{"responseId":1}'
-
-    dumpsMock.side_effect = side_effect
-    self.controller.isRegistered = False
-    self.assertEqual({"responseId":1}, self.controller.registerWithServer())
-    self.assertTrue(randintMock.called)
-    self.assertTrue(sleepMock.called)
-
-    sys.stdout = sys.__stdout__
-
-    self.controller.sendRequest = Controller.Controller.sendRequest
-    self.controller.addToQueue = Controller.Controller.addToQueue
-
-
-  @patch("pprint.pformat")
-  def test_addToQueue(self, pformatMock):
-
-    actionQueue = MagicMock()
-    self.controller.actionQueue = actionQueue
-    self.controller.addToQueue(None)
-    self.assertFalse(actionQueue.put.called)
-    self.controller.addToQueue("cmd")
-    self.assertTrue(actionQueue.put.called)
-
-
-  @patch("urllib2.build_opener")
-  @patch("urllib2.install_opener")
-  @patch.object(Controller, "ActionQueue")
-  def test_run(self, ActionQueue_mock, installMock, buildMock):
-    aq = MagicMock()
-    ActionQueue_mock.return_value = aq
-
-    buildMock.return_value = "opener"
-    registerAndHeartbeat  = MagicMock("registerAndHeartbeat")
-    calls = []
-    def side_effect():
-      if len(calls) == 0:
-        self.controller.repeatRegistration = True
-      calls.append(1)
-    registerAndHeartbeat.side_effect = side_effect
-    self.controller.registerAndHeartbeat = registerAndHeartbeat
-
-    # repeat registration
-    self.controller.run()
-
-    self.assertTrue(buildMock.called)
-    installMock.called_once_with("opener")
-    self.assertEqual(2, registerAndHeartbeat.call_count)
-
-    # one call, +1
-    registerAndHeartbeat.side_effect = None
-    self.controller.run()
-    self.assertEqual(3, registerAndHeartbeat.call_count)
-
-    # Action queue should be started during calls
-    self.assertTrue(ActionQueue_mock.called)
-    self.assertTrue(aq.start.called)
-
-
-  @patch("urllib2.build_opener")
-  @patch("urllib2.install_opener")
-  @patch.object(ActionQueue.ActionQueue, "run")
-  def test_repeatRegistration(self,
-                              run_mock, installMock, buildMock):
-
-    registerAndHeartbeat = MagicMock(name="registerAndHeartbeat")
-
-    self.controller.registerAndHeartbeat = registerAndHeartbeat
-    self.controller.run()
-    self.assertTrue(installMock.called)
-    self.assertTrue(buildMock.called)
-    self.controller.registerAndHeartbeat.assert_called_once_with()
-
-    calls = []
-    def switchBool():
-      if len(calls) == 0:
-        self.controller.repeatRegistration = True
-        calls.append(1)
-      self.controller.repeatRegistration = False
-
-    registerAndHeartbeat.side_effect = switchBool
-    self.controller.run()
-    self.assertEqual(2, registerAndHeartbeat.call_count)
-
-    self.controller.registerAndHeartbeat = \
-      Controller.Controller.registerAndHeartbeat
-
-
-  @patch("time.sleep")
-  def test_registerAndHeartbeatWithException(self, sleepMock):
-
-    registerWithServer = MagicMock(name="registerWithServer")
-    registerWithServer.return_value = {"response":"resp"}
-    self.controller.registerWithServer = registerWithServer
-    heartbeatWithServer = MagicMock(name="heartbeatWithServer")
-    self.controller.heartbeatWithServer = heartbeatWithServer
-
-    Controller.Controller.__sendRequest__ = MagicMock(side_effect=Exception())
-
-    self.controller.isRegistered = True
-    self.controller.registerAndHeartbeat()
-    registerWithServer.assert_called_once_with()
-    heartbeatWithServer.assert_called_once_with()
-
-    self.controller.registerWithServer =\
-    Controller.Controller.registerWithServer
-    self.controller.heartbeatWithServer =\
-    Controller.Controller.registerWithServer
-
-  @patch("time.sleep")
-  def test_registerAndHeartbeat(self, sleepMock):
-
-    registerWithServer = MagicMock(name="registerWithServer")
-    registerWithServer.return_value = {"response":"resp"}
-    self.controller.registerWithServer = registerWithServer
-    heartbeatWithServer = MagicMock(name="heartbeatWithServer")
-    self.controller.heartbeatWithServer = heartbeatWithServer
-
-    self.controller.isRegistered = True;
-    self.controller.registerAndHeartbeat()
-    registerWithServer.assert_called_once_with()
-    heartbeatWithServer.assert_called_once_with()
-
-    self.controller.registerWithServer = \
-      Controller.Controller.registerWithServer
-    self.controller.heartbeatWithServer = \
-      Controller.Controller.registerWithServer
-
-
-  @patch("os._exit")
-  def test_restartAgent(self, os_exit_mock):
-
-    self.controller.restartAgent()
-    self.assertTrue(os_exit_mock.called)
-    self.assertTrue(os_exit_mock.call_args[0][0] == AGENT_AUTO_RESTART_EXIT_CODE)
-
-
-  @patch("urllib2.Request")
-  @patch.object(Controller, "security")
-  def test_sendRequest(self, security_mock, requestMock):
-
-    conMock = MagicMock()
-    conMock.request.return_value = "response"
-    security_mock.CachedHTTPSConnection.return_value = conMock
-    url = "url"
-    data = "data"
-    requestMock.return_value = "request"
-
-    self.controller.cachedconnect = None
-
-    self.assertEqual("response", self.controller.sendRequest(url, data))
-    security_mock.CachedHTTPSConnection.assert_called_once_with(
-      self.controller.config)
-    requestMock.called_once_with(url, data,
-      {'Content-Type': 'application/json'})
-
-
-  @patch.object(threading._Event, "wait")
-  @patch("time.sleep")
-  @patch("json.loads")
-  @patch("json.dumps")
-  def test_heartbeatWithServer(self, dumpsMock, loadsMock, sleepMock, event_mock):
-
-    out = StringIO.StringIO()
-    sys.stdout = out
-
-    hearbeat = MagicMock()
-    self.controller.heartbeat = hearbeat
-
-    dumpsMock.return_value = "data"
-
-    sendRequest = MagicMock(name="sendRequest")
-    self.controller.sendRequest = sendRequest
-
-    self.controller.responseId = 1
-    response = {"responseId":"2", "restartAgent":"false"}
-    loadsMock.return_value = response
-
-    def one_heartbeat(*args, **kwargs):
-      self.controller.DEBUG_STOP_HEARTBEATING = True
-      return "data"
-
-    sendRequest.side_effect = one_heartbeat
-
-    actionQueue = MagicMock()
-    actionQueue.isIdle.return_value = True
-
-    # one successful request, after stop
-    self.controller.actionQueue = actionQueue
-    self.controller.heartbeatWithServer()
-    self.assertTrue(sendRequest.called)
-
-    calls = []
-    def retry(*args, **kwargs):
-      if len(calls) == 0:
-        calls.append(1)
-        response["responseId"] = "3"
-        raise Exception()
-      if len(calls) > 0:
-        self.controller.DEBUG_STOP_HEARTBEATING = True
-      return "data"
-
-    # exception, retry, successful and stop
-    sendRequest.side_effect = retry
-    self.controller.DEBUG_STOP_HEARTBEATING = False
-    self.controller.heartbeatWithServer()
-
-    self.assertEqual(1, self.controller.DEBUG_SUCCESSFULL_HEARTBEATS)
-
-    # retry registration
-    response["registrationCommand"] = "true"
-    sendRequest.side_effect = one_heartbeat
-    self.controller.DEBUG_STOP_HEARTBEATING = False
-    self.controller.heartbeatWithServer()
-
-    self.assertTrue(self.controller.repeatRegistration)
-
-    # components are not mapped
-    response["registrationCommand"] = "false"
-    response["hasMappedComponents"] = False
-    sendRequest.side_effect = one_heartbeat
-    self.controller.DEBUG_STOP_HEARTBEATING = False
-    self.controller.heartbeatWithServer()
-
-    self.assertFalse(self.controller.hasMappedComponents)
-
-    # components are mapped
-    response["hasMappedComponents"] = True
-    sendRequest.side_effect = one_heartbeat
-    self.controller.DEBUG_STOP_HEARTBEATING = False
-    self.controller.heartbeatWithServer()
-
-    self.assertTrue(self.controller.hasMappedComponents)
-
-    # components are mapped
-    del response["hasMappedComponents"]
-    sendRequest.side_effect = one_heartbeat
-    self.controller.DEBUG_STOP_HEARTBEATING = False
-    self.controller.heartbeatWithServer()
-
-    self.assertTrue(self.controller.hasMappedComponents)
-
-    # wrong responseId => restart
-    response = {"responseId":"2", "restartAgent":"false"}
-    loadsMock.return_value = response
-
-    restartAgent = MagicMock(name="restartAgent")
-    self.controller.restartAgent = restartAgent
-    self.controller.DEBUG_STOP_HEARTBEATING = False
-    self.controller.heartbeatWithServer()
-
-    restartAgent.assert_called_once_with()
-
-    # executionCommands, statusCommands
-    self.controller.responseId = 1
-    addToQueue = MagicMock(name="addToQueue")
-    self.controller.addToQueue = addToQueue
-    response["executionCommands"] = "executionCommands"
-    response["statusCommands"] = "statusCommands"
-    self.controller.DEBUG_STOP_HEARTBEATING = False
-    self.controller.heartbeatWithServer()
-
-    addToQueue.assert_has_calls([call("executionCommands"),
-                                 call("statusCommands")])
-
-    # restartAgent command
-    self.controller.responseId = 1
-    self.controller.DEBUG_STOP_HEARTBEATING = False
-    response["restartAgent"] = "true"
-    restartAgent = MagicMock(name="restartAgent")
-    self.controller.restartAgent = restartAgent
-    self.controller.heartbeatWithServer()
-
-    restartAgent.assert_called_once_with()
-
-    # actionQueue not idle
-    self.controller.responseId = 1
-    self.controller.DEBUG_STOP_HEARTBEATING = False
-    actionQueue.isIdle.return_value = False
-    response["restartAgent"] = "false"
-    self.controller.heartbeatWithServer()
-
-    sleepMock.assert_called_with(
-      self.controller.netutil.MINIMUM_INTERVAL_BETWEEN_HEARTBEATS)
-
-    sys.stdout = sys.__stdout__
-    self.controller.sendRequest = Controller.Controller.sendRequest
-    self.controller.sendRequest = Controller.Controller.addToQueue
-
-  @patch("pprint.pformat")
-  @patch("time.sleep")
-  @patch("json.loads")
-  @patch("json.dumps")
-  def test_certSigningFailed(self, dumpsMock, loadsMock, sleepMock, pformatMock):
-    register = MagicMock()
-    self.controller.register = register
-
-    dumpsMock.return_value = "request"
-    response = {"responseId":1,}
-    loadsMock.return_value = response
-
-    self.controller.sendRequest = Mock(side_effect=ssl.SSLError())
-
-    self.controller.repeatRegistration=True
-    self.controller.registerWithServer()
-
-    #Conroller thread and the agent stop if the repeatRegistration flag is False
-    self.assertFalse(self.controller.repeatRegistration)
-
-if __name__ == "__main__":
-  unittest.main(verbosity=2)
-
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestCustomServiceOrchestrator.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestCustomServiceOrchestrator.py b/ambari-agent/src/test/python/TestCustomServiceOrchestrator.py
deleted file mode 100644
index b9aab2a..0000000
--- a/ambari-agent/src/test/python/TestCustomServiceOrchestrator.py
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/usr/bin/env python2.6
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-import ConfigParser
-import os
-
-import pprint
-
-from unittest import TestCase
-import threading
-import tempfile
-import time
-from threading import Thread
-
-from PythonExecutor import PythonExecutor
-from CustomServiceOrchestrator import CustomServiceOrchestrator
-from AmbariConfig import AmbariConfig
-from mock.mock import MagicMock, patch
-import StringIO
-import sys
-from AgentException import AgentException
-from FileCache import FileCache
-
-
-class TestCustomServiceOrchestrator(TestCase):
-
-  def setUp(self):
-    # disable stdout
-    out = StringIO.StringIO()
-    sys.stdout = out
-    # generate sample config
-    tmpdir = tempfile.gettempdir()
-    self.config = ConfigParser.RawConfigParser()
-    self.config.add_section('agent')
-    self.config.set('agent', 'prefix', tmpdir)
-    self.config.set('agent', 'cache_dir', "/cachedir")
-
-
-  def test_dump_command_to_json(self):
-    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' }}
-    }
-    config = AmbariConfig().getConfig()
-    tempdir = tempfile.gettempdir()
-    config.set('agent', 'prefix', tempdir)
-    orchestrator = CustomServiceOrchestrator(config)
-    file = orchestrator.dump_command_to_json(command)
-    self.assertTrue(os.path.exists(file))
-    self.assertTrue(os.path.getsize(file) > 0)
-    self.assertEqual(oct(os.stat(file).st_mode & 0777), '0600')
-    os.unlink(file)
-
-
-  @patch("os.path.exists")
-  def test_resolve_script_path(self, exists_mock):
-    config = AmbariConfig().getConfig()
-    orchestrator = CustomServiceOrchestrator(config)
-    # Testing existing path
-    exists_mock.return_value = True
-    path = orchestrator.\
-      resolve_script_path("/HBASE", "scripts/hbase_master.py", "PYTHON")
-    self.assertEqual("/HBASE/package/scripts/hbase_master.py", path)
-    # Testing not existing path
-    exists_mock.return_value = False
-    try:
-      orchestrator.resolve_script_path("/HBASE",
-                                       "scripts/hbase_master.py", "PYTHON")
-      self.fail('ExpectedException not thrown')
-    except AgentException:
-      pass # Expected
-
-
-  @patch.object(CustomServiceOrchestrator, "resolve_script_path")
-  @patch.object(FileCache, "get_service_base_dir")
-  @patch.object(CustomServiceOrchestrator, "dump_command_to_json")
-  @patch.object(PythonExecutor, "run_file")
-  def test_runCommand(self, run_file_mock, dump_command_to_json_mock,
-                      get_service_base_dir_mock, resolve_script_path_mock):
-    command = {
-      'role' : 'REGION_SERVER',
-      'hostLevelParams' : {
-        'stack_name' : 'HDP',
-        'stack_version' : '2.0.7',
-      },
-      'commandParams': {
-        'script_type': 'PYTHON',
-        'script': 'scripts/hbase_regionserver.py',
-        'command_timeout': '600',
-        'service_metadata_folder' : 'HBASE'
-      },
-      'roleCommand': 'INSTALL'
-    }
-    get_service_base_dir_mock.return_value = "/basedir/"
-    resolve_script_path_mock.return_value = "/basedir/scriptpath"
-    orchestrator = CustomServiceOrchestrator(self.config)
-    # normal run case
-    run_file_mock.return_value = {
-        'stdout' : 'sss',
-        'stderr' : 'eee',
-        'exitcode': 0,
-      }
-    ret = orchestrator.runCommand(command, "out.txt", "err.txt")
-    self.assertEqual(ret['exitcode'], 0)
-    self.assertTrue(run_file_mock.called)
-
-    run_file_mock.reset_mock()
-    # unknown script type case
-    command['commandParams']['script_type'] = "PUPPET"
-    ret = orchestrator.runCommand(command, "out.txt", "err.txt")
-    self.assertEqual(ret['exitcode'], 1)
-    self.assertFalse(run_file_mock.called)
-    self.assertTrue("Unknown script type" in ret['stdout'])
-    pass
-
-
-  def tearDown(self):
-    # enable stdout
-    sys.stdout = sys.__stdout__
-
-

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestDataCleaner.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestDataCleaner.py b/ambari-agent/src/test/python/TestDataCleaner.py
deleted file mode 100644
index 2f2a8bc..0000000
--- a/ambari-agent/src/test/python/TestDataCleaner.py
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env python2.6
-# -*- coding: utf-8 -*-
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-
-import unittest
-from mock.mock import patch, MagicMock, call, Mock
-from ambari_agent import DataCleaner
-
-
-class TestDataCleaner(unittest.TestCase):
-
-  def setUp(self):
-    self.test_dir = [('/test_path', [],
-                      ['errors-12.txt','output-12.txt','site-12.pp','site-13.pp','site-15.pp','version'])]
-    self.config = MagicMock()
-    self.config.get.side_effect = [2592000,3600 + 1,"/test_path"]
-    DataCleaner.logger = MagicMock()
-
-  def test_init_success(self):
-    config = MagicMock()
-    config.get.return_value = 2592000
-    DataCleaner.logger.reset_mock()
-    cleaner = DataCleaner.DataCleaner(config)
-    self.assertFalse(DataCleaner.logger.warn.called)
-
-
-  def test_init_warn(self):
-    config = MagicMock()
-    config.get.return_value = 10
-    DataCleaner.logger.reset_mock()
-    cleaner = DataCleaner.DataCleaner(config)
-    self.assertTrue(DataCleaner.logger.warn.called)
-    self.assertTrue(cleaner.file_max_age == 3600)
-
-  @patch('os.walk')
-  @patch('time.time')
-  @patch('os.path.getmtime')
-  @patch('os.remove')
-  def test_cleanup_success(self,remMock,mtimeMock,timeMock,walkMock):
-    self.config.reset_mock()
-    DataCleaner.logger.reset_mock()
-
-    walkMock.return_value = iter(self.test_dir)
-    timeMock.return_value = 2592000 + 2
-    mtimeMock.side_effect = [1,1,1,2,1,1]
-
-    cleaner = DataCleaner.DataCleaner(self.config)
-    cleaner.cleanup()
-
-    self.assertTrue(len(remMock.call_args_list) == 4)
-    remMock.assert_any_call('/test_path/errors-12.txt');
-    remMock.assert_any_call('/test_path/output-12.txt');
-    remMock.assert_any_call('/test_path/site-12.pp');
-    remMock.assert_any_call('/test_path/site-15.pp');
-    pass
-
-  @patch('os.walk')
-  @patch('time.time')
-  @patch('os.path.getmtime')
-  @patch('os.remove')
-  def test_cleanup_remove_error(self,remMock,mtimeMock,timeMock,walkMock):
-    self.config.reset_mock()
-    DataCleaner.logger.reset_mock()
-
-    walkMock.return_value = iter(self.test_dir)
-    timeMock.return_value = 2592000 + 2
-    mtimeMock.side_effect = [1,1,1,2,1,1]
-
-    def side_effect(arg):
-      if arg == '/test_path/site-15.pp':
-        raise Exception("Can't remove file")
-
-    remMock.side_effect = side_effect
-
-    cleaner = DataCleaner.DataCleaner(self.config)
-    cleaner.cleanup()
-
-    self.assertTrue(len(remMock.call_args_list) == 4)
-    self.assertTrue(DataCleaner.logger.error.call_count == 1)
-    pass
-
-if __name__ == "__main__":
-  suite = unittest.TestLoader().loadTestsFromTestCase(TestDataCleaner)
-  unittest.TextTestRunner(verbosity=2).run(suite)

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestFileCache.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestFileCache.py b/ambari-agent/src/test/python/TestFileCache.py
deleted file mode 100644
index 8426012..0000000
--- a/ambari-agent/src/test/python/TestFileCache.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env python2.6
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-import ConfigParser
-import os
-
-import pprint
-
-from unittest import TestCase
-import threading
-import tempfile
-import time
-from threading import Thread
-
-from PythonExecutor import PythonExecutor
-from CustomServiceOrchestrator import CustomServiceOrchestrator
-from FileCache import FileCache
-from AmbariConfig import AmbariConfig
-from mock.mock import MagicMock, patch
-import StringIO
-import sys
-from ambari_agent import AgentException
-
-
-class TestFileCache(TestCase):
-
-  def setUp(self):
-    # disable stdout
-    out = StringIO.StringIO()
-    sys.stdout = out
-    # generate sample config
-    tmpdir = tempfile.gettempdir()
-    self.config = ConfigParser.RawConfigParser()
-    self.config.add_section('agent')
-    self.config.set('agent', 'prefix', tmpdir)
-    self.config.set('agent', 'cache_dir', "/var/lib/ambari-agent/cache")
-
-
-  @patch("os.path.isdir")
-  def test_get_service_base_dir(self, isdir_mock):
-    fileCache = FileCache(self.config)
-    isdir_mock.return_value = True
-    base = fileCache.get_service_base_dir("HDP", "2.0.7",
-                                          "HBASE", "REGION_SERVER")
-    self.assertEqual(base, "/var/lib/ambari-agent/cache/stacks/HDP/2.0.7/services/HBASE")
-
-
-  def tearDown(self):
-    # enable stdout
-    sys.stdout = sys.__stdout__
-
-

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestGrep.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestGrep.py b/ambari-agent/src/test/python/TestGrep.py
deleted file mode 100644
index 5163312..0000000
--- a/ambari-agent/src/test/python/TestGrep.py
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/env python2.6
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-
-from unittest import TestCase
-from ambari_agent.Grep import Grep
-import socket
-import os, sys
-import logging
-
-class TestGrep(TestCase):
-
-  logger = logging.getLogger()
-  string_good = None
-  string_bad = None
-  grep = Grep()
-
-  def setUp(self):
-    self.string_good = open('dummy_puppet_output_good.txt', 'r').read().replace("\n", os.linesep)
-    self.string_bad = open('dummy_puppet_output_error.txt', 'r').read().replace("\n", os.linesep)
-    pass
-
-  def test_grep_many_lines(self):
-    fragment = self.grep.grep(self.string_bad, "err", 1000, 1000)
-    desired = self.string_bad.strip()
-    self.assertEquals(fragment, desired, "Grep grep function should return all lines if there are less lines than n")
-
-
-  def test_grep_few_lines(self):
-    fragment = self.grep.grep(self.string_bad, "Err", 3, 3)
-    desired = """
-debug: /Schedule[never]: Skipping device resources because running on a host
-debug: Exec[command_good](provider=posix): Executing 'wget e432423423xample.com/badurl444111'
-debug: Executing 'wget e432423423xample.com/badurl444111'
-err: /Stage[main]//Exec[command_good]/returns: change from notrun to 0 failed: wget e432423423xample.com/badurl444111 returned 4 instead of one of [0] at /root/puppet-learn/2-bad.pp:5
-debug: /Schedule[weekly]: Skipping device resources because running on a host
-debug: /Schedule[puppet]: Skipping device resources because running on a host
-debug: Finishing transaction 70171639726240
-""".strip()
-    self.assertEquals(fragment, desired, "Grep grep function should return only last 3 lines of file")
-
-  def test_grep_no_result(self):
-    fragment = self.grep.grep(self.string_good, "Err", 3, 3)
-    desired = None
-    self.assertEquals(fragment, desired, 'Grep grep function should return None if result is not found')
-
-  def test_grep_empty_string(self):
-    fragment = self.grep.grep("", "Err", 1000, 1000)
-    desired = None
-    self.assertEquals(fragment, desired, 'Grep grep function should return None for empty string')
-
-  def test_grep_all(self):
-    fragment = self.grep.grep(self.string_bad, "Err", 35, 9)
-    desired = self.string_bad.strip()
-    self.assertEquals(fragment, desired, 'Grep grep function contains bug in index arithmetics')
-
-
-  def test_tail_many_lines(self):
-    fragment = self.grep.tail(self.string_good, 1000)
-    desired = self.string_good.strip()
-    self.assertEquals(fragment, desired, "Grep tail function should return all lines if there are less lines than n")
-
-  def test_tail_few_lines(self):
-    fragment = self.grep.tail(self.string_good, 3)
-    desired = """
-debug: Finishing transaction 70060456663980
-debug: Received report to process from ambari-dmi
-debug: Processing report from ambari-dmi with processor Puppet::Reports::Store
-""".strip()
-    self.assertEquals(fragment, desired, "Grep tail function should return only last 3 lines of file")
-
-  def test_tail_no_lines(self):
-    fragment = self.grep.tail("", 3)
-    desired = ''
-    self.assertEquals(fragment, desired, 'Grep tail function should return "" for empty string')
-
-  def test_tail_all(self):
-    fragment = self.grep.tail("", 47)
-    desired = ''
-    self.assertEquals(fragment, desired, 'Grep tail function contains bug in index arithmetics')
-
-  def test_filterMarkup(self):
-    string = """notice: /Stage[main]/Hdp-hadoop/Hdp-hadoop::Package[hadoop]/Hdp::Package[hadoop 64]/Hdp::Package::Process_pkg[hadoop 64]/Package[hadoop-libhdfs]/ensure: created"""
-    desired="""notice: /Stage[main]/Hdp-hadoop/Hdp-hadoop::Package[hadoop]/Hdp::Package[hadoop 64]/Hdp::Package::Process_pkg[hadoop 64]/Package[hadoop-libhdfs]/ensure: created"""
-    filtered = self.grep.filterMarkup(string)
-    #sys.stderr.write(filtered)
-    self.assertEquals(filtered, desired)
-
-  def tearDown(self):
-    pass
-
-  def test_cleanByTemplate(self):
-    fragment = self.grep.cleanByTemplate(self.string_bad, "debug")
-    desired = """
-info: Applying configuration version '1352127563'
-err: /Stage[main]//Exec[command_good]/returns: change from notrun to 0 failed: wget e432423423xample.com/badurl444111 returned 4 instead of one of [0] at /root/puppet-learn/2-bad.pp:5
-notice: Finished catalog run in 0.23 seconds
-""".strip()
-    self.assertEquals(fragment, desired, 'Grep cleanByTemplate function should return string without debug lines.')
-
-

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestHardware.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestHardware.py b/ambari-agent/src/test/python/TestHardware.py
deleted file mode 100644
index 18b10d6..0000000
--- a/ambari-agent/src/test/python/TestHardware.py
+++ /dev/null
@@ -1,168 +0,0 @@
-#!/usr/bin/env python2.6
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-
-import subprocess, os
-import tempfile
-from unittest import TestCase
-from ambari_agent.Hardware import Hardware
-from mock.mock import MagicMock, patch, ANY
-import mock.mock
-from AmbariConfig import AmbariConfig
-
-class TestHardware(TestCase):
-  def test_build(self):
-    hardware = Hardware(AmbariConfig().getConfig())
-    result = hardware.get()
-    osdisks = hardware.osdisks()
-    for dev_item in result['mounts']:
-      self.assertTrue(dev_item['available'] >= 0)
-      self.assertTrue(dev_item['used'] >= 0)
-      self.assertTrue(dev_item['percent'] != None)
-      self.assertTrue(dev_item['device'] != None)
-      self.assertTrue(dev_item['mountpoint'] != None)
-      self.assertTrue(dev_item['type'] != None)
-      self.assertTrue(dev_item['size'] > 0)
-
-    for os_disk_item in osdisks:
-      self.assertTrue(os_disk_item['available'] >= 0)
-      self.assertTrue(os_disk_item['used'] >= 0)
-      self.assertTrue(os_disk_item['percent'] != None)
-      self.assertTrue(os_disk_item['device'] != None)
-      self.assertTrue(os_disk_item['mountpoint'] != None)
-      self.assertTrue(os_disk_item['type'] != None)
-      self.assertTrue(os_disk_item['size'] > 0)
-
-    self.assertTrue(len(result['mounts']) == len(osdisks))
-
-
-  @patch.object(subprocess, "Popen")
-  @patch.object(Hardware, "facterLib")
-  @patch("os.path.exists")
-  def test_facterInfo(self, os_path_exists_mock, hardware_facterLib_mock, subprocess_popen_mock):
-    config = AmbariConfig().getConfig()
-    tmp_dir = tempfile.gettempdir()
-    config.set("puppet", "facter_home", tmp_dir)
-    hardware = Hardware(config)
-    facter = MagicMock()
-    facter.communicate.return_value = ["memoryfree => 1 GB\n memorysize => 25 MB\n memorytotal => 300 KB\n "
-                                        + "physicalprocessorcount => 25\n is_virtual => true\n", "no errors"]
-    facter.returncode = 0
-    os.environ['RUBYLIB'] = tmp_dir;
-    subprocess_popen_mock.return_value = facter
-    os_path_exists_mock.return_value = True
-    hardware_facterLib_mock.return_value = "bla bla bla"
-    facterInfo = hardware.facterInfo()
-
-    self.assertEquals(facterInfo['memoryfree'], 1048576L)
-    self.assertEquals(facterInfo['memorysize'], 25600L)
-    self.assertEquals(facterInfo['memorytotal'], 300L)
-    self.assertEquals(facterInfo['physicalprocessorcount'], 25)
-    self.assertTrue(facterInfo['is_virtual'])
-    self.assertEquals(subprocess_popen_mock.call_args[1]['env']['RUBYLIB'],
-                      tmp_dir + ":" + "bla bla bla")
-
-    facter.communicate.return_value = ["memoryfree => 1 G\n memorysize => 25 M\n memorytotal => 300 K\n "
-                                         + "someinfo => 12 Byte\n ssh_name_key => Aa06Fdd\n", "no errors"]
-    facterInfo = hardware.facterInfo()
-    facter.returncode = 1
-    self.assertEquals(facterInfo['memoryfree'], 1048576L)
-    self.assertEquals(facterInfo['memorysize'], 25600L)
-    self.assertEquals(facterInfo['memorytotal'], 300L)
-    self.assertEquals(facterInfo['someinfo'], '12 Byte')
-    self.assertFalse(facterInfo.has_key('ssh_name_key'))
-
-    facter.communicate.return_value = ["memoryfree => 1024 M B\n memorytotal => 1024 Byte" , "no errors"]
-
-    facterInfo = hardware.facterInfo()
-
-    self.assertEquals(facterInfo['memoryfree'], 1L)
-    self.assertEquals(facterInfo['memorytotal'], 1L)
-
-    os_path_exists_mock.return_value = False
-    facterInfo = hardware.facterInfo()
-
-    self.assertEquals(facterInfo, {})
-
-
-  @patch("os.path.exists")
-  def test_facterBin(self, ps_path_exists_mock):
-    hardware = Hardware(AmbariConfig().getConfig())
-    ps_path_exists_mock.return_value = False
-    result = hardware.facterBin("bla bla bla")
-    self.assertEquals(result, "facter")
-
-    ps_path_exists_mock.return_value = True
-    result = hardware.facterBin("bla bla bla")
-    self.assertEquals(result, "bla bla bla/bin/facter")
-
-
-  @patch("os.path.exists")
-  @patch.dict('os.environ', {"PATH": ""})
-  @patch.object(subprocess, "Popen")
-  @patch.object(Hardware, "facterInfo")
-  def test_configureEnviron(self, hrdware_facterinfo_mock, subproc_popen, os_path_exists_mock):
-    config = AmbariConfig().getConfig()
-    tmpdir = tempfile.gettempdir()
-    config.set("puppet", "ruby_home", tmpdir)
-    hardware = Hardware(config)
-    os_path_exists_mock.return_value = True
-    result = hardware.configureEnviron({'PATH': ""})
-
-    self.assertEquals(result['PATH'], tmpdir + "/bin:")
-    self.assertEquals(result['MY_RUBY_HOME'], tmpdir)
-    config.remove_option("puppet", "ruby_home")
-
-
-  def test_facterLib(self):
-    hardware = Hardware(AmbariConfig().getConfig())
-    facterLib = hardware.facterLib("/home")
-    self.assertEquals(facterLib, "/home/lib/")
-
-
-  def test_extractMountInfo(self):
-    outputLine = "device type size used available percent mountpoint"
-    result = Hardware.extractMountInfo(outputLine)
-
-    self.assertEquals(result['device'], 'device')
-    self.assertEquals(result['type'], 'type')
-    self.assertEquals(result['size'], 'size')
-    self.assertEquals(result['used'], 'used')
-    self.assertEquals(result['available'], 'available')
-    self.assertEquals(result['percent'], 'percent')
-    self.assertEquals(result['mountpoint'], 'mountpoint')
-
-    outputLine = ""
-    result = Hardware.extractMountInfo(outputLine)
-
-    self.assertEquals(result, None)
-
-    outputLine = "device type size used available percent"
-    result = Hardware.extractMountInfo(outputLine)
-
-    self.assertEquals(result, None)
-
-    outputLine = "device type size used available percent mountpoint info"
-    result = Hardware.extractMountInfo(outputLine)
-
-    self.assertEquals(result, None)
-
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/e5c6e113/ambari-agent/src/test/python/TestHeartbeat.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestHeartbeat.py b/ambari-agent/src/test/python/TestHeartbeat.py
deleted file mode 100644
index 5ef5d72..0000000
--- a/ambari-agent/src/test/python/TestHeartbeat.py
+++ /dev/null
@@ -1,211 +0,0 @@
-#!/usr/bin/env python2.6
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-
-from unittest import TestCase
-import unittest
-from ambari_agent.Heartbeat import Heartbeat
-from ambari_agent.ActionQueue import ActionQueue
-from ambari_agent.LiveStatus import LiveStatus
-from ambari_agent import AmbariConfig
-import socket
-import os
-import time
-from mock.mock import patch, MagicMock, call
-from ambari_agent.StackVersionsFileHandler import StackVersionsFileHandler
-from ambari_agent.HostInfo import HostInfo
-import StringIO
-import sys
-
-class TestHeartbeat(TestCase):
-
-  def setUp(self):
-    # disable stdout
-    out = StringIO.StringIO()
-    sys.stdout = out
-
-
-  def tearDown(self):
-    # enable stdout
-    sys.stdout = sys.__stdout__
-
-
-  def test_build(self):
-    actionQueue = ActionQueue(AmbariConfig.AmbariConfig().getConfig(),'dummy_controller')
-    heartbeat = Heartbeat(actionQueue)
-    result = heartbeat.build(100)
-    print "Heartbeat: " + str(result)
-    self.assertEquals(result['hostname'] != '', True, "hostname should not be empty")
-    self.assertEquals(result['responseId'], 100)
-    self.assertEquals(result['componentStatus'] is not None, True, "Heartbeat should contain componentStatus")
-    self.assertEquals(result['reports'] is not None, True, "Heartbeat should contain reports")
-    self.assertEquals(result['timestamp'] >= 1353679373880L, True)
-    self.assertEquals(len(result['nodeStatus']), 2)
-    self.assertEquals(result['nodeStatus']['cause'], "NONE")
-    self.assertEquals(result['nodeStatus']['status'], "HEALTHY")
-    # result may or may NOT have an agentEnv structure in it
-    self.assertEquals((len(result) is 6) or (len(result) is 7), True)
-    self.assertEquals(not heartbeat.reports, True, "Heartbeat should not contain task in progress")
-
-
-  @patch.object(ActionQueue, "result")
-  @patch.object(HostInfo, "register")
-  def test_no_mapping(self, register_mock, result_mock):
-    result_mock.return_value = {
-      'reports': [{'status': 'IN_PROGRESS',
-                   'stderr': 'Read from /tmp/errors-3.txt',
-                   'stdout': 'Read from /tmp/output-3.txt',
-                   'clusterName': u'cc',
-                   'roleCommand': u'INSTALL',
-                   'serviceName': u'HDFS',
-                   'role': u'DATANODE',
-                   'actionId': '1-1',
-                   'taskId': 3,
-                   'exitCode': 777}],
-      'componentStatus': [{'status': 'HEALTHY', 'componentName': 'NAMENODE'}]
-    }
-    actionQueue = ActionQueue(AmbariConfig.AmbariConfig().getConfig(),'dummy_controller')
-    heartbeat = Heartbeat(actionQueue)
-    hb = heartbeat.build(id = 10, state_interval=1, componentsMapped=True)
-    self.assertEqual(register_mock.call_args_list[0][0][1], True)
-    register_mock.reset_mock()
-
-    hb = heartbeat.build(id = 0, state_interval=1, componentsMapped=True)
-    self.assertEqual(register_mock.call_args_list[0][0][1], False)
-
-
-  @patch.object(ActionQueue, "result")
-  def test_build_long_result(self, result_mock):
-    actionQueue = ActionQueue(AmbariConfig.AmbariConfig().getConfig(),'dummy_controller')
-    result_mock.return_value = {
-      'reports': [{'status': 'IN_PROGRESS',
-            'stderr': 'Read from /tmp/errors-3.txt',
-            'stdout': 'Read from /tmp/output-3.txt',
-            'clusterName': u'cc',
-            'roleCommand': u'INSTALL',
-            'serviceName': u'HDFS',
-            'role': u'DATANODE',
-            'actionId': '1-1',
-            'taskId': 3,
-            'exitCode': 777},
-
-            {'status': 'COMPLETED',
-             'stderr': 'stderr',
-             'stdout': 'out',
-             'clusterName': 'clusterName',
-             'roleCommand': 'UPGRADE',
-             'serviceName': 'serviceName',
-             'role': 'role',
-             'actionId': 17,
-             'taskId': 'taskId',
-             'exitCode': 0},
-
-            {'status': 'FAILED',
-             'stderr': 'stderr',
-             'stdout': 'out',
-             'clusterName': u'cc',
-             'roleCommand': u'INSTALL',
-             'serviceName': u'HDFS',
-             'role': u'DATANODE',
-             'actionId': '1-1',
-             'taskId': 3,
-             'exitCode': 13},
-
-            {'status': 'COMPLETED',
-             'stderr': 'stderr',
-             'stdout': 'out',
-             'clusterName': u'cc',
-             'configurationTags': {'global': {'tag': 'v1'}},
-             'roleCommand': u'INSTALL',
-             'serviceName': u'HDFS',
-             'role': u'DATANODE',
-             'actionId': '1-1',
-             'taskId': 3,
-             'exitCode': 0}
-
-            ],
-      'componentStatus': [
-        {'status': 'HEALTHY', 'componentName': 'DATANODE'},
-        {'status': 'UNHEALTHY', 'componentName': 'NAMENODE'},
-      ],
-    }
-    heartbeat = Heartbeat(actionQueue)
-    hb = heartbeat.build(10)
-    hb['hostname'] = 'hostname'
-    hb['timestamp'] = 'timestamp'
-    expected = {'nodeStatus':
-                  {'status': 'HEALTHY',
-                   'cause': 'NONE'},
-                'timestamp': 'timestamp', 'hostname': 'hostname',
-                'responseId': 10, 'reports': [
-      {'status': 'IN_PROGRESS', 'roleCommand': u'INSTALL',
-       'serviceName': u'HDFS', 'role': u'DATANODE', 'actionId': '1-1',
-       'stderr': 'Read from /tmp/errors-3.txt',
-       'stdout': 'Read from /tmp/output-3.txt', 'clusterName': u'cc',
-       'taskId': 3, 'exitCode': 777},
-      {'status': 'COMPLETED', 'roleCommand': 'UPGRADE',
-       'serviceName': 'serviceName', 'role': 'role', 'actionId': 17,
-       'stderr': 'stderr', 'stdout': 'out', 'clusterName': 'clusterName',
-       'taskId': 'taskId', 'exitCode': 0},
-      {'status': 'FAILED', 'roleCommand': u'INSTALL', 'serviceName': u'HDFS',
-       'role': u'DATANODE', 'actionId': '1-1', 'stderr': 'stderr',
-       'stdout': 'out', 'clusterName': u'cc', 'taskId': 3, 'exitCode': 13},
-      {'status': 'COMPLETED', 'stdout': 'out',
-       'configurationTags': {'global': {'tag': 'v1'}}, 'taskId': 3,
-       'exitCode': 0, 'roleCommand': u'INSTALL', 'clusterName': u'cc',
-       'serviceName': u'HDFS', 'role': u'DATANODE', 'actionId': '1-1',
-       'stderr': 'stderr'}], 'componentStatus': [
-      {'status': 'HEALTHY', 'componentName': 'DATANODE'},
-      {'status': 'UNHEALTHY', 'componentName': 'NAMENODE'}]}
-    self.assertEquals(hb, expected)
-
-
-  @patch.object(HostInfo, 'register')
-  def test_heartbeat_no_host_check_cmd_in_queue(self, register_mock):
-    actionQueue = ActionQueue(AmbariConfig.AmbariConfig().getConfig(),'dummy_controller')
-    statusCommand = {
-      "serviceName" : 'HDFS',
-      "commandType" : "STATUS_COMMAND",
-      "clusterName" : "c1",
-      "componentName" : "DATANODE",
-      'configurations':{'global' : {}}
-    }
-    actionQueue.put([statusCommand])
-
-    heartbeat = Heartbeat(actionQueue)
-    heartbeat.build(12, 6)
-    self.assertTrue(register_mock.called)
-    args, kwargs = register_mock.call_args_list[0]
-    self.assertTrue(args[2])
-    self.assertFalse(args[1])
-
-
-  @patch.object(HostInfo, 'register')
-  def test_heartbeat_host_check_no_cmd(self, register_mock):
-    actionQueue = ActionQueue(AmbariConfig.AmbariConfig().getConfig(),'dummy_controller')
-    heartbeat = Heartbeat(actionQueue)
-    heartbeat.build(12, 6)
-    self.assertTrue(register_mock.called)
-    args, kwargs = register_mock.call_args_list[0]
-    self.assertFalse(args[1])
-    self.assertFalse(args[2])
-
-
-if __name__ == "__main__":
-  unittest.main(verbosity=2)