You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2013/06/07 21:12:43 UTC
svn commit: r1490789 - in
/incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie:
files/oozieSmoke.sh files/oozieSmoke2.sh manifests/oozie/service_check.pp
Author: smohanty
Date: Fri Jun 7 19:12:42 2013
New Revision: 1490789
URL: http://svn.apache.org/r1490789
Log:
AMBARI-2305. OOZIE service check fails for Hadoop 2.0.5. (smohanty)
Added:
incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/files/oozieSmoke2.sh
Modified:
incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/files/oozieSmoke.sh
incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/manifests/oozie/service_check.pp
Modified: incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/files/oozieSmoke.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/files/oozieSmoke.sh?rev=1490789&r1=1490788&r2=1490789&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/files/oozieSmoke.sh (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/files/oozieSmoke.sh Fri Jun 7 19:12:42 2013
@@ -63,7 +63,7 @@ export JTHOST=$7
export NNHOST=$8
export OOZIE_EXIT_CODE=0
-export JOBTRACKER=`getValueFromField ${hadoop_conf_dir}/yarn-site.xml yarn.resourcemanager.address`
+export JOBTRACKER=`getValueFromField ${hadoop_conf_dir}/mapred-site.xml mapred.job.tracker`
export NAMENODE=`getValueFromField ${hadoop_conf_dir}/core-site.xml fs.default.name`
export OOZIE_SERVER=`getValueFromField ${oozie_conf_dir}/oozie-site.xml oozie.base.url`
export OOZIE_EXAMPLES_DIR=`rpm -ql oozie-client | grep 'oozie-examples.tar.gz$' | xargs dirname`
Added: incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/files/oozieSmoke2.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/files/oozieSmoke2.sh?rev=1490789&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/files/oozieSmoke2.sh (added)
+++ incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/files/oozieSmoke2.sh Fri Jun 7 19:12:42 2013
@@ -0,0 +1,98 @@
+#!/bin/sh
+#
+#
+# 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.
+#
+#
+function getValueFromField {
+ xmllint $1 | grep "<name>$2</name>" -C 2 | grep '<value>' | cut -d ">" -f2 | cut -d "<" -f1
+ return $?
+}
+
+function checkOozieJobStatus {
+ local job_id=$1
+ local num_of_tries=$2
+ #default num_of_tries to 10 if not present
+ num_of_tries=${num_of_tries:-10}
+ local i=0
+ local rc=1
+ local cmd="source ${oozie_conf_dir}/oozie-env.sh ; /usr/bin/oozie job -oozie ${OOZIE_SERVER} -info $job_id"
+ su - ${smoke_test_user} -c "$cmd"
+ while [ $i -lt $num_of_tries ] ; do
+ cmd_output=`su - ${smoke_test_user} -c "$cmd"`
+ (IFS='';echo $cmd_output)
+ act_status=$(IFS='';echo $cmd_output | grep ^Status | cut -d':' -f2 | sed 's| ||g')
+ echo "workflow_status=$act_status"
+ if [ "RUNNING" == "$act_status" ]; then
+ #increment the couner and get the status again after waiting for 15 secs
+ sleep 15
+ (( i++ ))
+ elif [ "SUCCEEDED" == "$act_status" ]; then
+ rc=0;
+ break;
+ else
+ rc=1
+ break;
+ fi
+ done
+ return $rc
+}
+
+export oozie_conf_dir=$1
+export hadoop_conf_dir=$2
+export smoke_test_user=$3
+export security_enabled=$4
+export smoke_user_keytab=$5
+export realm=$6
+export JTHOST=$7
+export NNHOST=$8
+
+export OOZIE_EXIT_CODE=0
+export JOBTRACKER=`getValueFromField ${hadoop_conf_dir}/yarn-site.xml yarn.resourcemanager.address`
+export NAMENODE=`getValueFromField ${hadoop_conf_dir}/core-site.xml fs.default.name`
+export OOZIE_SERVER=`getValueFromField ${oozie_conf_dir}/oozie-site.xml oozie.base.url`
+export OOZIE_EXAMPLES_DIR=`rpm -ql oozie-client | grep 'oozie-examples.tar.gz$' | xargs dirname`
+cd $OOZIE_EXAMPLES_DIR
+
+tar -zxf oozie-examples.tar.gz
+sed -i "s|nameNode=hdfs://localhost:8020|nameNode=$NAMENODE|g" examples/apps/map-reduce/job.properties
+sed -i "s|nameNode=hdfs://localhost:9000|nameNode=$NAMENODE|g" examples/apps/map-reduce/job.properties
+sed -i "s|jobTracker=localhost:8021|jobTracker=$JOBTRACKER|g" examples/apps/map-reduce/job.properties
+sed -i "s|jobTracker=localhost:9001|jobTracker=$JOBTRACKER|g" examples/apps/map-reduce/job.properties
+sed -i "s|oozie.wf.application.path=hdfs://localhost:9000|oozie.wf.application.path=$NAMENODE|g" examples/apps/map-reduce/job.properties
+
+if [[ $security_enabled == "true" ]]; then
+ kinitcmd="${kinit_path_local} -kt ${smoke_user_keytab} ${smoke_test_user}; "
+ echo "dfs.namenode.kerberos.principal=nn/`echo ${NNHOST} | tr '[:upper:]' '[:lower:]'`@${realm}" >> examples/apps/map-reduce/job.properties
+ echo "mapreduce.jobtracker.kerberos.principal=jt/`echo ${JTHOST} | tr '[:upper:]' '[:lower:]'`@${realm}" >> examples/apps/map-reduce/job.properties
+else
+ kinitcmd=""
+fi
+
+su - ${smoke_test_user} -c "hdfs dfs -rm -r examples"
+su - ${smoke_test_user} -c "hdfs dfs -rm -r input-data"
+su - ${smoke_test_user} -c "hdfs dfs -copyFromLocal $OOZIE_EXAMPLES_DIR/examples examples"
+su - ${smoke_test_user} -c "hdfs dfs -copyFromLocal $OOZIE_EXAMPLES_DIR/examples/input-data input-data"
+
+cmd="${kinitcmd}source ${oozie_conf_dir}/oozie-env.sh ; /usr/bin/oozie -Doozie.auth.token.cache=false job -oozie $OOZIE_SERVER -config $OOZIE_EXAMPLES_DIR/examples/apps/map-reduce/job.properties -run"
+echo $cmd
+job_info=`su - ${smoke_test_user} -c "$cmd" | grep "job:"`
+job_id="`echo $job_info | cut -d':' -f2`"
+checkOozieJobStatus "$job_id"
+OOZIE_EXIT_CODE="$?"
+exit $OOZIE_EXIT_CODE
Modified: incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/manifests/oozie/service_check.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/manifests/oozie/service_check.pp?rev=1490789&r1=1490788&r2=1490789&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/manifests/oozie/service_check.pp (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-agent/src/main/puppet/modules/hdp-oozie/manifests/oozie/service_check.pp Fri Jun 7 19:12:42 2013
@@ -23,14 +23,25 @@ class hdp-oozie::oozie::service_check()
include hdp-oozie::params
$smoke_shell_files = ['oozieSmoke.sh']
+
+ if (hdp_get_major_stack_version($stack_version) >= 2) {
+ $smoke_test_file_name = 'oozieSmoke2.sh'
+ } else {
+ $smoke_test_file_name = 'oozieSmoke.sh'
+ }
+
anchor { 'hdp-oozie::oozie::service_check::begin':}
- hdp-oozie::smoke_shell_file { $smoke_shell_files: }
+ hdp-oozie::smoke_shell_file { $smoke_shell_files:
+ smoke_shell_file_name => $smoke_test_file_name
+ }
anchor{ 'hdp-oozie::oozie::service_check::end':}
}
-define hdp-oozie::smoke_shell_file()
+define hdp-oozie::smoke_shell_file(
+ $smoke_shell_file_name
+)
{
$smoke_test_user = $hdp::params::smokeuser
$conf_dir = $hdp::params::oozie_conf_dir
@@ -46,17 +57,17 @@ define hdp-oozie::smoke_shell_file()
$smoke_user_keytab = "${hdp-oozie::params::keytab_path}/${smoke_test_user}.headless.keytab"
$realm=$hdp::params::kerberos_domain
- file { '/tmp/oozieSmoke.sh':
+ file { "/tmp/${smoke_shell_file_name}":
ensure => present,
- source => "puppet:///modules/hdp-oozie/oozieSmoke.sh",
+ source => "puppet:///modules/hdp-oozie/${smoke_shell_file_name}",
mode => '0755'
}
- exec { '/tmp/oozieSmoke.sh':
- command => "sh /tmp/oozieSmoke.sh ${conf_dir} ${hadoopconf_dir} ${smoke_test_user} ${security} ${smoke_user_keytab} ${realm} $jt_host $nn_host",
+ exec { "/tmp/${smoke_shell_file_name}":
+ command => "sh /tmp/${smoke_shell_file_name} ${conf_dir} ${hadoopconf_dir} ${smoke_test_user} ${security} ${smoke_user_keytab} ${realm} $jt_host $nn_host",
tries => 3,
try_sleep => 5,
- require => File['/tmp/oozieSmoke.sh'],
+ require => File["/tmp/${smoke_shell_file_name}"],
path => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
logoutput => "true"
}