ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject git commit: AMBARI-4559. Write unnitests for OOZIE install script on HDP1 and HDP2 (Ivan Kozlov via dlysnichenko)
Date Mon, 10 Feb 2014 16:55:27 GMT
Updated Branches:
  refs/heads/trunk dea337569 -> 65e8bc1e2


AMBARI-4559. Write unnitests for OOZIE install script on HDP1 and HDP2 (Ivan Kozlov via dlysnichenko)


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

Branch: refs/heads/trunk
Commit: 65e8bc1e25d005296d961fc51796c11f56eaf596
Parents: dea3375
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Mon Feb 10 18:54:39 2014 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Mon Feb 10 18:54:39 2014 +0200

----------------------------------------------------------------------
 .../stacks/1.3.2/OOZIE/test_oozie_client.py     | 108 ++++++++
 .../stacks/1.3.2/OOZIE/test_oozie_server.py     | 262 ++++++++++++++++++
 .../stacks/2.0.6/OOZIE/test_oozie_client.py     | 114 ++++++++
 .../stacks/2.0.6/OOZIE/test_oozie_server.py     | 277 +++++++++++++++++++
 4 files changed, 761 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/65e8bc1e/ambari-server/src/test/python/stacks/1.3.2/OOZIE/test_oozie_client.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/1.3.2/OOZIE/test_oozie_client.py b/ambari-server/src/test/python/stacks/1.3.2/OOZIE/test_oozie_client.py
new file mode 100644
index 0000000..e60b1ad
--- /dev/null
+++ b/ambari-server/src/test/python/stacks/1.3.2/OOZIE/test_oozie_client.py
@@ -0,0 +1,108 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+class TestOozieClient(RMFTestCase):
+
+  def test_configure_default(self):
+    self.executeScript("1.3.2/services/OOZIE/package/scripts/oozie_client.py",
+                       classname = "OozieClient",
+                       command = "configure",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('XmlConfig', 'oozie-site.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+      mode = 0664,
+      conf_dir = '/etc/oozie/conf',
+      configurations = self.getConfig()['configurations']['oozie-site'],
+    )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('TemplateConfig', '/etc/oozie/conf/oozie-env.sh',
+      owner = 'oozie',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/adminusers.txt',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/hadoop-config.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/oozie-default.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf/action-conf',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/action-conf/hive.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertNoMoreResources()
+
+
+  def test_configure_secured(self):
+    self.executeScript("1.3.2/services/OOZIE/package/scripts/oozie_client.py",
+                       classname = "OozieClient",
+                       command = "configure",
+                       config_file="secured.json"
+    )
+    self.assertResourceCalled('XmlConfig', 'oozie-site.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+      mode = 0664,
+      conf_dir = '/etc/oozie/conf',
+      configurations = self.getConfig()['configurations']['oozie-site'],
+    )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('TemplateConfig', '/etc/oozie/conf/oozie-env.sh',
+      owner = 'oozie',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/adminusers.txt',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/hadoop-config.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/oozie-default.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf/action-conf',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/action-conf/hive.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertNoMoreResources()

http://git-wip-us.apache.org/repos/asf/ambari/blob/65e8bc1e/ambari-server/src/test/python/stacks/1.3.2/OOZIE/test_oozie_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/1.3.2/OOZIE/test_oozie_server.py b/ambari-server/src/test/python/stacks/1.3.2/OOZIE/test_oozie_server.py
new file mode 100644
index 0000000..ccc027c
--- /dev/null
+++ b/ambari-server/src/test/python/stacks/1.3.2/OOZIE/test_oozie_server.py
@@ -0,0 +1,262 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+class TestOozieServer(RMFTestCase):
+
+  def test_configure_default(self):
+    self.executeScript("1.3.2/services/OOZIE/package/scripts/oozie_server.py",
+                       classname = "OozieServer",
+                       command = "configure",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('XmlConfig', 'oozie-site.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+      mode = 0664,
+      conf_dir = '/etc/oozie/conf',
+      configurations = self.getConfig()['configurations']['oozie-site'],
+    )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('TemplateConfig', '/etc/oozie/conf/oozie-env.sh',
+      owner = 'oozie',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/adminusers.txt',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/hadoop-config.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/oozie-default.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf/action-conf',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/action-conf/hive.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('Directory', '/var/run/oozie',
+      owner = 'oozie',
+      recursive = True,
+      mode = 0755,
+    )
+    self.assertResourceCalled('Directory', '/var/log/oozie',
+      owner = 'oozie',
+      recursive = True,
+      mode = 0755,
+    )
+    self.assertResourceCalled('Directory', '/var/tmp/oozie',
+      owner = 'oozie',
+      recursive = True,
+      mode = 0755,
+    )
+    self.assertResourceCalled('Directory', '/hadoop/oozie/data',
+      owner = 'oozie',
+      recursive = True,
+      mode = 0755,
+    )
+    self.assertResourceCalled('Directory', '/var/lib/oozie/',
+      owner = 'oozie',
+      recursive = True,
+      mode = 0755,
+    )
+    self.assertResourceCalled('Directory', '/var/lib/oozie/oozie-server/webapps/',
+      owner = 'oozie',
+      recursive = True,
+      mode = 0755,
+    )
+    self.assertResourceCalled('Execute', 'cd /usr/lib/oozie && tar -xvf oozie-sharelib.tar.gz',
+      not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+    )
+    self.assertResourceCalled('Execute', 'cd /usr/lib/oozie && mkdir -p /var/tmp/oozie',
+      not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+    )
+    self.assertResourceCalled('Execute', 'cd /usr/lib/oozie && chown oozie:hadoop
/var/tmp/oozie',
+      not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+    )
+    self.assertResourceCalled('Execute', 'cd /var/tmp/oozie && /usr/lib/oozie/bin/oozie-setup.sh
-hadoop 0.20.200 /usr/lib/hadoop/ -extjs /usr/share/HDP-oozie/ext.zip -jars /usr/lib/hadoop/lib/hadoop-lzo-0.5.0.jar:',
+      not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+      user = 'oozie',
+    )
+    self.assertNoMoreResources()
+
+
+  def test_start_default(self):
+    self.executeScript("1.3.2/services/OOZIE/package/scripts/oozie_server.py",
+                         classname = "OozieServer",
+                         command = "start",
+                         config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'cd /var/tmp/oozie && /usr/lib/oozie/bin/ooziedb.sh
create -sqlfile oozie.sql -run',
+      not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+      ignore_failures = True,
+      user = 'oozie',
+    )
+    self.assertResourceCalled('Execute', ' hadoop dfs -put /usr/lib/oozie/share /user/oozie
; hadoop dfs -chmod -R 755 /user/oozie/share',
+      not_if = " hadoop dfs -ls /user/oozie/share | awk 'BEGIN {count=0;} /share/ {count++}
END {if (count > 0) {exit 0} else {exit 1}}'",
+      user = 'oozie',
+    )
+    self.assertResourceCalled('Execute', 'cd /var/tmp/oozie && /usr/lib/oozie/bin/oozie-start.sh',
+      not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+      user = 'oozie',
+    )
+    self.assertNoMoreResources()
+
+
+  def test_stop_default(self):
+    self.executeScript("1.3.2/services/OOZIE/package/scripts/oozie_server.py",
+                         classname = "OozieServer",
+                         command = "stop",
+                         config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', "su - oozie -c  'cd /var/tmp/oozie && /usr/lib/oozie/bin/oozie-stop.sh'
&& rm -f /var/run/oozie/oozie.pid",
+      only_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+    )
+    self.assertNoMoreResources()
+
+
+  def test_configure_secured(self):
+    self.executeScript("1.3.2/services/OOZIE/package/scripts/oozie_server.py",
+                       classname = "OozieServer",
+                       command = "configure",
+                       config_file="secured.json"
+    )
+    self.assertResourceCalled('XmlConfig', 'oozie-site.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+      mode = 0664,
+      conf_dir = '/etc/oozie/conf',
+      configurations = self.getConfig()['configurations']['oozie-site'],
+    )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('TemplateConfig', '/etc/oozie/conf/oozie-env.sh',
+      owner = 'oozie',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/adminusers.txt',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/hadoop-config.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/oozie-default.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf/action-conf',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/oozie/conf/action-conf/hive.xml',
+      owner = 'oozie',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('Directory', '/var/run/oozie',
+      owner = 'oozie',
+      recursive = True,
+      mode = 0755,
+    )
+    self.assertResourceCalled('Directory', '/var/log/oozie',
+      owner = 'oozie',
+      recursive = True,
+      mode = 0755,
+    )
+    self.assertResourceCalled('Directory', '/var/tmp/oozie',
+      owner = 'oozie',
+      recursive = True,
+      mode = 0755,
+    )
+    self.assertResourceCalled('Directory', '/hadoop/oozie/data',
+      owner = 'oozie',
+      recursive = True,
+      mode = 0755,
+    )
+    self.assertResourceCalled('Directory', '/var/lib/oozie/',
+      owner = 'oozie',
+      recursive = True,
+      mode = 0755,
+    )
+    self.assertResourceCalled('Directory', '/var/lib/oozie/oozie-server/webapps/',
+      owner = 'oozie',
+      recursive = True,
+      mode = 0755,
+    )
+    self.assertResourceCalled('Execute', 'cd /usr/lib/oozie && tar -xvf oozie-sharelib.tar.gz',
+      not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+    )
+    self.assertResourceCalled('Execute', 'cd /usr/lib/oozie && mkdir -p /var/tmp/oozie',
+      not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+    )
+    self.assertResourceCalled('Execute', 'cd /usr/lib/oozie && chown oozie:hadoop
/var/tmp/oozie',
+      not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+    )
+    self.assertResourceCalled('Execute', 'cd /var/tmp/oozie && /usr/lib/oozie/bin/oozie-setup.sh
-hadoop 0.20.200 /usr/lib/hadoop/ -extjs /usr/share/HDP-oozie/ext.zip -jars /usr/lib/hadoop/lib/hadoop-lzo-0.5.0.jar:',
+      not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+      user = 'oozie',
+    )
+    self.assertNoMoreResources()
+
+
+  def test_start_secured(self):
+    self.executeScript("1.3.2/services/OOZIE/package/scripts/oozie_server.py",
+                         classname = "OozieServer",
+                         command = "start",
+                         config_file="secured.json"
+    )
+    self.assertResourceCalled('Execute', 'cd /var/tmp/oozie && /usr/lib/oozie/bin/ooziedb.sh
create -sqlfile oozie.sql -run',
+      not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+      ignore_failures = True,
+      user = 'oozie',
+    )
+    self.assertResourceCalled('Execute', '/usr/bin/kinit -kt /etc/security/keytabs/oozie.service.keytab
oozie/c6402.ambari.apache.org@EXAMPLE.COM; hadoop dfs -put /usr/lib/oozie/share /user/oozie
; hadoop dfs -chmod -R 755 /user/oozie/share',
+      not_if = "/usr/bin/kinit -kt /etc/security/keytabs/oozie.service.keytab oozie/c6402.ambari.apache.org@EXAMPLE.COM;
hadoop dfs -ls /user/oozie/share | awk 'BEGIN {count=0;} /share/ {count++} END {if (count
> 0) {exit 0} else {exit 1}}'",
+      user = 'oozie',
+    )
+    self.assertResourceCalled('Execute', 'cd /var/tmp/oozie && /usr/lib/oozie/bin/oozie-start.sh',
+      not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+      user = 'oozie',
+    )
+    self.assertNoMoreResources()
+
+
+  def test_stop_secured(self):
+    self.executeScript("1.3.2/services/OOZIE/package/scripts/oozie_server.py",
+                         classname = "OozieServer",
+                         command = "stop",
+                         config_file="secured.json"
+    )
+    self.assertResourceCalled('Execute', "su - oozie -c  'cd /var/tmp/oozie && /usr/lib/oozie/bin/oozie-stop.sh'
&& rm -f /var/run/oozie/oozie.pid",
+      only_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+    )
+    self.assertNoMoreResources()

http://git-wip-us.apache.org/repos/asf/ambari/blob/65e8bc1e/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py
new file mode 100644
index 0000000..358cab9
--- /dev/null
+++ b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py
@@ -0,0 +1,114 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+class TestOozieClient(RMFTestCase):
+
+  def test_configure_default(self):
+    self.executeScript("2.0.6/services/OOZIE/package/scripts/oozie_client.py",
+                       classname = "OozieClient",
+                       command = "configure",
+                       config_file="default.json"
+    )
+    # Hack for oozie.py changing conf on fly
+    oozie_site = self.getConfig()['configurations']['oozie-site'].copy()
+    oozie_site["oozie.services.ext"] = 'org.apache.oozie.service.JMSAccessorService,' + oozie_site["oozie.services.ext"]
+    self.assertResourceCalled('XmlConfig', 'oozie-site.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              mode = 0664,
+                              conf_dir = '/etc/oozie/conf',
+                              configurations = oozie_site,
+                              )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf',
+        owner = 'oozie',
+        group = 'hadoop',
+        )
+    self.assertResourceCalled('TemplateConfig', '/etc/oozie/conf/oozie-env.sh',
+        owner = 'oozie',
+        )
+    self.assertResourceCalled('File', '/etc/oozie/conf/adminusers.txt',
+        owner = 'oozie',
+        group = 'hadoop',
+        )
+    self.assertResourceCalled('File', '/etc/oozie/conf/hadoop-config.xml',
+        owner = 'oozie',
+        group = 'hadoop',
+        )
+    self.assertResourceCalled('File', '/etc/oozie/conf/oozie-default.xml',
+        owner = 'oozie',
+        group = 'hadoop',
+        )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf/action-conf',
+        owner = 'oozie',
+        group = 'hadoop',
+        )
+    self.assertResourceCalled('File', '/etc/oozie/conf/action-conf/hive.xml',
+        owner = 'oozie',
+        group = 'hadoop',
+        )
+    self.assertNoMoreResources()
+
+
+  def test_configure_secured(self):
+    self.executeScript("2.0.6/services/OOZIE/package/scripts/oozie_client.py",
+                       classname = "OozieClient",
+                       command = "configure",
+                       config_file="secured.json"
+    )
+    # Hack for oozie.py changing conf on fly
+    oozie_site = self.getConfig()['configurations']['oozie-site'].copy()
+    oozie_site["oozie.services.ext"] = 'org.apache.oozie.service.JMSAccessorService,' + oozie_site["oozie.services.ext"]
+    self.assertResourceCalled('XmlConfig', 'oozie-site.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              mode = 0664,
+                              conf_dir = '/etc/oozie/conf',
+                              configurations = oozie_site,
+                              )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('TemplateConfig', '/etc/oozie/conf/oozie-env.sh',
+                              owner = 'oozie',
+                              )
+    self.assertResourceCalled('File', '/etc/oozie/conf/adminusers.txt',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/oozie/conf/hadoop-config.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/oozie/conf/oozie-default.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf/action-conf',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/oozie/conf/action-conf/hive.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertNoMoreResources()

http://git-wip-us.apache.org/repos/asf/ambari/blob/65e8bc1e/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py
new file mode 100644
index 0000000..300f9c8
--- /dev/null
+++ b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py
@@ -0,0 +1,277 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+class TestOozieServer(RMFTestCase):
+  def test_configure_default(self):
+    self.executeScript("2.0.6/services/OOZIE/package/scripts/oozie_server.py",
+                       classname = "OozieServer",
+                       command = "configure",
+                       config_file="default.json"
+    )
+    self.assert_configure_default()
+    self.assertNoMoreResources()
+
+
+  def test_start_default(self):
+    self.executeScript("2.0.6/services/OOZIE/package/scripts/oozie_server.py",
+                         classname = "OozieServer",
+                         command = "start",
+                         config_file="default.json"
+        )
+    self.assert_configure_default()
+    self.assertResourceCalled('Execute', 'cd /var/tmp/oozie && /usr/lib/oozie/bin/ooziedb.sh
create -sqlfile oozie.sql -run',
+        not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+        ignore_failures = True,
+        user = 'oozie',
+        )
+    self.assertResourceCalled('Execute', ' hadoop dfs -put /usr/lib/oozie/share /user/oozie
; hadoop dfs -chmod -R 755 /user/oozie/share',
+        not_if = " hadoop dfs -ls /user/oozie/share | awk 'BEGIN {count=0;} /share/ {count++}
END {if (count > 0) {exit 0} else {exit 1}}'",
+        user = 'oozie',
+        )
+    self.assertResourceCalled('Execute', 'cd /var/tmp/oozie && /usr/lib/oozie/bin/oozie-start.sh',
+        not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+        user = 'oozie',
+        )
+    self.assertNoMoreResources()
+
+
+  def test_stop_default(self):
+    self.executeScript("2.0.6/services/OOZIE/package/scripts/oozie_server.py",
+                         classname = "OozieServer",
+                         command = "stop",
+                         config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', "su - oozie -c  'cd /var/tmp/oozie && /usr/lib/oozie/bin/oozie-stop.sh'
&& rm -f /var/run/oozie/oozie.pid",
+      only_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps `cat
/var/run/oozie/oozie.pid` >/dev/null 2>&1',
+    )
+    self.assertNoMoreResources()
+
+
+  def test_configure_secured(self):
+    self.executeScript("2.0.6/services/OOZIE/package/scripts/oozie_server.py",
+                       classname = "OozieServer",
+                       command = "configure",
+                       config_file="secured.json"
+    )
+    self.assert_configure_secured()
+    self.assertNoMoreResources()
+
+
+  def test_start_secured(self):
+    self.executeScript("2.0.6/services/OOZIE/package/scripts/oozie_server.py",
+                         classname = "OozieServer",
+                         command = "start",
+                         config_file="secured.json"
+    )
+    self.assert_configure_secured()
+    self.assertResourceCalled('Execute', 'cd /var/tmp/oozie && /usr/lib/oozie/bin/ooziedb.sh
create -sqlfile oozie.sql -run',
+                              not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1
&& ps `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1',
+                              ignore_failures = True,
+                              user = 'oozie',
+                              )
+    self.assertResourceCalled('Execute', '/usr/bin/kinit -kt /etc/security/keytabs/oozie.service.keytab
oozie/c6402.ambari.apache.org@EXAMPLE.COM; hadoop dfs -put /usr/lib/oozie/share /user/oozie
; hadoop dfs -chmod -R 755 /user/oozie/share',
+                              not_if = "/usr/bin/kinit -kt /etc/security/keytabs/oozie.service.keytab
oozie/c6402.ambari.apache.org@EXAMPLE.COM; hadoop dfs -ls /user/oozie/share | awk 'BEGIN {count=0;}
/share/ {count++} END {if (count > 0) {exit 0} else {exit 1}}'",
+                              user = 'oozie',
+                              )
+    self.assertResourceCalled('Execute', 'cd /var/tmp/oozie && /usr/lib/oozie/bin/oozie-start.sh',
+                              not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1
&& ps `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1',
+                              user = 'oozie',
+                              )
+    self.assertNoMoreResources()
+
+  def test_stop_secured(self):
+    self.executeScript("2.0.6/services/OOZIE/package/scripts/oozie_server.py",
+                         classname = "OozieServer",
+                         command = "stop",
+                         config_file="secured.json"
+    )
+    self.assertResourceCalled('Execute', "su - oozie -c  'cd /var/tmp/oozie && /usr/lib/oozie/bin/oozie-stop.sh'
&& rm -f /var/run/oozie/oozie.pid",
+                              only_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1
&& ps `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1',
+                              )
+    self.assertNoMoreResources()
+
+
+  def assert_configure_default(self):
+    # Hack for oozie.py changing conf on fly
+    oozie_site = self.getConfig()['configurations']['oozie-site'].copy()
+    oozie_site["oozie.services.ext"] = 'org.apache.oozie.service.JMSAccessorService,' + oozie_site["oozie.services.ext"]
+    self.assertResourceCalled('XmlConfig', 'oozie-site.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              mode = 0664,
+                              conf_dir = '/etc/oozie/conf',
+                              configurations = oozie_site,
+                              )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('TemplateConfig', '/etc/oozie/conf/oozie-env.sh',
+                              owner = 'oozie',
+                              )
+    self.assertResourceCalled('File', '/etc/oozie/conf/adminusers.txt',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/oozie/conf/hadoop-config.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/oozie/conf/oozie-default.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf/action-conf',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/oozie/conf/action-conf/hive.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('Directory', '/var/run/oozie',
+                              owner = 'oozie',
+                              recursive = True,
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Directory', '/var/log/oozie',
+                              owner = 'oozie',
+                              recursive = True,
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Directory', '/var/tmp/oozie',
+                              owner = 'oozie',
+                              recursive = True,
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Directory', '/hadoop/oozie/data',
+                              owner = 'oozie',
+                              recursive = True,
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Directory', '/var/lib/oozie/',
+                              owner = 'oozie',
+                              recursive = True,
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Directory', '/var/lib/oozie/oozie-server/webapps/',
+                              owner = 'oozie',
+                              recursive = True,
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Execute', 'cd /usr/lib/oozie && tar -xvf oozie-sharelib.tar.gz',
+                              not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1
&& ps `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1',
+                              )
+    self.assertResourceCalled('Execute', 'cd /usr/lib/oozie && mkdir -p /var/tmp/oozie',
+                              not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1
&& ps `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1',
+                              )
+    self.assertResourceCalled('Execute', 'cd /usr/lib/oozie && chown oozie:hadoop
/var/tmp/oozie && mkdir -p /usr/lib/oozie/libext && cp /usr/share/HDP-oozie/ext-2.2.zip
/usr/lib/oozie/libext && cp /usr/lib/falcon/oozie/ext/falcon-oozie-el-extension-*.jar
/usr/lib/oozie/libext',
+                              not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1
&& ps `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1',
+                              )
+    self.assertResourceCalled('Execute', 'cd /var/tmp/oozie && /usr/lib/oozie/bin/oozie-setup.sh
prepare-war',
+                              not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1
&& ps `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1',
+                              user = 'oozie',
+                              )
+
+
+  def assert_configure_secured(self):
+    # Hack for oozie.py changing conf on fly
+    oozie_site = self.getConfig()['configurations']['oozie-site'].copy()
+    oozie_site["oozie.services.ext"] = 'org.apache.oozie.service.JMSAccessorService,' + oozie_site["oozie.services.ext"]
+    self.assertResourceCalled('XmlConfig', 'oozie-site.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              mode = 0664,
+                              conf_dir = '/etc/oozie/conf',
+                              configurations = oozie_site,
+                              )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('TemplateConfig', '/etc/oozie/conf/oozie-env.sh',
+                              owner = 'oozie',
+                              )
+    self.assertResourceCalled('File', '/etc/oozie/conf/adminusers.txt',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/oozie/conf/hadoop-config.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/oozie/conf/oozie-default.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('Directory', '/etc/oozie/conf/action-conf',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/oozie/conf/action-conf/hive.xml',
+                              owner = 'oozie',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('Directory', '/var/run/oozie',
+                              owner = 'oozie',
+                              recursive = True,
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Directory', '/var/log/oozie',
+                              owner = 'oozie',
+                              recursive = True,
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Directory', '/var/tmp/oozie',
+                              owner = 'oozie',
+                              recursive = True,
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Directory', '/hadoop/oozie/data',
+                              owner = 'oozie',
+                              recursive = True,
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Directory', '/var/lib/oozie/',
+                              owner = 'oozie',
+                              recursive = True,
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Directory', '/var/lib/oozie/oozie-server/webapps/',
+                              owner = 'oozie',
+                              recursive = True,
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Execute', 'cd /usr/lib/oozie && tar -xvf oozie-sharelib.tar.gz',
+                              not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1
&& ps `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1',
+                              )
+    self.assertResourceCalled('Execute', 'cd /usr/lib/oozie && mkdir -p /var/tmp/oozie',
+                              not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1
&& ps `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1',
+                              )
+    self.assertResourceCalled('Execute', 'cd /usr/lib/oozie && chown oozie:hadoop
/var/tmp/oozie && mkdir -p /usr/lib/oozie/libext && cp /usr/share/HDP-oozie/ext-2.2.zip
/usr/lib/oozie/libext && cp /usr/lib/falcon/oozie/ext/falcon-oozie-el-extension-*.jar
/usr/lib/oozie/libext',
+                              not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1
&& ps `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1',
+                              )
+    self.assertResourceCalled('Execute', 'cd /var/tmp/oozie && /usr/lib/oozie/bin/oozie-setup.sh
prepare-war',
+                              not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1
&& ps `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1',
+                              user = 'oozie',
+                              )
+


Mime
View raw message