#!/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="${LOG}(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})
percentpass="$(grepsed -n 'Percent/ Tests passed:/p' ${LOGLOG1} | sed 's/Percent^.*Tests passed:[ \t]*//; s/[ \t]*$//')"
foldertotal="$(grepsed -n 'Log/ Tests directoryran:/p' ${LOGLOG1} | sed 's/Log directory^.*Tests ran:[ \t]*//; s/[ \t]*$//')
percent=$(echo "scale=1; ${pass}*100.0/${total}" | bc)
rt folder="$(grepsed -n 'Running/ output Timedirectory:/p' ${LOGLOG1} | sed 's/Running Time^.* output directory:[ \t]*//; s/[ \t]*$//')"
echo " Percent passed: ${percent}" >> ${CLOG}
echo " Running Time: ${rt}" >> ${CLOG}
sed -n '/Results Tests Summarypassed:/,/Log Tests directoryran:/p' ${LOGLOG1} > | 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 ${LOG} >>LOG1} 2>&1 | /usr/bin/tee -a u.tmp
mv -f a.tmp ${LOG}
if [ "${percent}" == "100.0%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 2>&1 | /usr/bin/tee -a ${LOG} > 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})
failpass=$(sed -n '/^FAIL[ \t]* Tests passed:/p' ${LOGLOG1} | sed 's/^FAIL^.*Tests passed:[ \t]*//; s/[ \t]*$//')
passtotal=$(sed -n '/^PASS[ \t]* Tests ran:/p' ${LOGLOG1} | sed 's/^PASS^.*Tests ran:[ \t]*//; s/[ \t]*$//')
echo "TOTAL TESTS: $total" total=0
>> u.tmp
if [result=$(echo "scale=1; ${pass}*100.0/${total}" != "" ]; then| bc)
folder=$(sed -n '/ output total=$((directory:/p' ${total} + ${pass})LOG1} | sed 's/^.* output directory:[ \t]*//;s/[ \t]*$//')
fised -n '/ Tests passed:/,/ if [ "Tests ran:/p' ${fail}" != "" ]; then
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 total=$((${total} + ${fail}))
fi
echo "TOTAL TESTS: $totalTime: 00:${tm}" >> u.tmp
echo "Percent passed: ${result}" >> u.tmp
sed -n '/Results Summary/,/echo "Log directory:/p' ${LOGfolder}" >> u.tmp
echo "---------------------------------------------------------" >> u.tmp
echo "" >> u.tmp
cat ${LOG} >>LOG1} 2>&1 | /usr/bin/tee -a u.tmp
mv -f u.tmp ${LOG}
fi
|