You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2013/04/30 02:49:45 UTC

svn commit: r1477433 - in /incubator/ambari/trunk: ./ ambari-agent/src/main/puppet/modules/hdp-yarn/files/ ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/ ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/resourcemanager/

Author: swagle
Date: Tue Apr 30 00:49:44 2013
New Revision: 1477433

URL: http://svn.apache.org/r1477433
Log:
AMBARI-2050. Create smoke test for RESOURCEMANAGER component. (swagle)

Added:
    incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/files/
    incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/files/validateYarnComponentStatus.py
    incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/resourcemanager/
    incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/resourcemanager/service_check.pp
Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/params.pp

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1477433&r1=1477432&r2=1477433&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Tue Apr 30 00:49:44 2013
@@ -12,6 +12,8 @@ Trunk (unreleased changes):
 
  NEW FEATURES
 
+ AMBARI-2050. Create smoke test for RESOURCEMANAGER component. (swagle)
+
  AMBARI-2049. Create ambari agent scripts for MAPREDUCEv2_CLIENT. (swagle)
 
  AMBARI-2048. Create ambari agent scripts for historyserver. (swagle)

Added: incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/files/validateYarnComponentStatus.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/files/validateYarnComponentStatus.py?rev=1477433&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/files/validateYarnComponentStatus.py (added)
+++ incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/files/validateYarnComponentStatus.py Tue Apr 30 00:49:44 2013
@@ -0,0 +1,75 @@
+#!/usr/bin/env python2.6
+
+'''
+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.
+'''
+
+import optparse
+import urllib2, urllib
+import json
+
+RESOURCEMANAGER = 'rm'
+NODEMANAGER = 'nm'
+
+STARTED_STATE = 'STARTED'
+
+def validate(path, port):
+
+  try:
+    url = 'http://localhost:' + str(port) + path
+    opener = urllib2.build_opener()
+    urllib2.install_opener(opener)
+    request = urllib2.Request(url)
+    handler = urllib2.urlopen(request)
+    cluster_info = json.loads(handler.read())
+    component_state = cluster_info['clusterInfo']['state']
+  
+    if component_state == STARTED_STATE:
+      print 'Component''s state is: ' + str(component_state)
+      exit(0)
+    else:
+      print 'Component''s state is not' + STARTED_STATE
+      exit(1)
+  except Exception as e:
+    print 'Error checking status of component', e
+    exit(1)
+
+#
+# Main.
+#
+def main():
+  parser = optparse.OptionParser(usage="usage: %prog [options] component ")
+  parser.add_option("-p", "--port", dest="port", help="Port for rest api of desired component")
+
+
+  (options, args) = parser.parse_args()
+
+  component = args[0]
+  
+  port = options.port
+  
+  if component == RESOURCEMANAGER:
+    path = '/ws/v1/cluster/info'
+  elif component == NODEMANAGER:
+    path = '/ws/v1/node/info'
+  else:
+    parser.error("Invalid component")
+
+  validate(path, port)
+
+if __name__ == "__main__":
+  main()

Modified: incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/params.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/params.pp?rev=1477433&r1=1477432&r2=1477433&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/params.pp (original)
+++ incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/params.pp Tue Apr 30 00:49:44 2013
@@ -34,5 +34,8 @@ class hdp-yarn::params(
   
   $yarn_log_dir_prefix = hdp_default("hadoop/yarn-env/yarn_log_dir_prefix","/var/log/hadoop-yarn")
   $yarn_pid_dir_prefix = hdp_default("hadoop/yarn-env/yarn_pid_dir_prefix","/var/run/hadoop-yarn")
+  
+  ## yarn-site
+  $yarn_webui_port = hdp_default("yarn-site/yarn.resourcemanager.webapp.address", "8088")
  
 }

Added: incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/resourcemanager/service_check.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/resourcemanager/service_check.pp?rev=1477433&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/resourcemanager/service_check.pp (added)
+++ incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/resourcemanager/service_check.pp Tue Apr 30 00:49:44 2013
@@ -0,0 +1,46 @@
+#
+#
+# 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.
+#
+#
+class hdp-yarn::resourcemanager::service_check() inherits hdp-yarn::params
+{
+  $smoke_test_user = $hdp::params::smokeuser
+  
+  $validateStatusFileName = "validateYarnComponentStatus.py"
+  $validateStatusFilePath = "/tmp/$validateStatusFileName"
+  $yarn_webui_port = $hdp-yarn::params::yarn_webui_port
+  $validateStatusCmd = "su - ${smoke_test_user} -c 'python $validateStatusFilePath rm -p $yarn_webui_port'"
+
+  $test_cmd = "fs -test -e ${output_file}" 
+
+  file { $validateStatusFilePath:
+    ensure => present,
+    source => "puppet:///modules/hdp-yarn/$validateStatusFileName",
+    mode => '0755'
+  }
+
+  exec { $validateStatusFilePath:
+    command   => $validateStatusCmd,
+    tries     => 3,
+    try_sleep => 5,
+    path      => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+    logoutput => "true"
+  }
+  File[$validateStatusFilePath] -> Exec[$validateStatusFilePath]
+}
\ No newline at end of file