Whamcloud - gitweb
LU-14786 lod: create missing debugfs file
[fs/lustre-release.git] / lustre / tests / yaml.sh
index 4dbdfe7..bd08571 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
+# vim:shiftwidth=4:softtabstop=4:tabstop=4:
 
 #
 # Shell routines for logging results to a yaml file.
@@ -17,10 +17,10 @@ yml_nodes_file() {
     export logdir=$1
 
     if [ -f $logdir/shared ]; then
-        do_rpc_nodes $(comma_list $(nodes_list)) \
-            "yml_node >> $logdir/node.\\\$(hostname).yml"
+        do_rpc_nodes $(comma_list $(all_nodes)) \
+            "yml_node >> $logdir/node.\\\$(hostname -s).yml"
     else
-        do_rpc_nodes $(comma_list $(nodes_list)) yml_node | split_output
+        do_rpc_nodes $(comma_list $(all_nodes)) yml_node | split_output
     fi
     yml_entities
 }
@@ -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,9 +54,10 @@ 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}
+    TEST_PROJECT=${TEST_PROJECT:-"LUSTRE"}
 
     # TestGroup information
     cat <<EOF
@@ -63,29 +66,40 @@ TestGroup:
     testhost: $TEST_HOST
     submission: $(date)
     user_name: $TEST_USER
-
+project: $TEST_PROJECT
 EOF
 }
 
-release() {
-   if [ -r /etc/lsb-release ]; then
-      dist=$(grep 'DISTRIB_ID' /etc/lsb-release | sed 's/DISTRIB_ID=//' | head -1)
-   elif [ -r /etc/redhat-release ]; then
-       dist=$(awk '/release/ { printf("%s %s %s", $1, $2, $3)}' /etc/redhat-release)
-   elif [ -r /etc/*-release ]; then
-       dist=$(find /etc/ -maxdepth 1 -name '*release' 2> /dev/null | \
-           sed -e 's/\/etc\///' -e 's/-release//' | head -1)
-   else
-       dist="UNKNOWN"
-   fi
+yml_code_review() {
+    echo -e $CODE_REVIEW_YAML
+}
 
-   echo $dist
+release() {
+       rhel_pat=".*release \([[:digit:]]\+\.[[:digit:]]\+\).*"
+
+       if [ -r /etc/centos-release ]; then
+               version=$(sed -n -e "s/${rhel_pat}/\1/p" /etc/centos-release)
+               dist="CentOS ${version}"
+       elif [ -r /etc/redhat-release ]; then
+               version=$(sed -n -e "s/${rhel_pat}/\1/p" /etc/redhat-release)
+               dist="RHEL ${version}"
+       elif [ -r /etc/os-release ]; then
+               name=$(sed -n -e 's/"//g' -e 's/^NAME=//p' /etc/os-release)
+               version=$(sed -n -e 's/"//g' -e 's/^VERSION_ID=//p' \
+               /etc/os-release)
+               dist="${name} ${version}"
+       else
+               dist="UNKNOWN"
+       fi
+
+       echo $dist
 }
 
 yml_build_info() {
-    TEST_DISTRO=$(release)
-    LUSTRE_VERSION=$(lctl lustre_build_version | awk '/Lustre version:/ {print $3}')
-    LUSTRE_BUILD=$(sed 's/-.*//' <<<$LUSTRE_VERSION)
+       local TEST_DISTRO=$(release)
+       local LUSTRE_VERSION=$(lustre_build_version)
+       local LUSTRE_BUILD=${LUSTRE_BUILD_SOURCE:-$LUSTRE_VERSION}
+       local FILE_SYSTEM=$(node_fstypes $(hostname -s))
 
 cat <<EOF
     lbats_build_id: $LBATS_ID
@@ -93,9 +107,12 @@ cat <<EOF
     architecture: $(uname -m)
     os: $(uname -o)
     os_distribution: $TEST_DISTRO
-    lustre_version: $LUSTRE_VERSION
-    lustre_build: $LUSTRE_BUILD
+    version: $LUSTRE_VERSION
+    build: $LUSTRE_BUILD
+    branch: $LUSTRE_BRANCH
+    revision: $LUSTRE_REVISION
     kernel_version: $(uname -r)
+    file_system: ${FILE_SYSTEM:-"NA"}
 EOF
 }
 
@@ -103,7 +120,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:
@@ -122,22 +139,43 @@ EOF
 }
 
 yml_entities() {
-    local host
-    for num in $(seq $MDSCOUNT); do
-        host=$(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)
-        yml_entity "OST $num" $host >> $logdir/node.$host.yml
-    done
-
-    i=1
-    for host in ${CLIENTS//,/ }; do
-        yml_entity "Client $i" $host >> $logdir/node.$host.yml
-        i=$((i+1))
-    done
+       local host
+       local f_host
+       local i
+
+       if ! combined_mgs_mds; then
+               host=$(short_hostname $(facet_active_host mgs))
+               f_host=$(short_hostname $(facet_passive_host mgs))
+
+               yml_entity "MGS" $host >> $logdir/node.$host.yml
+               [[ -n $f_host ]] &&
+                       yml_entity "MGS" $f_host >> $logdir/node.$f_host.yml
+       fi
+
+       for i in $(seq $MDSCOUNT); do
+               host=$(short_hostname $(facet_active_host mds$i))
+               f_host=$(short_hostname $(facet_passive_host mds$i))
+
+               yml_entity "MDS $i" $host >> $logdir/node.$host.yml
+               [[ -n $f_host ]] &&
+                       yml_entity "MDS $i" $f_host >> $logdir/node.$f_host.yml
+       done
+
+       for i in $(seq $OSTCOUNT); do
+               host=$(short_hostname $(facet_active_host ost$i))
+               f_host=$(short_hostname $(facet_passive_host ost$i))
+
+               yml_entity "OST $i" $host >> $logdir/node.$host.yml
+               [[ -n $f_host ]] &&
+                       yml_entity "OST $i" $f_host >> $logdir/node.$f_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
 }
 
 yml_log_test() {
@@ -147,6 +185,7 @@ yml_log_test() {
         name: $1
         description: $TESTSUITE $1
         submission: $(date)
+        report_version: 2
         SubTests:
 EOF
     fi
@@ -154,8 +193,8 @@ EOF
 
 yml_log_test_status() {
     cat <<EOF
-    duration: $1
-    status: $2
+        duration: $1
+        status: $2
 EOF
 }