You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2014/08/18 18:39:19 UTC

[3/5] git commit: AMBARI-6889. Add unittests for BEFORE-ANY hook (aonishuk)

AMBARI-6889. Add unittests for BEFORE-ANY hook (aonishuk)


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

Branch: refs/heads/branch-alerts-dev
Commit: f9c8bd96cf60450d349f7c8f2ded20588e86a7a0
Parents: 9e529ed
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Aug 18 16:52:50 2014 +0300
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Mon Aug 18 12:39:08 2014 -0400

----------------------------------------------------------------------
 .../1.3.2/hooks/before-ANY/test_before_any.py   | 39 ++++++++++++++++++++
 .../2.0.6/hooks/before-ANY/test_before_any.py   | 39 ++++++++++++++++++++
 2 files changed, 78 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f9c8bd96/ambari-server/src/test/python/stacks/1.3.2/hooks/before-ANY/test_before_any.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/1.3.2/hooks/before-ANY/test_before_any.py b/ambari-server/src/test/python/stacks/1.3.2/hooks/before-ANY/test_before_any.py
new file mode 100644
index 0000000..fe623a5
--- /dev/null
+++ b/ambari-server/src/test/python/stacks/1.3.2/hooks/before-ANY/test_before_any.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+'''
+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 mock.mock import MagicMock, call, patch
+from resource_management import *
+from stacks.utils.RMFTestCase import *
+
+@patch.object(Hook, "run_custom_hook", new = MagicMock())
+class TestHookBeforeInstall(RMFTestCase):
+  def test_hook_default(self):
+    self.executeScript("1.3.2/hooks/before-ANY/scripts/hook.py",
+                       classname="BeforeAnyHook",
+                       command="hook",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'mkdir -p /tmp/HDP-artifacts/;     curl -kf -x "" --retry 10     http://c6401.ambari.apache.org:8080/resources//UnlimitedJCEPolicyJDK7.zip -o /tmp/HDP-artifacts//UnlimitedJCEPolicyJDK7.zip',
+        environment = {'no_proxy': 'c6401.ambari.apache.org'},
+        not_if = 'test -e /tmp/HDP-artifacts//UnlimitedJCEPolicyJDK7.zip',
+        ignore_failures = True,
+        path = ['/bin', '/usr/bin/'],
+    )
+    self.assertNoMoreResources()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/f9c8bd96/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
new file mode 100644
index 0000000..3abfa57
--- /dev/null
+++ b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+'''
+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 mock.mock import MagicMock, call, patch
+from resource_management import *
+from stacks.utils.RMFTestCase import *
+
+@patch.object(Hook, "run_custom_hook", new = MagicMock())
+class TestHookBeforeInstall(RMFTestCase):
+  def test_hook_default(self):
+    self.executeScript("2.0.6/hooks/before-ANY/scripts/hook.py",
+                       classname="BeforeAnyHook",
+                       command="hook",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'mkdir -p /tmp/HDP-artifacts/;     curl -kf -x "" --retry 10     http://c6401.ambari.apache.org:8080/resources//UnlimitedJCEPolicyJDK7.zip -o /tmp/HDP-artifacts//UnlimitedJCEPolicyJDK7.zip',
+        environment = {'no_proxy': 'c6401.ambari.apache.org'},
+        not_if = 'test -e /tmp/HDP-artifacts//UnlimitedJCEPolicyJDK7.zip',
+        ignore_failures = True,
+        path = ['/bin', '/usr/bin/'],
+    )
+    self.assertNoMoreResources()
\ No newline at end of file