AMBARI-7455. Add python unit test for ATS.(vbrodetskyi)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/061fb880 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/061fb880 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/061fb880 Branch: refs/heads/branch-alerts-dev Commit: 061fb880440ff757bf5cc22fcab6d7b513e659b6 Parents: d29c34a Author: Vitaly Brodetskyi <[email protected]> Authored: Tue Sep 23 21:08:39 2014 +0300 Committer: Vitaly Brodetskyi <[email protected]> Committed: Tue Sep 23 21:08:51 2014 +0300 ---------------------------------------------------------------------- .../package/scripts/application_timeline_server.py | 2 +- .../python/stacks/2.1/YARN/test_apptimelineserver.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/061fb880/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/application_timeline_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/application_timeline_server.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/application_timeline_server.py index b38c147..75a4710 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/application_timeline_server.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/application_timeline_server.py @@ -51,7 +51,7 @@ class ApplicationTimelineServer(Script): env.set_params(status_params) Execute(format("mv {yarn_historyserver_pid_file_old} {yarn_historyserver_pid_file}"), only_if = format("test -e {yarn_historyserver_pid_file_old}", user=status_params.yarn_user)) - check_process_status(status_params.yarn_historyserver_pid_file) + functions.check_process_status(status_params.yarn_historyserver_pid_file) if __name__ == "__main__": ApplicationTimelineServer().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/061fb880/ambari-server/src/test/python/stacks/2.1/YARN/test_apptimelineserver.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.1/YARN/test_apptimelineserver.py b/ambari-server/src/test/python/stacks/2.1/YARN/test_apptimelineserver.py index 4d28601..89019ba 100644 --- a/ambari-server/src/test/python/stacks/2.1/YARN/test_apptimelineserver.py +++ b/ambari-server/src/test/python/stacks/2.1/YARN/test_apptimelineserver.py @@ -20,8 +20,10 @@ limitations under the License. from mock.mock import MagicMock, call, patch from stacks.utils.RMFTestCase import * import os +import resource_management.libraries.functions origin_exists = os.path.exists [email protected](resource_management.libraries.functions, "check_process_status", new = MagicMock()) @patch.object(os.path, "exists", new=MagicMock( side_effect=lambda *args: origin_exists(args[0]) if args[0][-2:] == "j2" else True)) @@ -207,3 +209,15 @@ class TestAppTimelineServer(RMFTestCase): owner = 'mapred', group = 'hadoop', ) + + + def test_status(self): + self.executeScript("2.0.6/services/YARN/package/scripts/application_timeline_server.py", + classname="ApplicationTimelineServer", + command="status", + config_file="default.json") + + self.assertResourceCalled('Execute', 'mv /var/run/hadoop-yarn/yarn/yarn-yarn-historyserver.pid /var/run/hadoop-yarn/yarn/yarn-yarn-timelineserver.pid', + only_if = 'test -e /var/run/hadoop-yarn/yarn/yarn-yarn-historyserver.pid', + ) + self.assertNoMoreResources()
