Repository: mesos Updated Branches: refs/heads/master 8c4f45d67 -> bf8eb0f82
Added 'timed_tests.sh' script to help investigate the cause of hanging tests. Review: https://reviews.apache.org/r/23700 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/bf8eb0f8 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/bf8eb0f8 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/bf8eb0f8 Branch: refs/heads/master Commit: bf8eb0f82df2e743149aa7f65ccdcccf3f8142da Parents: 8c4f45d Author: Jiang Yan Xu <y...@jxu.me> Authored: Fri Jul 18 12:57:46 2014 -0700 Committer: Jiang Yan Xu <y...@jxu.me> Committed: Thu Aug 7 15:15:34 2014 -0700 ---------------------------------------------------------------------- support/timed_tests.sh | 78 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/bf8eb0f8/support/timed_tests.sh ---------------------------------------------------------------------- diff --git a/support/timed_tests.sh b/support/timed_tests.sh new file mode 100755 index 0000000..e060966 --- /dev/null +++ b/support/timed_tests.sh @@ -0,0 +1,78 @@ +#!/usr/bin/setsid bash + +# TODO(xujyan): Make the script OSX compatible. +function usage { +cat <<EOF + +Run Mesos tests within a duration and attach gdb if the tests time out. This +script will run the test command under the current work directory. To put the +time limit only on tests, compile the project before runing the script. This +script works only on Linux. + +Usage: $0 [-h] <test_cmd> <duration> + + test_cmd Command that runs the tests. + e.g., MESOS_VERBOSE=1 make check GTEST_SHUFFLE=1 + duration Duration (in seconds) before the tests time out. + e.g., 3600, \$((160 * 60)) + -h Print this help message and exit +EOF +} + +die () { + echo >&2 "$@" + exit 1 +} + +if test ${#} -ne 2; then + usage + exit 1 +fi + +test_cmd=$1 +duration=$2 + +echo "This script runs with session id $$ and can be terminated by: pkill -s $$" + +echo -n `date`; echo ": start running $test_cmd" + +start=$(date +"%s") +eval $test_cmd & + +test_cmd_pid=$! + +while [ $(($(date +"%s") - $start)) -lt $duration ]; do + running=`ps p $test_cmd_pid h | wc -l` + if [ $running -eq 0 ]; then + echo "Test finished" + exit 0 + fi + + sleep 5 +done + +echo -n `date`; echo ": process still running after $duration seconds" + +tmp=`mktemp XXXXX` +echo "thread apply all bt" > $tmp + +for test_pid in $( pgrep -s 0 ); do + cat <<EOF +========== + +Attaching gdb to `ps o pid,cmd p $test_pid h` + +========== +EOF + + gdb attach $test_pid < $tmp +done + +rm $tmp + +echo "Test failed and killing the stuck test process" + +# Kill all processes in the test process session. +pkill -s 0 + +exit 1 \ No newline at end of file