Browse Source

AMBARI-4427. Unittests for hooks, GANGLIA, FALCON and SQOOP (Eugene Chekanskiy via dlysnichenko)

Lisnichenko Dmitro 11 năm trước cách đây
mục cha
commit
bc102b3273
24 tập tin đã thay đổi với 1703 bổ sung27 xóa
  1. 1 1
      ambari-server/src/main/resources/stacks/HDP/1.3.3/services/GANGLIA/package/scripts/ganglia.py
  2. 3 5
      ambari-server/src/main/resources/stacks/HDP/2.1.1/services/FALCON/package/scripts/falcon_client.py
  3. 2 2
      ambari-server/src/main/resources/stacks/HDP/2.1.1/services/FALCON/package/scripts/falcon_server.py
  4. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.1.1/services/GANGLIA/package/scripts/ganglia.py
  5. 2 2
      ambari-server/src/main/resources/stacks/HDP/2.1.1/services/GANGLIA/package/scripts/ganglia_server.py
  6. 195 0
      ambari-server/src/test/python/stacks/1.3.3/GANGLIA/test_ganglia_monitor.py
  7. 226 0
      ambari-server/src/test/python/stacks/1.3.3/GANGLIA/test_ganglia_server.py
  8. 48 0
      ambari-server/src/test/python/stacks/1.3.3/SQOOP/test_service_check.py
  9. 52 0
      ambari-server/src/test/python/stacks/1.3.3/SQOOP/test_sqoop.py
  10. 78 0
      ambari-server/src/test/python/stacks/1.3.3/hooks/before-INSTALL/test_before_install.py
  11. 150 0
      ambari-server/src/test/python/stacks/1.3.3/hooks/before-START/test_before_start.py
  12. 38 0
      ambari-server/src/test/python/stacks/2.1.1/FALCON/test_falcon_client.py
  13. 94 0
      ambari-server/src/test/python/stacks/2.1.1/FALCON/test_falcon_server.py
  14. 42 0
      ambari-server/src/test/python/stacks/2.1.1/FALCON/test_service_check.py
  15. 169 0
      ambari-server/src/test/python/stacks/2.1.1/GANGLIA/test_ganglia_monitor.py
  16. 214 0
      ambari-server/src/test/python/stacks/2.1.1/GANGLIA/test_ganglia_server.py
  17. 50 0
      ambari-server/src/test/python/stacks/2.1.1/SQOOP/test_service_check.py
  18. 52 0
      ambari-server/src/test/python/stacks/2.1.1/SQOOP/test_sqoop.py
  19. 12 3
      ambari-server/src/test/python/stacks/2.1.1/configs/default.json
  20. 11 2
      ambari-server/src/test/python/stacks/2.1.1/configs/secured.json
  21. 87 0
      ambari-server/src/test/python/stacks/2.1.1/hooks/before-INSTALL/test_before_install.py
  22. 157 0
      ambari-server/src/test/python/stacks/2.1.1/hooks/before-START/test_before_start.py
  23. 3 2
      ambari-server/src/test/python/stacks/utils/RMFTestCase.py
  24. 16 9
      ambari-server/src/test/python/unitTests.py

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/1.3.3/services/GANGLIA/package/scripts/ganglia.py

@@ -72,7 +72,7 @@ def shell_file(name):
   )
 
 
-def ganglia_TemplateConfig(name, mode=755, tag=None):
+def ganglia_TemplateConfig(name, mode=0755, tag=None):
   import params
 
   TemplateConfig(format("{params.ganglia_shell_cmds_dir}/{name}"),

+ 3 - 5
ambari-server/src/main/resources/stacks/HDP/2.1.1/services/FALCON/package/scripts/falcon_client.py

@@ -22,15 +22,13 @@ from falcon import falcon
 
 class FalconClient(Script):
   def install(self, env):
-    import params
-
     self.install_packages(env)
-    env.set_params(params)
-    self.config(env)
+    self.configure(env)
 
-  def config(self, env):
+  def configure(self, env):
     import params
 
+    env.set_params(params)
     falcon('client', action='config')
 
   def status(self, env):

+ 2 - 2
ambari-server/src/main/resources/stacks/HDP/2.1.1/services/FALCON/package/scripts/falcon_server.py

@@ -26,12 +26,12 @@ class FalconServer(Script):
 
     self.install_packages(env)
     env.set_params(params)
-    self.config(env)
 
   def start(self, env):
     import params
 
     env.set_params(params)
+    self.configure(env)
 
     falcon('server', action='start')
 
@@ -43,7 +43,7 @@ class FalconServer(Script):
     falcon('server', action='stop')
 
 
-  def config(self, env):
+  def configure(self, env):
     import params
 
     env.set_params(params)

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.1.1/services/GANGLIA/package/scripts/ganglia.py

@@ -63,7 +63,7 @@ def shell_file(name):
   )
 
 
-def ganglia_TemplateConfig(name, mode=755, tag=None):
+def ganglia_TemplateConfig(name, mode=0755, tag=None):
   import params
 
   TemplateConfig(format("{params.ganglia_shell_cmds_dir}/{name}"),

+ 2 - 2
ambari-server/src/main/resources/stacks/HDP/2.1.1/services/GANGLIA/package/scripts/ganglia_server.py

@@ -31,7 +31,7 @@ class GangliaServer(Script):
 
     self.install_packages(env)
     env.set_params(params)
-    self.config(env)
+    self.configure(env)
 
   def start(self, env):
     import params
@@ -52,7 +52,7 @@ class GangliaServer(Script):
     # Recursively check all existing gmetad pid files
     check_process_status(pid_file)
 
-  def config(self, env):
+  def configure(self, env):
     import params
 
     ganglia.groups_and_users()

+ 195 - 0
ambari-server/src/test/python/stacks/1.3.3/GANGLIA/test_ganglia_monitor.py

@@ -0,0 +1,195 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+
+class TestGangliaMonitor(RMFTestCase):
+
+  def test_configure_default(self):
+    self.executeScript("1.3.3/services/GANGLIA/package/scripts/ganglia_monitor.py",
+                       classname="GangliaMonitor",
+                       command="configure",
+                       config_file="default.json"
+                      )
+    self.assertResourceCalled('Group', 'hadoop',
+                              )
+    self.assertResourceCalled('Group', 'nobody',
+                              )
+    self.assertResourceCalled('Group', 'nobody',
+                              )
+    self.assertResourceCalled('User', 'nobody',
+                              groups = [u'nobody'],
+                              )
+    self.assertResourceCalled('User', 'nobody',
+                              groups = [u'nobody'],
+                              )
+    self.assertResourceCalled('Directory', '/etc/ganglia/hdp',
+                              owner = 'root',
+                              group = 'hadoop',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('Directory', '/usr/libexec/hdp/ganglia',
+                              owner = 'root',
+                              group = 'root',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('File', '/etc/init.d/hdp-gmetad',
+                              content = StaticFile('gmetad.init'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/etc/init.d/hdp-gmond',
+                              content = StaticFile('gmond.init'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/checkGmond.sh',
+                              content = StaticFile('checkGmond.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/checkRrdcached.sh',
+                              content = StaticFile('checkRrdcached.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/gmetadLib.sh',
+                              content = StaticFile('gmetadLib.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/gmondLib.sh',
+                              content = StaticFile('gmondLib.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/rrdcachedLib.sh',
+                              content = StaticFile('rrdcachedLib.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/setupGanglia.sh',
+                              content = StaticFile('setupGanglia.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/startGmetad.sh',
+                              content = StaticFile('startGmetad.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/startGmond.sh',
+                              content = StaticFile('startGmond.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/startRrdcached.sh',
+                              content = StaticFile('startRrdcached.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/stopGmetad.sh',
+                              content = StaticFile('stopGmetad.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/stopGmond.sh',
+                              content = StaticFile('stopGmond.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/stopRrdcached.sh',
+                              content = StaticFile('stopRrdcached.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/teardownGanglia.sh',
+                              content = StaticFile('teardownGanglia.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('TemplateConfig', '/usr/libexec/hdp/ganglia/gangliaClusters.conf',
+                              owner = 'root',
+                              template_tag = None,
+                              group = 'root',
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('TemplateConfig', '/usr/libexec/hdp/ganglia/gangliaEnv.sh',
+                              owner = 'root',
+                              template_tag = None,
+                              group = 'root',
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('TemplateConfig', '/usr/libexec/hdp/ganglia/gangliaLib.sh',
+                              owner = 'root',
+                              template_tag = None,
+                              group = 'root',
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPJobTracker -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPHistoryServer -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPSlaves -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Directory', '/etc/ganglia/conf.d',
+                              owner = 'root',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/ganglia/conf.d/modgstatus.conf',
+                              owner = 'root',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/ganglia/conf.d/multicpu.conf',
+                              owner = 'root',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/ganglia/gmond.conf',
+                              owner = 'root',
+                              group = 'hadoop',
+                              )
+    self.assertNoMoreResources()
+
+  def test_start_default(self):
+    self.executeScript("1.3.3/services/GANGLIA/package/scripts/ganglia_monitor.py",
+                       classname="GangliaMonitor",
+                       command="start",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'chkconfig gmond off',
+                              path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', 'service hdp-gmond start >> /tmp/gmond.log  2>&1 ; /bin/ps auwx | /bin/grep [g]mond  >> /tmp/gmond.log  2>&1',
+                              path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
+                              )
+    self.assertNoMoreResources()
+
+  def test_stop_default(self):
+    self.executeScript("1.3.3/services/GANGLIA/package/scripts/ganglia_monitor.py",
+                       classname="GangliaMonitor",
+                       command="stop",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'service hdp-gmond stop >> /tmp/gmond.log  2>&1 ; /bin/ps auwx | /bin/grep [g]mond  >> /tmp/gmond.log  2>&1',
+                              path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
+                              )
+    self.assertNoMoreResources()
+

+ 226 - 0
ambari-server/src/test/python/stacks/1.3.3/GANGLIA/test_ganglia_server.py

@@ -0,0 +1,226 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+
+class TestGangliaServer(RMFTestCase):
+
+  def test_configure_default(self):
+    self.executeScript("1.3.3/services/GANGLIA/package/scripts/ganglia_server.py",
+                       classname="GangliaServer",
+                       command="configure",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Group', 'hadoop',
+                              )
+    self.assertResourceCalled('Group', 'nobody',
+                              )
+    self.assertResourceCalled('Group', 'nobody',
+                              )
+    self.assertResourceCalled('User', 'nobody',
+                              groups = [u'nobody'],
+                              )
+    self.assertResourceCalled('User', 'nobody',
+                              groups = [u'nobody'],
+                              )
+    self.assertResourceCalled('Directory', '/usr/libexec/hdp/ganglia',
+                              owner = 'root',
+                              group = 'root',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('File', '/etc/init.d/hdp-gmetad',
+                              content = StaticFile('gmetad.init'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/etc/init.d/hdp-gmond',
+                              content = StaticFile('gmond.init'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/checkGmond.sh',
+                              content = StaticFile('checkGmond.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/checkRrdcached.sh',
+                              content = StaticFile('checkRrdcached.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/gmetadLib.sh',
+                              content = StaticFile('gmetadLib.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/gmondLib.sh',
+                              content = StaticFile('gmondLib.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/rrdcachedLib.sh',
+                              content = StaticFile('rrdcachedLib.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/setupGanglia.sh',
+                              content = StaticFile('setupGanglia.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/startGmetad.sh',
+                              content = StaticFile('startGmetad.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/startGmond.sh',
+                              content = StaticFile('startGmond.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/startRrdcached.sh',
+                              content = StaticFile('startRrdcached.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/stopGmetad.sh',
+                              content = StaticFile('stopGmetad.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/stopGmond.sh',
+                              content = StaticFile('stopGmond.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/stopRrdcached.sh',
+                              content = StaticFile('stopRrdcached.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/teardownGanglia.sh',
+                              content = StaticFile('teardownGanglia.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('TemplateConfig', '/usr/libexec/hdp/ganglia/gangliaClusters.conf',
+                              owner = 'root',
+                              template_tag = None,
+                              group = 'root',
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('TemplateConfig', '/usr/libexec/hdp/ganglia/gangliaEnv.sh',
+                              owner = 'root',
+                              template_tag = None,
+                              group = 'root',
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('TemplateConfig', '/usr/libexec/hdp/ganglia/gangliaLib.sh',
+                              owner = 'root',
+                              template_tag = None,
+                              group = 'root',
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPNameNode -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPJobTracker -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPHBaseMaster -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPHistoryServer -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPDataNode -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPTaskTracker -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPHBaseRegionServer -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -t -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Directory', '/var/lib/ganglia/dwoo',
+                              owner = 'nobody',
+                              recursive = True,
+                              mode = 0777,
+                              )
+    self.assertResourceCalled('Directory', '/srv/www/cgi-bin',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('File', '/srv/www/cgi-bin/rrd.py',
+                              content = StaticFile('rrd.py'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/etc/ganglia/gmetad.conf',
+                              owner = 'root',
+                              group = 'hadoop',
+                              )
+    self.assertNoMoreResources()
+
+  def test_start_default(self):
+    self.executeScript("1.3.3/services/GANGLIA/package/scripts/ganglia_server.py",
+                       classname="GangliaServer",
+                       command="start",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'service hdp-gmetad start >> /tmp/gmetad.log  2>&1 ; /bin/ps auwx | /bin/grep [g]metad  >> /tmp/gmetad.log  2>&1',
+                              path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
+                              )
+    self.assertResourceCalled('MonitorWebserver', 'restart',
+                              )
+    self.assertNoMoreResources()
+
+  def test_stop_default(self):
+    self.executeScript("1.3.3/services/GANGLIA/package/scripts/ganglia_server.py",
+                       classname="GangliaServer",
+                       command="stop",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'service hdp-gmetad stop >> /tmp/gmetad.log  2>&1 ; /bin/ps auwx | /bin/grep [g]metad  >> /tmp/gmetad.log  2>&1',
+                              path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
+                              )
+    self.assertResourceCalled('MonitorWebserver', 'restart',
+                              )
+    self.assertNoMoreResources()
+

+ 48 - 0
ambari-server/src/test/python/stacks/1.3.3/SQOOP/test_service_check.py

@@ -0,0 +1,48 @@
+#!/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 TestSqoopServiceCheck(RMFTestCase):
+
+  def test_service_check_secured(self):
+    self.executeScript("1.3.3/services/SQOOP/package/scripts/service_check.py",
+                       classname = "SqoopServiceCheck",
+                       command = "service_check",
+                       config_file="secured.json")
+    self.assertResourceCalled('Execute', '/usr/bin/kinit  -kt /etc/security/keytabs/smokeuser.headless.keytab ambari-qa',)
+    self.assertResourceCalled('Execute', 'sqoop version',
+                              logoutput = True,
+                              user = 'ambari-qa',)
+    self.assertNoMoreResources()
+
+  def test_service_check_default(self):
+    self.executeScript("1.3.3/services/SQOOP/package/scripts/service_check.py",
+                         classname = "SqoopServiceCheck",
+                         command = "service_check",
+                         config_file="default.json")
+    self.assertResourceCalled('Execute', 'sqoop version',
+                              logoutput = True,
+                              user = 'ambari-qa',)
+    self.assertNoMoreResources()
+
+
+
+

+ 52 - 0
ambari-server/src/test/python/stacks/1.3.3/SQOOP/test_sqoop.py

@@ -0,0 +1,52 @@
+#!/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 TestSqoop(RMFTestCase):
+
+  def test_configure_default(self):
+    self.executeScript("1.3.3/services/SQOOP/package/scripts/sqoop_client.py",
+                       classname = "SqoopClient",
+                       command = "configure",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Link', '/usr/lib/sqoop/lib/mysql-connector-java.jar',
+                              to = '/usr/share/java/mysql-connector-java.jar',)
+    self.assertResourceCalled('Directory', '/usr/lib/sqoop/conf',
+                              owner = 'sqoop',
+                              group = 'hadoop',)
+    self.assertResourceCalled('TemplateConfig', '/usr/lib/sqoop/conf/sqoop-env.sh',
+                              owner = 'sqoop',
+                              template_tag = None,)
+    self.assertResourceCalled('File', '/usr/lib/sqoop/conf/sqoop-env-template.sh',
+                              owner = 'sqoop',
+                              group = 'hadoop',)
+    self.assertResourceCalled('File', '/usr/lib/sqoop/conf/sqoop-site-template.xml',
+                              owner = 'sqoop',
+                              group = 'hadoop',)
+    self.assertResourceCalled('File', '/usr/lib/sqoop/conf/sqoop-site.xml',
+                              owner = 'sqoop',
+                              group = 'hadoop',)
+    self.assertNoMoreResources()
+
+
+
+

+ 78 - 0
ambari-server/src/test/python/stacks/1.3.3/hooks/before-INSTALL/test_before_install.py

@@ -0,0 +1,78 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+
+class TestHookBeforeInstall(RMFTestCase):
+  def test_hook_default(self):
+    self.executeScript("1.3.3/hooks/before-INSTALL/scripts/hook.py",
+                       classname="BeforeConfigureHook",
+                       command="hook",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Group', 'hadoop',)
+    self.assertResourceCalled('Group', 'users',)
+    self.assertResourceCalled('Group', 'users',)
+    self.assertResourceCalled('User', 'ambari-qa',
+                              gid='hadoop',
+                              groups=[u'users'],)
+    self.assertResourceCalled('File', '/tmp/changeUid.sh',
+                              content=StaticFile('changeToSecureUid.sh'),
+                              mode=0555,)
+    self.assertResourceCalled('Execute',
+                              '/tmp/changeUid.sh ambari-qa /tmp/hadoop-ambari-qa,/tmp/hsperfdata_ambari-qa,/home/ambari-qa,/tmp/ambari-qa,/tmp/sqoop-ambari-qa 2>/dev/null',
+                              not_if='test $(id -u ambari-qa) -gt 1000',)
+    self.assertResourceCalled('User', 'hbase',
+                              gid='hadoop',
+                              groups=[u'hadoop'],)
+    self.assertResourceCalled('File', '/tmp/changeUid.sh',
+                              content=StaticFile('changeToSecureUid.sh'),
+                              mode=0555,)
+    self.assertResourceCalled('Execute',
+                              '/tmp/changeUid.sh hbase /home/hbase,/tmp/hbase,/usr/bin/hbase,/var/log/hbase,/hadoop/hbase 2>/dev/null',
+                              not_if='test $(id -u hbase) -gt 1000',)
+    self.assertResourceCalled('Group', 'nagios',)
+    self.assertResourceCalled('User', 'nagios', gid='nagios',)
+    self.assertResourceCalled('User', 'oozie', gid='hadoop',)
+    self.assertResourceCalled('User', 'hcat', gid='hadoop',)
+    self.assertResourceCalled('User', 'hcat', gid='hadoop',)
+    self.assertResourceCalled('User', 'hive',
+                              gid='hadoop',)
+    self.assertResourceCalled('Group', 'nobody',)
+    self.assertResourceCalled('Group', 'nobody',)
+    self.assertResourceCalled('User', 'nobody',
+                              gid='hadoop',
+                              groups=[u'nobody'],)
+    self.assertResourceCalled('User', 'nobody',
+                              gid='hadoop',
+                              groups=[u'nobody'],)
+    self.assertResourceCalled('User', 'hdfs',
+                              gid='hadoop',
+                              groups=[u'hadoop'],)
+    self.assertResourceCalled('User', 'mapred',
+                              gid='hadoop',
+                              groups=[u'hadoop'],)
+    self.assertResourceCalled('User', 'zookeeper',
+                              gid='hadoop',)
+    self.assertResourceCalled('Package', 'unzip',)
+    self.assertResourceCalled('Package', 'net-snmp',)
+    self.assertResourceCalled('Package', 'net-snmp-utils',)
+    self.assertNoMoreResources()

+ 150 - 0
ambari-server/src/test/python/stacks/1.3.3/hooks/before-START/test_before_start.py

@@ -0,0 +1,150 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+class TestHookBeforeStart(RMFTestCase):
+  def test_hook_default(self):
+    self.executeScript("1.3.3/hooks/before-START/scripts/hook.py",
+                       classname="BeforeConfigureHook",
+                       command="hook",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'mkdir -p /tmp/HDP-artifacts/ ; curl -kf --retry 10 http://c6401.ambari.apache.org:8080/resources//jdk-7u45-linux-x64.tar.gz -o /tmp/HDP-artifacts//jdk-7u45-linux-x64.tar.gz',
+                              not_if = 'test -e /usr/jdk64/jdk1.7.0_45/bin/java',
+                              path = ['/bin', '/usr/bin/'],
+                              )
+    self.assertResourceCalled('Execute', 'mkdir -p /usr/jdk64 ; cd /usr/jdk64 ; tar -xf /tmp/HDP-artifacts//jdk-7u45-linux-x64.tar.gz > /dev/null 2>&1',
+                              not_if = 'test -e /usr/jdk64/jdk1.7.0_45/bin/java',
+                              path = ['/bin', '/usr/bin/'],
+                              )
+    self.assertResourceCalled('Execute', 'mkdir -p /tmp/HDP-artifacts/; curl -kf --retry 10 http://c6401.ambari.apache.org:8080/resources//UnlimitedJCEPolicyJDK7.zip -o /tmp/HDP-artifacts//UnlimitedJCEPolicyJDK7.zip',
+                              not_if = 'test -e /tmp/HDP-artifacts//UnlimitedJCEPolicyJDK7.zip',
+                              ignore_failures = True,
+                              path = ['/bin', '/usr/bin/'],
+                              )
+    self.assertResourceCalled('File', '/etc/snmp/snmpd.conf',
+                              content = Template('snmpd.conf.j2'),
+                              )
+    self.assertResourceCalled('Service', 'snmpd',
+                              action = ['restart'],
+                              )
+    self.assertResourceCalled('Execute', '/bin/echo 0 > /selinux/enforce',
+                              only_if = 'test -f /selinux/enforce',
+                              )
+    self.assertResourceCalled('Execute', 'mkdir -p /usr/lib/hadoop/lib/native/Linux-i386-32; ln -sf /usr/lib/libsnappy.so /usr/lib/hadoop/lib/native/Linux-i386-32/libsnappy.so',
+                              )
+    self.assertResourceCalled('Execute', 'mkdir -p /usr/lib/hadoop/lib/native/Linux-amd64-64; ln -sf /usr/lib64/libsnappy.so /usr/lib/hadoop/lib/native/Linux-amd64-64/libsnappy.so',
+                              )
+    self.assertResourceCalled('Directory', '/etc/hadoop/conf',
+                              owner = 'root',
+                              group = 'root',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('Directory', '/var/log/hadoop',
+                              owner = 'root',
+                              group = 'root',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('Directory', '/var/run/hadoop',
+                              owner = 'root',
+                              group = 'root',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('File', '/etc/security/limits.d/hdfs.conf',
+                              content = Template('hdfs.conf.j2'),
+                              owner = 'root',
+                              group = 'root',
+                              mode = 0644,
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/taskcontroller.cfg',
+                              content = Template('taskcontroller.cfg.j2'),
+                              owner = 'hdfs',
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/hadoop-env.sh',
+                              content = Template('hadoop-env.sh.j2'),
+                              owner = 'hdfs',
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/commons-logging.properties',
+                              content = Template('commons-logging.properties.j2'),
+                              owner = 'hdfs',
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/slaves',
+                              content = Template('slaves.j2'),
+                              owner = 'hdfs',
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/health_check',
+                              content = Template('health_check.j2'),
+                              owner = 'hdfs',
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?ambari.jobhistory.driver=.*~ambari.jobhistory.driver=org.postgresql.Driver~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.appender.JHA=.*~log4j.appender.JHA=org.apache.ambari.log4j.hadoop.mapreduce.jobhistory.JobHistoryAppender~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.appender.JHA.driver=.*~log4j.appender.JHA.driver=${ambari.jobhistory.driver}~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.appender.JHA.database=.*~log4j.appender.JHA.database=${ambari.jobhistory.database}~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?ambari.jobhistory.logger=.*~ambari.jobhistory.logger=DEBUG,JHA~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.appender.JHA.password=.*~log4j.appender.JHA.password=${ambari.jobhistory.password}~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?ambari.jobhistory.database=.*~ambari.jobhistory.database=jdbc:postgresql://c6401.ambari.apache.org/ambarirca~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.additivity.org.apache.hadoop.mapred.JobHistory$JobHistoryLogger=.*~log4j.additivity.org.apache.hadoop.mapred.JobHistory$JobHistoryLogger=true~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.logger.org.apache.hadoop.mapred.JobHistory$JobHistoryLogger=.*~log4j.logger.org.apache.hadoop.mapred.JobHistory$JobHistoryLogger=${ambari.jobhistory.logger}~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.appender.JHA.user=.*~log4j.appender.JHA.user=${ambari.jobhistory.user}~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?ambari.jobhistory.user=.*~ambari.jobhistory.user=mapred~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?ambari.jobhistory.password=.*~ambari.jobhistory.password=mapred~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/hadoop-metrics2.properties',
+                              content = Template('hadoop-metrics2.properties.j2'),
+                              owner = 'hdfs',
+                              )
+    self.assertResourceCalled('XmlConfig', 'core-site.xml',
+                              owner = 'hdfs',
+                              group = 'hadoop',
+                              conf_dir = '/etc/hadoop/conf',
+                              configurations = self.getConfig()['configurations']['core-site'],
+                              )
+    self.assertResourceCalled('XmlConfig', 'mapred-site.xml',
+                              owner = 'mapred',
+                              group = 'hadoop',
+                              conf_dir = '/etc/hadoop/conf',
+                              configurations = self.getConfig()['configurations']['mapred-site'],
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/task-log4j.properties',
+                              content = StaticFile('task-log4j.properties'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('XmlConfig', 'hdfs-site.xml',
+                              owner = 'hdfs',
+                              group = 'hadoop',
+                              conf_dir = '/etc/hadoop/conf',
+                              configurations = self.getConfig()['configurations']['hdfs-site'],
+                              )
+    self.assertResourceCalled('Link', '/usr/lib/hadoop/lib/hadoop-tools.jar',
+                              to = '/usr/lib/hadoop/hadoop-tools.jar',
+                              )
+    self.assertNoMoreResources()

+ 38 - 0
ambari-server/src/test/python/stacks/2.1.1/FALCON/test_falcon_client.py

@@ -0,0 +1,38 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+
+class TestFalconClient(RMFTestCase):
+  def test_configure_default(self):
+    self.executeScript("2.1.1/services/FALCON/package/scripts/falcon_client.py",
+                       classname="FalconClient",
+                       command="configure",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute',
+                              'cd /tmp; rm -f falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm; wget http://public-repo-1.hortonworks.com/HDP-LABS/Projects/Falcon/2.0.6.0-76/rpm/falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm; rpm -Uvh --nodeps falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm',
+                              not_if='yum list installed | grep falcon', )
+
+    self.assertResourceCalled('File', '/etc/falcon/conf/client.properties',
+                              content=Template('client.properties.j2'),
+                              mode=0644, )
+    self.assertNoMoreResources()

+ 94 - 0
ambari-server/src/test/python/stacks/2.1.1/FALCON/test_falcon_server.py

@@ -0,0 +1,94 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+
+class TestFalconServer(RMFTestCase):
+
+  def test_start_default(self):
+    self.executeScript("2.1.1/services/FALCON/package/scripts/falcon_server.py",
+                       classname="FalconServer",
+                       command="start",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute',
+                              'cd /tmp; rm -f falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm; wget http://public-repo-1.hortonworks.com/HDP-LABS/Projects/Falcon/2.0.6.0-76/rpm/falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm; rpm -Uvh --nodeps falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm',
+                              not_if='yum list installed | grep falcon', )
+    self.assertResourceCalled('Directory',
+                              '/hadoop/falcon',
+                              owner='falcon',
+                              recursive=True, )
+    self.assertResourceCalled('Directory', '/hadoop/falcon/activemq',
+                              owner='falcon',
+                              recursive=True, )
+    self.assertResourceCalled('File', '/etc/falcon/conf/runtime.properties',
+                              content=Template('runtime.properties.j2'),
+                              mode=0644, )
+    self.assertResourceCalled('File', '/etc/falcon/conf/startup.properties',
+                              content=Template('startup.properties.j2'),
+                              mode=0644, )
+    self.assertResourceCalled('Execute',
+                              'cd /tmp; rm -f falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm; wget http://public-repo-1.hortonworks.com/HDP-LABS/Projects/Falcon/2.0.6.0-76/rpm/falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm; rpm -Uvh --nodeps falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm',
+                              not_if='yum list installed | grep falcon', )
+    self.assertResourceCalled('Execute',
+                              'env JAVA_HOME=/usr/jdk64/jdk1.7.0_45 FALCON_LOG_DIR=/var/log/falcon FALCON_PID_DIR=/var/run/falcon FALCON_DATA_DIR=/hadoop/falcon/activemq /usr/lib/falcon/bin/falcon-start -port 15000',
+                              user='falcon', )
+    self.assertNoMoreResources()
+
+  def test_stop_default(self):
+    self.executeScript("2.1.1/services/FALCON/package/scripts/falcon_server.py",
+                       classname="FalconServer",
+                       command="stop",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute',
+                          'cd /tmp; rm -f falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm; wget http://public-repo-1.hortonworks.com/HDP-LABS/Projects/Falcon/2.0.6.0-76/rpm/falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm; rpm -Uvh --nodeps falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm',
+                          not_if='yum list installed | grep falcon', )
+    self.assertResourceCalled('Execute',
+                          'env JAVA_HOME=/usr/jdk64/jdk1.7.0_45 FALCON_LOG_DIR=/var/log/falcon FALCON_PID_DIR=/var/run/falcon FALCON_DATA_DIR=/hadoop/falcon/activemq /usr/lib/falcon/bin/falcon-stop',
+                          user='falcon', )
+    self.assertNoMoreResources()
+
+  def test_configure_default(self):
+    self.executeScript("2.1.1/services/FALCON/package/scripts/falcon_server.py",
+                       classname="FalconServer",
+                       command="configure",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute',
+                              'cd /tmp; rm -f falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm; wget http://public-repo-1.hortonworks.com/HDP-LABS/Projects/Falcon/2.0.6.0-76/rpm/falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm; rpm -Uvh --nodeps falcon-0.4.0.2.0.6.0-76.el6.noarch.rpm',
+                              not_if='yum list installed | grep falcon', )
+    self.assertResourceCalled('Directory',
+                              '/hadoop/falcon',
+                              owner='falcon',
+                              recursive=True, )
+    self.assertResourceCalled('Directory', '/hadoop/falcon/activemq',
+                              owner='falcon',
+                              recursive=True, )
+    self.assertResourceCalled('File', '/etc/falcon/conf/runtime.properties',
+                              content=Template('runtime.properties.j2'),
+                              mode=0644, )
+    self.assertResourceCalled('File', '/etc/falcon/conf/startup.properties',
+                              content=Template('startup.properties.j2'),
+                              mode=0644, )
+    self.assertNoMoreResources()
+
+

+ 42 - 0
ambari-server/src/test/python/stacks/2.1.1/FALCON/test_service_check.py

@@ -0,0 +1,42 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+
+class TestFalconServer(RMFTestCase):
+
+  def test_service_check(self):
+    self.executeScript("2.1.1/services/FALCON/package/scripts/service_check.py",
+                       classname="FalconServiceCheck",
+                       command="service_check",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'env '
+                                         'JAVA_HOME=/usr/jdk64/jdk1.7.0_45 FALCON_LOG_DIR=/var/log/falcon '
+                                         'FALCON_PID_DIR=/var/run/falcon '
+                                         'FALCON_DATA_DIR=/hadoop/falcon/activemq '
+                                         '/usr/lib/falcon/bin/falcon admin -version',
+                              logoutput = True,
+                              tries = 3,
+                              user = 'ambari-qa',
+                              try_sleep = 20,)
+    self.assertNoMoreResources()
+

+ 169 - 0
ambari-server/src/test/python/stacks/2.1.1/GANGLIA/test_ganglia_monitor.py

@@ -0,0 +1,169 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+
+class TestGangliaMonitor(RMFTestCase):
+
+  def test_configure_default(self):
+    self.executeScript("2.1.1/services/GANGLIA/package/scripts/ganglia_monitor.py",
+                       classname="GangliaMonitor",
+                       command="configure",
+                       config_file="default.json"
+                      )
+    self.assertResourceCalled('Directory', '/etc/ganglia/hdp',
+                              owner = 'root',
+                              group = 'hadoop',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('Directory', '/usr/libexec/hdp/ganglia',
+                              owner = 'root',
+                              group = 'root',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('File', '/etc/init.d/hdp-gmetad',
+                              content = StaticFile('gmetad.init'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/etc/init.d/hdp-gmond',
+                              content = StaticFile('gmond.init'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/checkGmond.sh',
+                              content = StaticFile('checkGmond.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/checkRrdcached.sh',
+                              content = StaticFile('checkRrdcached.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/gmetadLib.sh',
+                              content = StaticFile('gmetadLib.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/gmondLib.sh',
+                              content = StaticFile('gmondLib.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/rrdcachedLib.sh',
+                              content = StaticFile('rrdcachedLib.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/setupGanglia.sh',
+                              content = StaticFile('setupGanglia.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/startGmetad.sh',
+                              content = StaticFile('startGmetad.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/startGmond.sh',
+                              content = StaticFile('startGmond.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/startRrdcached.sh',
+                              content = StaticFile('startRrdcached.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/stopGmetad.sh',
+                              content = StaticFile('stopGmetad.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/stopGmond.sh',
+                              content = StaticFile('stopGmond.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/stopRrdcached.sh',
+                              content = StaticFile('stopRrdcached.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/teardownGanglia.sh',
+                              content = StaticFile('teardownGanglia.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('TemplateConfig', '/usr/libexec/hdp/ganglia/gangliaClusters.conf',
+                              owner = 'root',
+                              template_tag = None,
+                              group = 'root',
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('TemplateConfig', '/usr/libexec/hdp/ganglia/gangliaEnv.sh',
+                              owner = 'root',
+                              template_tag = None,
+                              group = 'root',
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('TemplateConfig', '/usr/libexec/hdp/ganglia/gangliaLib.sh',
+                              owner = 'root',
+                              template_tag = None,
+                              group = 'root',
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPNameNode -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Directory', '/etc/ganglia/conf.d',
+                              owner = 'root',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/ganglia/conf.d/modgstatus.conf',
+                              owner = 'root',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/ganglia/conf.d/multicpu.conf',
+                              owner = 'root',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('File', '/etc/ganglia/gmond.conf',
+                              owner = 'root',
+                              group = 'hadoop',
+                              )
+    self.assertNoMoreResources()
+
+  def test_start_default(self):
+    self.executeScript("2.1.1/services/GANGLIA/package/scripts/ganglia_monitor.py",
+                       classname="GangliaMonitor",
+                       command="start",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'chkconfig gmond off',
+                              path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', 'service hdp-gmond start >> /tmp/gmond.log  2>&1 ; /bin/ps auwx | /bin/grep [g]mond  >> /tmp/gmond.log  2>&1',
+                              path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
+                              )
+    self.assertNoMoreResources()
+
+  def test_stop_default(self):
+    self.executeScript("2.1.1/services/GANGLIA/package/scripts/ganglia_monitor.py",
+                       classname="GangliaMonitor",
+                       command="stop",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'service hdp-gmond stop >> /tmp/gmond.log  2>&1 ; /bin/ps auwx | /bin/grep [g]mond  >> /tmp/gmond.log  2>&1',
+                              path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
+                              )
+    self.assertNoMoreResources()
+

+ 214 - 0
ambari-server/src/test/python/stacks/2.1.1/GANGLIA/test_ganglia_server.py

@@ -0,0 +1,214 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+
+class TestGangliaServer(RMFTestCase):
+
+  def test_configure_default(self):
+    self.executeScript("2.1.1/services/GANGLIA/package/scripts/ganglia_server.py",
+                       classname="GangliaServer",
+                       command="configure",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Directory', '/usr/libexec/hdp/ganglia',
+                              owner = 'root',
+                              group = 'root',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('File', '/etc/init.d/hdp-gmetad',
+                              content = StaticFile('gmetad.init'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/etc/init.d/hdp-gmond',
+                              content = StaticFile('gmond.init'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/checkGmond.sh',
+                              content = StaticFile('checkGmond.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/checkRrdcached.sh',
+                              content = StaticFile('checkRrdcached.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/gmetadLib.sh',
+                              content = StaticFile('gmetadLib.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/gmondLib.sh',
+                              content = StaticFile('gmondLib.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/rrdcachedLib.sh',
+                              content = StaticFile('rrdcachedLib.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/setupGanglia.sh',
+                              content = StaticFile('setupGanglia.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/startGmetad.sh',
+                              content = StaticFile('startGmetad.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/startGmond.sh',
+                              content = StaticFile('startGmond.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/startRrdcached.sh',
+                              content = StaticFile('startRrdcached.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/stopGmetad.sh',
+                              content = StaticFile('stopGmetad.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/stopGmond.sh',
+                              content = StaticFile('stopGmond.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/stopRrdcached.sh',
+                              content = StaticFile('stopRrdcached.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/usr/libexec/hdp/ganglia/teardownGanglia.sh',
+                              content = StaticFile('teardownGanglia.sh'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('TemplateConfig', '/usr/libexec/hdp/ganglia/gangliaClusters.conf',
+                              owner = 'root',
+                              template_tag = None,
+                              group = 'root',
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('TemplateConfig', '/usr/libexec/hdp/ganglia/gangliaEnv.sh',
+                              owner = 'root',
+                              template_tag = None,
+                              group = 'root',
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('TemplateConfig', '/usr/libexec/hdp/ganglia/gangliaLib.sh',
+                              owner = 'root',
+                              template_tag = None,
+                              group = 'root',
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPNameNode -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPHBaseMaster -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPResourceManager -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPNodeManager -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPHistoryServer -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPDataNode -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -c HDPHBaseRegionServer -m -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Execute', '/usr/libexec/hdp/ganglia/setupGanglia.sh -t -o root -g hadoop',
+                              path = ['/usr/libexec/hdp/ganglia',
+                                      '/usr/sbin',
+                                      '/sbin:/usr/local/bin',
+                                      '/bin',
+                                      '/usr/bin'],
+                              )
+    self.assertResourceCalled('Directory', '/var/lib/ganglia/dwoo',
+                              owner = 'nobody',
+                              recursive = True,
+                              mode = 0777,
+                              )
+    self.assertResourceCalled('Directory', '/srv/www/cgi-bin',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('File', '/srv/www/cgi-bin/rrd.py',
+                              content = StaticFile('rrd.py'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('File', '/etc/ganglia/gmetad.conf',
+                              owner = 'root',
+                              group = 'hadoop',
+                              )
+    self.assertNoMoreResources()
+
+  def test_start_default(self):
+    self.executeScript("2.1.1/services/GANGLIA/package/scripts/ganglia_server.py",
+                       classname="GangliaServer",
+                       command="start",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'service hdp-gmetad start >> /tmp/gmetad.log  2>&1 ; /bin/ps auwx | /bin/grep [g]metad  >> /tmp/gmetad.log  2>&1',
+                              path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
+                              )
+    self.assertResourceCalled('MonitorWebserver', 'restart',
+                              )
+    self.assertNoMoreResources()
+
+  def test_stop_default(self):
+    self.executeScript("2.1.1/services/GANGLIA/package/scripts/ganglia_server.py",
+                       classname="GangliaServer",
+                       command="stop",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'service hdp-gmetad stop >> /tmp/gmetad.log  2>&1 ; /bin/ps auwx | /bin/grep [g]metad  >> /tmp/gmetad.log  2>&1',
+                              path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
+                              )
+    self.assertResourceCalled('MonitorWebserver', 'restart',
+                              )
+    self.assertNoMoreResources()
+

+ 50 - 0
ambari-server/src/test/python/stacks/2.1.1/SQOOP/test_service_check.py

@@ -0,0 +1,50 @@
+#!/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 TestSqoopServiceCheck(RMFTestCase):
+
+  def test_service_check_secured(self):
+    self.executeScript("2.1.1/services/SQOOP/package/scripts/service_check.py",
+                       classname = "SqoopServiceCheck",
+                       command = "service_check",
+                       config_file="secured.json"
+    )
+    self.assertResourceCalled('Execute', '/usr/bin/kinit  -kt /etc/security/keytabs/smokeuser.headless.keytab ambari-qa',)
+    self.assertResourceCalled('Execute', 'sqoop version',
+                              logoutput = True,
+                              user = 'ambari-qa',)
+    self.assertNoMoreResources()
+
+  def test_service_check_default(self):
+    self.executeScript("2.1.1/services/SQOOP/package/scripts/service_check.py",
+                       classname = "SqoopServiceCheck",
+                       command = "service_check",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'sqoop version',
+                              logoutput = True,
+                              user = 'ambari-qa',)
+    self.assertNoMoreResources()
+
+
+
+

+ 52 - 0
ambari-server/src/test/python/stacks/2.1.1/SQOOP/test_sqoop.py

@@ -0,0 +1,52 @@
+#!/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 TestSqoop(RMFTestCase):
+
+  def test_configure_default(self):
+    self.executeScript("1.3.3/services/SQOOP/package/scripts/sqoop_client.py",
+                       classname = "SqoopClient",
+                       command = "configure",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Link', '/usr/lib/sqoop/lib/mysql-connector-java.jar',
+                              to = '/usr/share/java/mysql-connector-java.jar',)
+    self.assertResourceCalled('Directory', '/usr/lib/sqoop/conf',
+                              owner = 'sqoop',
+                              group = 'hadoop',)
+    self.assertResourceCalled('TemplateConfig', '/usr/lib/sqoop/conf/sqoop-env.sh',
+                              owner = 'sqoop',
+                              template_tag = None,)
+    self.assertResourceCalled('File', '/usr/lib/sqoop/conf/sqoop-env-template.sh',
+                              owner = 'sqoop',
+                              group = 'hadoop',)
+    self.assertResourceCalled('File', '/usr/lib/sqoop/conf/sqoop-site-template.xml',
+                              owner = 'sqoop',
+                              group = 'hadoop',)
+    self.assertResourceCalled('File', '/usr/lib/sqoop/conf/sqoop-site.xml',
+                              owner = 'sqoop',
+                              group = 'hadoop',)
+    self.assertNoMoreResources()
+
+
+
+

+ 12 - 3
ambari-server/src/test/python/stacks/2.1.1/configs/default.json

@@ -12,7 +12,8 @@
         "ambari_db_rca_driver": "org.postgresql.Driver", 
         "jdk_name": "jdk-7u45-linux-x64.tar.gz", 
         "ambari_db_rca_username": "mapred", 
-        "java_home": "/usr/jdk64/jdk1.7.0_45"
+        "java_home": "/usr/jdk64/jdk1.7.0_45",
+        "db_name": "ambari"
     }, 
     "commandType": "EXECUTION_COMMAND", 
     "roleParams": {}, 
@@ -285,7 +286,12 @@
             "hadoop_heapsize": "1024", 
             "hadoop_pid_dir_prefix": "/var/run/hadoop", 
             "nagios_user": "nagios", 
-            "hbase_log_dir": "/var/log/hbase"
+            "hbase_log_dir": "/var/log/hbase",
+            "falcon_user": "falcon",
+            "falcon_port": "15000",
+            "falcon_local_dir": "/hadoop/falcon",
+            "falcon_store_uri": "file:///hadoop/falcon/store",
+            "rca_enabled": "false"
         }, 
         "capacity-scheduler": {
             "yarn.scheduler.capacity.node-locality-delay": "40", 
@@ -540,7 +546,7 @@
         ], 
         "logviewer_server_hosts": [
             "c6402.ambari.apache.org"
-        ], 
+        ],
         "hive_metastore_hosts": [
             "c6402.ambari.apache.org"
         ], 
@@ -596,6 +602,9 @@
         ], 
         "hive_mysql_host": [
             "c6402.ambari.apache.org"
+        ],
+        "falcon_server_hosts": [
+            "c6402.ambari.apache.org"
         ]
     }
 }

+ 11 - 2
ambari-server/src/test/python/stacks/2.1.1/configs/secured.json

@@ -17,7 +17,8 @@
         "jdk_name": "jdk-7u45-linux-x64.tar.gz", 
         "ambari_db_rca_username": "mapred", 
         "java_home": "/usr/jdk64/jdk1.7.0_45", 
-        "mysql_jdbc_url": "http://c6401.ambari.apache.org:8080/resources//mysql-connector-java.jar"
+        "mysql_jdbc_url": "http://c6401.ambari.apache.org:8080/resources//mysql-connector-java.jar",
+        "db_name": "ambari"
     }, 
     "commandType": "EXECUTION_COMMAND", 
     "roleParams": {}, 
@@ -382,7 +383,12 @@
             "resourcemanager_heapsize": "1024", 
             "hbase_regionserver_keytab": "/etc/security/keytabs/hbase.service.keytab", 
             "hbase_principal_name": "hbase", 
-            "hdfs_principal_name": "hdfs"
+            "hdfs_principal_name": "hdfs",
+            "falcon_user": "falcon",
+            "falcon_port": "15000",
+            "falcon_local_dir": "/hadoop/falcon",
+            "falcon_store_uri": "file:///hadoop/falcon/store",
+            "rca_enabled": "false"
         }, 
         "capacity-scheduler": {
             "yarn.scheduler.capacity.node-locality-delay": "40", 
@@ -723,6 +729,9 @@
         ], 
         "hive_mysql_host": [
             "c6402.ambari.apache.org"
+        ],
+        "falcon_server_hosts": [
+            "c6402.ambari.apache.org"
         ]
     }
 }

+ 87 - 0
ambari-server/src/test/python/stacks/2.1.1/hooks/before-INSTALL/test_before_install.py

@@ -0,0 +1,87 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+
+class TestHookBeforeInstall(RMFTestCase):
+  def test_configure_default(self):
+    self.executeScript("2.1.1/hooks/before-INSTALL/scripts/hook.py",
+                       classname="BeforeConfigureHook",
+                       command="hook",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Group', 'hadoop', )
+    self.assertResourceCalled('Group', 'users', )
+    self.assertResourceCalled('Group', 'users', )
+    self.assertResourceCalled('User', 'ambari-qa',
+                          gid='hadoop',
+                          groups=['users'], )
+    self.assertResourceCalled('File', '/tmp/changeUid.sh',
+                          content=StaticFile('changeToSecureUid.sh'),
+                          mode=0555, )
+    self.assertResourceCalled('Execute',
+                          '/tmp/changeUid.sh ambari-qa /tmp/hadoop-ambari-qa,/tmp/hsperfdata_ambari-qa,/home/ambari-qa,/tmp/ambari-qa,/tmp/sqoop-ambari-qa 2>/dev/null',
+                          not_if='test $(id -u ambari-qa) -gt 1000', )
+    self.assertResourceCalled('User', 'hbase',
+                          gid='hadoop',
+                          groups=['hadoop'], )
+    self.assertResourceCalled('File', '/tmp/changeUid.sh',
+                          content=StaticFile('changeToSecureUid.sh'),
+                          mode=0555, )
+    self.assertResourceCalled('Execute',
+                          '/tmp/changeUid.sh hbase /home/hbase,/tmp/hbase,/usr/bin/hbase,/var/log/hbase,/hadoop/hbase 2>/dev/null',
+                          not_if='test $(id -u hbase) -gt 1000', )
+    self.assertResourceCalled('Group', 'nagios', )
+    self.assertResourceCalled('User', 'nagios',
+                          gid='nagios', )
+    self.assertResourceCalled('User', 'oozie',
+                          gid='hadoop', )
+    self.assertResourceCalled('User', 'hcat',
+                          gid='hadoop', )
+    self.assertResourceCalled('User', 'hcat',
+                          gid='hadoop', )
+    self.assertResourceCalled('User', 'hive',
+                          gid='hadoop', )
+    self.assertResourceCalled('User', 'yarn',
+                          gid='hadoop', )
+    self.assertResourceCalled('Group', 'nobody', )
+    self.assertResourceCalled('Group', 'nobody', )
+    self.assertResourceCalled('User', 'nobody',
+                          gid='hadoop',
+                          groups=['nobody'], )
+    self.assertResourceCalled('User', 'nobody',
+                          gid='hadoop',
+                          groups=['nobody'], )
+    self.assertResourceCalled('User', 'hdfs',
+                          gid='hadoop',
+                          groups=['hadoop'], )
+    self.assertResourceCalled('User', 'mapred',
+                          gid='hadoop',
+                          groups=['hadoop'], )
+    self.assertResourceCalled('User', 'zookeeper',
+                          gid='hadoop', )
+    self.assertResourceCalled('User', 'storm',
+                          gid='hadoop',
+                          groups=['hadoop'], )
+    self.assertResourceCalled('Package', 'unzip', )
+    self.assertResourceCalled('Package', 'net-snmp', )
+    self.assertResourceCalled('Package', 'net-snmp-utils', )
+    self.assertNoMoreResources()

+ 157 - 0
ambari-server/src/test/python/stacks/2.1.1/hooks/before-START/test_before_start.py

@@ -0,0 +1,157 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+class TestHookBeforeStart(RMFTestCase):
+  def test_configure_default(self):
+    self.executeScript("2.1.1/hooks/before-START/scripts/hook.py",
+                       classname="BeforeConfigureHook",
+                       command="hook",
+                       config_file="default.json"
+    )
+    self.assertResourceCalled('Execute', 'mkdir -p /tmp/HDP-artifacts/ ; curl -kf --retry 10 http://c6401.ambari.apache.org:8080/resources//jdk-7u45-linux-x64.tar.gz -o /tmp/HDP-artifacts//jdk-7u45-linux-x64.tar.gz',
+                              not_if = 'test -e /usr/jdk64/jdk1.7.0_45/bin/java',
+                              path = ['/bin', '/usr/bin/'],
+                              )
+    self.assertResourceCalled('Execute', 'mkdir -p /usr/jdk64 ; cd /usr/jdk64 ; tar -xf /tmp/HDP-artifacts//jdk-7u45-linux-x64.tar.gz > /dev/null 2>&1',
+                              not_if = 'test -e /usr/jdk64/jdk1.7.0_45/bin/java',
+                              path = ['/bin', '/usr/bin/'],
+                              )
+    self.assertResourceCalled('Execute', 'mkdir -p /tmp/HDP-artifacts/; curl -kf --retry 10 http://c6401.ambari.apache.org:8080/resources//UnlimitedJCEPolicyJDK7.zip -o /tmp/HDP-artifacts//UnlimitedJCEPolicyJDK7.zip',
+                              not_if = 'test -e /tmp/HDP-artifacts//UnlimitedJCEPolicyJDK7.zip',
+                              ignore_failures = True,
+                              path = ['/bin', '/usr/bin/'],
+                              )
+    self.assertResourceCalled('File', '/etc/snmp/snmpd.conf',
+                              content = Template('snmpd.conf.j2'),
+                              )
+    self.assertResourceCalled('Service', 'snmpd',
+                              action = ['restart'],
+                              )
+    self.assertResourceCalled('Execute', '/bin/echo 0 > /selinux/enforce',
+                              only_if = 'test -f /selinux/enforce',
+                              )
+    self.assertResourceCalled('Execute', 'mkdir -p /usr/lib/hadoop/lib/native/Linux-i386-32; ln -sf /usr/lib/libsnappy.so /usr/lib/hadoop/lib/native/Linux-i386-32/libsnappy.so',
+                              )
+    self.assertResourceCalled('Execute', 'mkdir -p /usr/lib/hadoop/lib/native/Linux-amd64-64; ln -sf /usr/lib64/libsnappy.so /usr/lib/hadoop/lib/native/Linux-amd64-64/libsnappy.so',
+                              )
+    self.assertResourceCalled('Directory', '/etc/hadoop/conf',
+                              owner = 'root',
+                              group = 'root',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('Directory', '/var/log/hadoop',
+                              owner = 'root',
+                              group = 'root',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('Directory', '/var/run/hadoop',
+                              owner = 'root',
+                              group = 'root',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('Directory', '/tmp',
+                              owner = 'hdfs',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('File', '/etc/security/limits.d/hdfs.conf',
+                              content = Template('hdfs.conf.j2'),
+                              owner = 'root',
+                              group = 'root',
+                              mode = 0644,
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/taskcontroller.cfg',
+                              content = Template('taskcontroller.cfg.j2'),
+                              owner = 'hdfs',
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/hadoop-env.sh',
+                              content = Template('hadoop-env.sh.j2'),
+                              owner = 'hdfs',
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/commons-logging.properties',
+                              content = Template('commons-logging.properties.j2'),
+                              owner = 'hdfs',
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/slaves',
+                              content = Template('slaves.j2'),
+                              owner = 'hdfs',
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/health_check',
+                              content = Template('health_check-v2.j2'),
+                              owner = 'hdfs',
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?ambari.jobhistory.driver=.*~###ambari.jobhistory.driver=o~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.appender.JHA=.*~###log4j.appender.JHA=org.apache.ambari.log4j.hadoop.mapreduce.jobhistory.JobHistoryAppender~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.appender.JHA.driver=.*~###log4j.appender.JHA.driver=${ambari.jobhistory.driver}~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.appender.JHA.database=.*~###log4j.appender.JHA.database=${ambari.jobhistory.database}~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?ambari.jobhistory.logger=.*~###ambari.jobhistory.logger=DEBUG,JHA~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.appender.JHA.password=.*~###log4j.appender.JHA.password=${ambari.jobhistory.password}~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?ambari.jobhistory.database=.*~###ambari.jobhistory.database=j~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.additivity.org.apache.hadoop.mapred.JobHistory$JobHistoryLogger=.*~###log4j.additivity.org.apache.hadoop.mapred.JobHistory$JobHistoryLogger=true~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.logger.org.apache.hadoop.mapred.JobHistory$JobHistoryLogger=.*~###log4j.logger.org.apache.hadoop.mapred.JobHistory$JobHistoryLogger=${ambari.jobhistory.logger}~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?log4j.appender.JHA.user=.*~###log4j.appender.JHA.user=${ambari.jobhistory.user}~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?ambari.jobhistory.user=.*~###ambari.jobhistory.user=m~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('Execute', "sed -i 's~\\(###\\)\\?ambari.jobhistory.password=.*~###ambari.jobhistory.password=m~' /etc/hadoop/conf/log4j.properties",
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/hadoop-metrics2.properties',
+                              content = Template('hadoop-metrics2.properties.j2'),
+                              owner = 'hdfs',
+                              )
+    self.assertResourceCalled('XmlConfig', 'core-site.xml',
+                              owner = 'hdfs',
+                              group = 'hadoop',
+                              conf_dir = '/etc/hadoop/conf',
+                              configurations = self.getConfig()['configurations']['core-site'],
+                              )
+    self.assertResourceCalled('XmlConfig', 'mapred-site.xml',
+                              owner = 'mapred',
+                              group = 'hadoop',
+                              conf_dir = '/etc/hadoop/conf',
+                              configurations = self.getConfig()['configurations']['mapred-site'],
+                              )
+    self.assertResourceCalled('File', '/etc/hadoop/conf/task-log4j.properties',
+                              content = StaticFile('task-log4j.properties'),
+                              mode = 0755,
+                              )
+    self.assertResourceCalled('XmlConfig', 'capacity-scheduler.xml',
+                              owner = 'hdfs',
+                              group = 'hadoop',
+                              conf_dir = '/etc/hadoop/conf',
+                              configurations = self.getConfig()['configurations']['capacity-scheduler'],
+                              )
+    self.assertResourceCalled('XmlConfig', 'hdfs-site.xml',
+                              owner = 'hdfs',
+                              group = 'hadoop',
+                              conf_dir = '/etc/hadoop/conf',
+                              configurations = self.getConfig()['configurations']['hdfs-site'],
+                              )
+    self.assertNoMoreResources()

+ 3 - 2
ambari-server/src/test/python/stacks/utils/RMFTestCase.py

@@ -80,7 +80,8 @@ class RMFTestCase(TestCase):
         with patch.object(Script, 'get_config', return_value=self.config_dict): # mocking configurations
           with patch.object(Script, 'install_packages'):
             with patch('resource_management.libraries.functions.get_kinit_path', return_value=kinit_path_local):
-              method(RMFTestCase.env)
+              with patch.object(platform, 'linux_distribution', return_value=os_type):
+                method(RMFTestCase.env)
   
   def getConfig(self):
     return self.config_dict
@@ -107,7 +108,7 @@ class RMFTestCase(TestCase):
       return val[1:]
     
     return val
-  
+
   def printResources(self):
     for resource in RMFTestCase.env.resource_list:
       print "'{0}', {1},".format(resource.__class__.__name__, self._ppformat(resource.name))

+ 16 - 9
ambari-server/src/test/python/unitTests.py

@@ -114,12 +114,13 @@ def main():
   pwd = os.path.abspath(os.path.dirname(__file__))
 
   ambari_server_folder = get_parent_path(pwd,'ambari-server')
-  ambari_agent_folder = os.path.join(ambari_server_folder,os.path.normpath("../ambari-agent"))
-  ambari_common_folder = os.path.join(ambari_server_folder,os.path.normpath("../ambari-common"))
-  # append pythonpath (for running from IDE)
-  sys.path.append(ambari_common_folder + os.path.normpath("/src/test/python"))
-  sys.path.append(ambari_common_folder + os.path.normpath("/src/main/python/jinja2"))
-  sys.path.append(ambari_agent_folder + os.path.normpath("/src/main/python"))
+  ambari_agent_folder = os.path.join(ambari_server_folder,"../ambari-agent")
+  ambari_common_folder = os.path.join(ambari_server_folder,"../ambari-common")
+  sys.path.append(ambari_common_folder + "/src/main/python/jinja2")
+  sys.path.append(ambari_common_folder + "/src/test/python")
+  sys.path.append(ambari_agent_folder + "/src/main/python")
+  sys.path.append(ambari_server_folder + "/src/test/python")
+  sys.path.append(ambari_server_folder + "/src/main/python")
 
   stacks_folder = pwd+'/stacks'
   #generate test variants(path, service, stack)
@@ -130,9 +131,15 @@ def main():
       for service in os.listdir(current_stack_dir):
         current_service_dir = current_stack_dir+"/"+service
         if os.path.isdir(current_service_dir) and service not in SERVICE_EXCLUDE:
-          test_variants.append({'directory':current_service_dir,
-                                'service':service,
-                                'stack':stack})
+          if service == 'hooks':
+            for hook in os.listdir(current_service_dir):
+              test_variants.append({'directory':current_service_dir + "/" + hook,
+                                    'service':hook,
+                                    'stack':stack})
+          else:
+            test_variants.append({'directory':current_service_dir,
+                                  'service':service,
+                                  'stack':stack})
 
   #run tests for every service in every stack in separate process
   has_failures = False