2013-07-04 08:05:39 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
|
|
function myexit
|
|
|
|
{
|
|
|
|
local rc=$1 msg="$2"
|
|
|
|
if [ -n "$msg" ];then
|
|
|
|
echo " $msg" >&2
|
|
|
|
fi
|
|
|
|
echo " exit called from ${BASH_SOURCE[1]}:${BASH_LINENO[0]}" >&2
|
|
|
|
exit $rc
|
|
|
|
}
|
|
|
|
|
|
|
|
function execute_tests
|
|
|
|
{
|
2013-11-07 09:33:43 +00:00
|
|
|
local t rc send_msg=0
|
|
|
|
local tmp_file=/tmp/$my_name.$$
|
|
|
|
local fail_msg="tests failed on $(hostname) (Script $0):"$'\n'
|
|
|
|
local perf_msg="Performance-Failures:"$'\n'
|
|
|
|
local errorfile_msg="Error-Files:"$'\n'
|
|
|
|
local kernel_stack_msg="Kernel-Stacks:"$'\n'
|
|
|
|
local perf_grep_cmd='grep PERFORMANCE-FAILURE '$tmp_file
|
|
|
|
local errorfile_grep_cmd='grep ERROR-FILE '$tmp_file
|
|
|
|
local kernel_stack_grep_cmd='grep KERNEL-STACK '$tmp_file
|
|
|
|
|
2013-07-04 08:05:39 +00:00
|
|
|
for t in "${tests_to_execute[@]}"; do
|
|
|
|
echo executing test $t
|
2013-11-07 09:33:43 +00:00
|
|
|
cd $test_suite_dir/$t || myexit 1
|
|
|
|
$start_script 2>&1 | tee $tmp_file
|
|
|
|
rc=${PIPESTATUS[0]}
|
2013-07-04 08:05:39 +00:00
|
|
|
if [ $rc -ne 0 ];then
|
2013-11-07 09:33:43 +00:00
|
|
|
fail_msg+="$t"$'\n'
|
|
|
|
send_msg=1
|
|
|
|
fi
|
|
|
|
if $perf_grep_cmd >/dev/null; then
|
|
|
|
perf_msg+="$t: $($perf_grep_cmd)"$'\n'
|
|
|
|
send_msg=1
|
|
|
|
fi
|
|
|
|
if $errorfile_grep_cmd >/dev/null; then
|
|
|
|
errorfile_msg+="$t: $($errorfile_grep_cmd)"$'\n'
|
|
|
|
send_msg=1
|
|
|
|
fi
|
|
|
|
if $kernel_stack_grep_cmd >/dev/null; then
|
|
|
|
kernel_stack_msg+="$t: $($kernel_stack_grep_cmd)"$'\n'
|
|
|
|
send_msg=1
|
2013-07-04 08:05:39 +00:00
|
|
|
fi
|
|
|
|
done
|
2013-11-07 09:33:43 +00:00
|
|
|
rm $tmp_file
|
|
|
|
if [ $send_msg -eq 1 ]; then
|
2013-09-17 10:41:17 +00:00
|
|
|
local to
|
2013-11-07 09:33:43 +00:00
|
|
|
local msg="$fail_msg$perf_msg$errorfile_msg$kernel_stack_msg"$'\n'
|
|
|
|
msg+="for details see logfile on $(hostname)"
|
2013-07-04 08:05:39 +00:00
|
|
|
for to in "${mail_to[@]}"; do
|
|
|
|
sendEmail -m "$msg" -f $mail_from -t $to -u "failed mars tests" -s $mail_server
|
|
|
|
done
|
|
|
|
echo "$msg"
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
echo all tests passed
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_env
|
|
|
|
{
|
|
|
|
export PATH=$PATH:/sbin
|
|
|
|
}
|
|
|
|
|
|
|
|
function usage
|
|
|
|
{
|
2013-11-07 09:33:43 +00:00
|
|
|
echo "usage: $my_name [-c] test_suite_dir" >&2
|
2013-07-04 08:05:39 +00:00
|
|
|
echo " -c: without cleanup after all tests have passed" >&2
|
2013-08-06 12:29:21 +00:00
|
|
|
echo " -b: checkout, install, build resource" >&2
|
2013-07-04 08:05:39 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2013-11-07 09:33:43 +00:00
|
|
|
# main
|
|
|
|
my_name=$(basename $0)
|
|
|
|
|
2013-08-06 12:29:21 +00:00
|
|
|
OPTSTR="bc"
|
2013-07-04 08:05:39 +00:00
|
|
|
|
|
|
|
with_cleanup=0
|
2013-08-06 12:29:21 +00:00
|
|
|
only_checkout_install_build_resource=0
|
2013-07-04 08:05:39 +00:00
|
|
|
|
|
|
|
while getopts "$OPTSTR" opt; do
|
|
|
|
case $opt in # (
|
|
|
|
c) with_cleanup=0;;
|
2013-08-06 12:29:21 +00:00
|
|
|
b) only_checkout_install_build_resource=1;;
|
2013-07-04 08:05:39 +00:00
|
|
|
*) usage;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2013-11-07 09:33:43 +00:00
|
|
|
[ $# -ne 1 ] && usage
|
|
|
|
|
|
|
|
test_suite_dir=$1
|
|
|
|
|
2013-07-04 08:05:39 +00:00
|
|
|
# main
|
2013-11-07 09:33:43 +00:00
|
|
|
|
2013-07-04 08:05:39 +00:00
|
|
|
echo Start $(basename $0) at $(date)
|
2013-09-17 10:41:17 +00:00
|
|
|
logfile="/home/fl/tmp/cronjob_mars.log"
|
2013-07-04 08:05:39 +00:00
|
|
|
|
|
|
|
eval $(ssh-agent)
|
|
|
|
~/tools/sx
|
|
|
|
|
|
|
|
mail_server=mxintern.schlund.de:587
|
|
|
|
|
|
|
|
mail_from="$0@$(hostname)"
|
|
|
|
mail_to=("frank.liepold@1und1.de")
|
|
|
|
|
|
|
|
|
2013-11-07 09:33:43 +00:00
|
|
|
start_script=$test_suite_dir/scripts/start_test.sh
|
|
|
|
|
|
|
|
# test entries *must* start at begin of lines
|
2013-07-04 08:05:39 +00:00
|
|
|
|
2013-08-06 12:29:21 +00:00
|
|
|
tests_to_execute=(\
|
|
|
|
build_test_environment/checkout \
|
|
|
|
build_test_environment/make \
|
|
|
|
build_test_environment/install_mars \
|
|
|
|
build_test_environment/lv_config \
|
|
|
|
build_test_environment/cluster \
|
|
|
|
build_test_environment/resource/create_resource \
|
|
|
|
test_cases/admin/apply_fetch/apply \
|
|
|
|
test_cases/admin/apply_fetch/fetch \
|
|
|
|
test_cases/destroy_secondary_logfile \
|
|
|
|
test_cases/admin/resizing \
|
|
|
|
test_cases/admin/logrotate \
|
|
|
|
test_cases/admin/logdelete \
|
2013-09-17 10:41:17 +00:00
|
|
|
test_cases/bugs/memleak \
|
2013-08-06 12:29:21 +00:00
|
|
|
test_cases/admin/switch2primary \
|
|
|
|
test_cases/admin/datadev_full \
|
|
|
|
test_cases/hardcore/mars_dir_full/write_other_file \
|
|
|
|
test_cases/hardcore/mars_dir_full/write_data_dev \
|
|
|
|
test_cases/stabil/net_failure/connection_cut \
|
|
|
|
test_cases/stabil/crash/crash_primary \
|
|
|
|
test_cases/stabil/crash/crash_primary_logger_comletion_semantics__aio_sync_mode \
|
|
|
|
test_cases/stabil/crash/crash_primary_logger_completion_semantics \
|
|
|
|
test_cases/stabil/crash/crash_primary_aio_sync_mode \
|
2013-09-17 10:41:17 +00:00
|
|
|
test_cases/bugs/aio_filehandle \
|
2013-08-06 12:29:21 +00:00
|
|
|
build_test_environment/resource/leave_resource \
|
2013-11-07 09:33:43 +00:00
|
|
|
test_cases/perf \
|
2013-08-06 12:29:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if [ $only_checkout_install_build_resource -eq 1 ]; then
|
2013-11-07 09:33:43 +00:00
|
|
|
tests_to_execute=(\
|
2013-08-06 12:29:21 +00:00
|
|
|
build_test_environment/checkout \
|
|
|
|
build_test_environment/make \
|
|
|
|
build_test_environment/install_mars \
|
|
|
|
build_test_environment/lv_config \
|
|
|
|
build_test_environment/cluster \
|
|
|
|
build_test_environment/resource/create_resource \
|
|
|
|
)
|
|
|
|
fi
|
2013-07-04 08:05:39 +00:00
|
|
|
|
|
|
|
set_env
|
|
|
|
|
|
|
|
execute_tests
|
|
|
|
|
|
|
|
rc=$?
|
|
|
|
|
|
|
|
if [ $rc -eq 0 -a $with_cleanup -eq 1 ];then
|
|
|
|
tests_to_execute=(build_test_environment/resource/cleanup_resource)
|
|
|
|
execute_tests
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo End $(basename $0) at $(date)
|