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

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

Repository: ambari
Updated Branches:
  refs/heads/trunk 49a377ce4 -> cbf4fc823


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/cbf4fc82
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cbf4fc82
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cbf4fc82

Branch: refs/heads/trunk
Commit: cbf4fc8231f2816717ecc57531678aa83196bf96
Parents: 49a377c
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Aug 18 16:52:50 2014 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Mon Aug 18 16:52:50 2014 +0300

----------------------------------------------------------------------
 .../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/cbf4fc82/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/cbf4fc82/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