Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Code Block
languagebash
#!/bin/bash

ipa=$(sudo ifconfig | grep -A 1 vmxnet3s0 | sed '1d; s/^[ \t]*inet[ \t]*//; s/[ \t]*netmask.*$//')
if [ -n "$1" ]; then
    CLOG="/var/tmp/mdb-stability.$(date +%F-%T).txt"
    echo "=== Stability mdb tests $(date +%F-%T) ===" > ${CLOG}
    uname -a >> ${CLOG}
    echo "IP Address : ${ipa}" >> ${CLOG}
    for (( i=1; i<=$1; i++ ))
    do
        echo "------------------ Pass ${i} ---------------------" 2>&1 | /usr/bin/tee -a ${CLOG}
        LOG="/var/tmp/mdb-test.$i.txt"
        uname -a > ${LOG}
        echo "IP Address : ${ipa}" >> ${LOG}
        /opt/util-tests/bin/utiltest -c /opt/util-tests/runfiles/mdb.run 2>&1 | /usr/bin/tee -a tmp.log
        folder="$(grep 'Log directory:' tmp.log | sed 's/Log directory:[ \t]*//; s/[ \t]*$//')"
        sudo rm -f tmp.log 
        LOG1="${folder}/log"
        rt=$(sed '/^Test: /!d;s/ \[[A-Z]*\]//;s/^.*\[//;s/\].*//' ${LOG1})
        pass=$(sed -n '/ Tests passed:/p' ${LOG1} | sed 's/^.*Tests passed:[ \t]*//;s/[ \t]*$//')
        total=$(sed -n '/ Tests ran:/p' ${LOG1} | sed 's/^.*Tests ran:[ \t]*//;s/[ \t]*$//')
        percent=$(echo "scale=1; ${pass}*100.0/${total}" | bc)
        folder=$(sed -n '/ output directory:/p' ${LOG1} | sed 's/^.* output directory:[ \t]*//;s/[ \t]*$//')    
        echo " Percent passed: ${percent}" >> ${CLOG}
        echo " Running Time: ${rt}" >> ${CLOG}
        sed -n '/ Tests passed:/,/ Tests ran:/p' ${LOG1} | sed 's/^.*Tests passed:[ \t]*/PASS \t/;s/^.*Tests failed:[ \t]*/FAIL \t/;s/^.*Tests ran:[ \t]*/TOTAL\t/' >> u.tmp
        echo "---------------------------------------------------------" >> u.tmp
        echo "" >> u.tmp
        cat ${LOG1} 2>&1 | /usr/bin/tee -a u.tmp
        mv -f a.tmp ${LOG}
        if [ "${percent}" == "100.0" ]; then
            sudo rm -f ${LOG}
            sudo rm -r -f ${folder}
        else
            echo " PASS ${i} IS FAILED! (See ${LOG})" >> ${CLOG}
            echo "Fault on ${i} pass! Just ${percent}% are successfull. You can find logs in ${folder}." 2>&1 | /usr/bin/tee -a ${LOG}
            exit 1
        fi
    done
else
    LOG="/var/tmp/mdb-test.$(date +%F-%T).txt"
    uname -a > u.tmp
    echo "IP Address : ${ipa}" >> u.tmp
    echo "" >> u.tmp
    /opt/util-tests/bin/utiltest -c /opt/util-tests/runfiles/mdb.run > tmp.log
    folder="$(grep 'Log directory:' tmp.log | sed 's/Log directory:[ \t]*//; s/[ \t]*$//')"
    sudo rm -f tmp.log
    LOG1="${folder}/log"
    tm=$(sed '/^Test: /!d;s/ \[[A-Z]*\]//;s/^.*\[//;s/\].*//' ${LOG1})
    pass=$(sed -n '/ Tests passed:/p' ${LOG1} | sed 's/^.*Tests passed:[ \t]*//;s/[ \t]*$//')
    total=$(sed -n '/ Tests ran:/p' ${LOG1} | sed 's/^.*Tests ran:[ \t]*//;s/[ \t]*$//')
    echo "TOTAL TESTS: $total" >> u.tmp
    result=$(echo "scale=1; ${pass}*100.0/${total}" | bc)
    folder=$(sed -n '/ output directory:/p' ${LOG1} | sed 's/^.* output directory:[ \t]*//;s/[ \t]*$//')
    sed -n '/ Tests passed:/,/ Tests ran:/p' ${LOG1} | sed 's/^.*Tests passed:[ \t]*/PASS \t/;s/^.*Tests failed:[ \t]*/FAIL \t/;s/^.*Tests ran:[ \t]*/TOTAL\t/' >> u.tmp
    echo "" >> u.tmp
    echo "Running Time:   00:${tm}" >> u.tmp
    echo "Percent passed: ${result}" >> u.tmp
    echo "Log directory:  ${folder}" >> u.tmp
    echo "---------------------------------------------------------" >> u.tmp
    echo "" >> u.tmp
    cat ${LOG1} 2>&1 | /usr/bin/tee -a u.tmp
    mv -f u.tmp ${LOG}
fi

...