Przeglądaj źródła

AMBARI-2050. Create smoke test for RESOURCEMANAGER component. (swagle)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1477433 13f79535-47bb-0310-9956-ffa450edef68
Siddharth Wagle 12 lat temu
rodzic
commit
bbd8fe2a67

+ 2 - 0
CHANGES.txt

@@ -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)

+ 75 - 0
ambari-agent/src/main/puppet/modules/hdp-yarn/files/validateYarnComponentStatus.py

@@ -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()

+ 3 - 0
ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/params.pp

@@ -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")
  
 }

+ 46 - 0
ambari-agent/src/main/puppet/modules/hdp-yarn/manifests/resourcemanager/service_check.pp

@@ -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]
+}