Whamcloud - gitweb
LU-121 Fixup yaml.sh and test-framework.sh so that it only ever uses the first
authorChris <chris@whamcloud.com>
Thu, 10 Mar 2011 11:05:37 +0000 (11:05 +0000)
committerOleg Drokin <green@whamcloud.com>
Wed, 20 Jul 2011 20:50:25 +0000 (16:50 -0400)
part of the host name for log files.
This means stripping of everything off the name after and including the first .

This change is only designed to make the .yml files consistent. The log files
will append the fully qualified name and appear to do this consitantly.

We can create a jira to make the log and yml files consistant, but the reality
is that the yml files have a short life and are only used to send to Maloo.

This change will allow automated posting of results and automated testing to
begin.

1. Carries out the above using hostname -s [Thanks Andreas]
2. Adds in a quick change so that LUSTRE_BUILD in yaml.sh can be a reference to
the source rather than just the lustre version string which is recorded and
written to the yaml anyway as LUSTER_VERSION

Additionally a couple of other changes sneaked in.

1. Allows the review information to be applied to the yaml output file
by way of exporting the variable CODE_REVIEW_YAML to be a yaml description
for maloo

2. The addition of a couple of fixes to make the permissions for yaml
files be allow-all. This permissions are bracketed and so do not change any
other parts of the code.

Change-Id: Ied9a2117cd1b68e048bbc2bf1bffe782485c6150
Signed-off-by: Chris Gearing <chris@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/312
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Yu Jian <yujian@whamcloud.com>
lustre/tests/auster
lustre/tests/functions.sh
lustre/tests/test-framework.sh
lustre/tests/yaml.sh

index a59c6f4..bde5313 100755 (executable)
@@ -222,7 +222,7 @@ run_suite_logged() {
     fi
     
     echo "run_suite $suite_name $suite_script"
-    local log_name=${suite_name}.suite_log.$(hostname).log
+    local log_name=${suite_name}.suite_log.$(hostname -s).log
     if $verbose; then
        run_suite $suite_name $suite_script 2>&1 |tee  $LOGDIR/$log_name
     else
index 56529b6..19b3cc6 100644 (file)
@@ -241,3 +241,12 @@ lst_setup_all () {
     do_rpc_nodes $list lst_setup 
 }
 
+###
+# short_hostname
+#
+# Passed a single argument, strips everything off following and includes the first period.
+# client-20.lab.whamcloud.com becomes client-20
+short_hostname() {
+  echo $(sed 's/\..*//' <<< $1)
+}
+
index 40912c3..a28f1f6 100644 (file)
@@ -3205,9 +3205,11 @@ run_one() {
 run_one_logged() {
     local BEFORE=`date +%s`
     local TEST_ERROR
-    local name=${TESTSUITE}.test_${1}.test_log.$(hostname).log
+    local name=${TESTSUITE}.test_${1}.test_log.$(hostname -s).log
     local test_log=$LOGDIR/$name
     rm -rf $LOGDIR/err
+    local SAVE_UMASK=`umask`
+    umask 0022
 
     echo
     log_sub_test_begin test_${1}
@@ -3226,6 +3228,8 @@ run_one_logged() {
         $FAIL_ON_ERROR && exit $RC
     fi
 
+    umask $SAVE_UMASK
+
     return 0
 }
 
@@ -4067,14 +4071,14 @@ gather_logs () {
 
     if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
         echo "Dumping logs only on local client."
-        $LCTL dk > ${prefix}.debug_log.$(hostname).${suffix}
-        dmesg > ${prefix}.dmesg.$(hostname).${suffix}
+        $LCTL dk > ${prefix}.debug_log.$(hostname -s).${suffix}
+        dmesg > ${prefix}.dmesg.$(hostname -s).${suffix}
         return
     fi
 
     do_nodesv $list \
-        "$LCTL dk > ${prefix}.debug_log.\\\$(hostname).${suffix};
-         dmesg > ${prefix}.dmesg.\\\$(hostname).${suffix}"
+        "$LCTL dk > ${prefix}.debug_log.\\\$(hostname -s).${suffix};
+         dmesg > ${prefix}.dmesg.\\\$(hostname -s).${suffix}"
     if [ ! -f $LOGDIR/shared ]; then
         do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
       fi
@@ -4433,7 +4437,7 @@ check_logdir() {
         # Not found. Create local logdir
         mkdir -p $dir
     else
-        touch $dir/node.$(hostname).yml
+        touch $dir/node.$(hostname -s).yml
     fi
     return 0
 }
@@ -4441,7 +4445,7 @@ check_logdir() {
 check_write_access() {
     local dir=$1
     for node in $(nodes_list); do
-        if [ ! -f "$dir/node.${node}.yml" ]; then
+        if [ ! -f "$dir/node.$(short_hostname ${node}).yml" ]; then
             # Logdir not accessible/writable from this node.
             return 1
         fi
@@ -4453,6 +4457,9 @@ init_logging() {
     if [[ -n $YAML_LOG ]]; then
         return
     fi
+    local SAVE_UMASK=`umask`
+    umask 0000
+
     export YAML_LOG=${LOGDIR}/results.yml
     mkdir -p $LOGDIR
     init_clients_lists
@@ -4467,6 +4474,8 @@ init_logging() {
 
     yml_nodes_file $LOGDIR >> $YAML_LOG
     yml_results_file >> $YAML_LOG
+
+    umask $SAVE_UMASK
 }
 
 log_test() {
@@ -4593,4 +4602,3 @@ is_sanity_benchmark() {
 min_ost_size () {
     $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1
 }
-
index f5803e2..13f69bf 100644 (file)
@@ -18,7 +18,7 @@ yml_nodes_file() {
 
     if [ -f $logdir/shared ]; then
         do_rpc_nodes $(comma_list $(nodes_list)) \
-            "yml_node >> $logdir/node.\\\$(hostname).yml"
+            "yml_node >> $logdir/node.\\\$(hostname -s).yml"
     else
         do_rpc_nodes $(comma_list $(nodes_list)) yml_node | split_output
     fi
@@ -31,13 +31,15 @@ yml_results_file() {
     #TestGroup
     yml_test_group
 
+    #CodeReview
+    yml_code_review
+
     # Tests
     printf "Tests:\n"
 }
 
 # Called on the node for which we the info is needed.
 yml_node() {
-    local node=$(hostname)
     logdir=$1
 
     printf "Build:\n"
@@ -52,8 +54,8 @@ yml_node() {
 }
 
 yml_test_group() {
-    TEST_GROUP=${TEST_GROUP:-"acc-sm-$(hostname)"}
-    TEST_HOST=${TEST_HOST:-$(hostname)}
+    TEST_GROUP=${TEST_GROUP:-"acc-sm-$(hostname -s)"}
+    TEST_HOST=${TEST_HOST:-$(hostname -s)}
     TEST_USER=${TEST_USER:-$USER}
 
     # TestGroup information
@@ -63,10 +65,13 @@ TestGroup:
     testhost: $TEST_HOST
     submission: $(date)
     user_name: $TEST_USER
-
 EOF
 }
 
+yml_code_review() {
+    echo -e $CODE_REVIEW_YAML
+}
+
 release() {
    if [ -r /etc/lsb-release ]; then
       dist=$(grep 'DISTRIB_ID' /etc/lsb-release | sed 's/DISTRIB_ID=//' | head -1)
@@ -85,7 +90,7 @@ release() {
 yml_build_info() {
     TEST_DISTRO=$(release)
     LUSTRE_VERSION=$(lctl lustre_build_version | awk '/Lustre version:/ {print $3}')
-    LUSTRE_BUILD=$(sed 's/-.*//' <<<$LUSTRE_VERSION)
+    LUSTRE_BUILD=${LUSTRE_BUILD_SOURCE:-$(sed 's/-.*//' <<<$LUSTRE_VERSION)}
 
 cat <<EOF
     lbats_build_id: $LBATS_ID
@@ -103,7 +108,7 @@ yml_node_info()
 {
     mem=$(awk '/MemTotal:/ {print $2 " " $3}' /proc/meminfo)
 cat <<EOF
-    node_name: $(hostname)
+    node_name: $(hostname -s)
     mem_size: $mem
     architecture: $(uname -m)
     networks:
@@ -124,17 +129,18 @@ EOF
 yml_entities() {
     local host
     for num in $(seq $MDSCOUNT); do
-        host=$(facet_active_host mds$num)
+        host=$(short_hostname $(facet_active_host mds$num))
         yml_entity "MDS $num" $host >> $logdir/node.$host.yml
     done
 
     for num in $(seq $OSTCOUNT); do
-        host=$(facet_active_host ost$num)
+        host=$(short_hostname $(facet_active_host ost$num))
         yml_entity "OST $num" $host >> $logdir/node.$host.yml
     done
 
     i=1
     for host in ${CLIENTS//,/ }; do
+        host=$(short_hostname $host)
         yml_entity "Client $i" $host >> $logdir/node.$host.yml
         i=$((i+1))
     done