File: run.stress-tests-forever.bash

package info (click to toggle)
mariadb-10.0 10.0.16-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 416,512 kB
  • sloc: cpp: 1,351,103; ansic: 803,086; perl: 59,621; pascal: 32,136; sh: 25,156; yacc: 14,897; xml: 5,194; sql: 4,651; cs: 4,647; makefile: 4,113; python: 2,526; ruby: 2,496; lex: 1,427; asm: 295; awk: 54; php: 22; sed: 16
file content (97 lines) | stat: -rwxr-xr-x 3,011 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# $Id: run.stress-tests.bash 38773 2012-01-13 20:35:00Z leifwalsh $

set -e

scriptname=$(basename "$0")
toku_toplevel=$(dirname $(dirname $(readlink -f "$PWD/$0")))

src_tests="${toku_toplevel}/src/tests"
testnames=(test_stress1.tdb \
           test_stress5.tdb \
           test_stress6.tdb)

declare -a pids=(0)
i=0

savepid() {
    pids[$i]=$1
    (( i = i + 1 ))
}

killchildren() {
    kill ${pids[@]} || true
    for exec in ${testnames[@]}
    do
        pkill -f $exec || true
    done
}

trap killchildren INT TERM EXIT

run_test() {
    exec="$1"; shift
    table_size="$1"; shift
    cachetable_size="$1"; shift
    num_ptquery="$1"; shift
    num_update="$1"; shift

    rundir=$(mktemp -d ./rundir.XXXXXXXX)
    tmplog=$(mktemp)

    ulimit -c unlimited
    t0="$(date)"
    t1=""
    envdir="../${exec}-${table_size}-${cachetable_size}-${num_ptquery}-${num_update}-forever-$$.dir"
    cd $rundir
    if LD_LIBRARY_PATH=../../../lib:$LD_LIBRARY_PATH \
        ../$exec -v --only_create --envdir "$envdir" \
        --num_elements $table_size \
        --cachetable_size $cachetable_size &> $tmplog
    then
        rm -f $tmplog
        t1="$(date)"
        echo "Running $exec -v --only_stress --num_seconds 0 --envdir \"$envdir\" --num_elements $table_size --cachetable_size $cachetable_size --num_ptquery_threads $num_ptquery --no-crash_on_update_failure --num_update_threads $num_update &> $tmplog in $rundir."
        (LD_LIBRARY_PATH=../../../lib:$LD_LIBRARY_PATH \
            ../$exec -v --only_stress --num_seconds 0 --envdir "$envdir" \
            --num_elements $table_size \
            --cachetable_size $cachetable_size \
            --num_ptquery_threads $num_ptquery \
            --no-crash_on_update_failure \
            --num_update_threads $num_update &> $tmplog) & mypid=$!
        savepid $mypid
        while true
        do
            sleep 10s
            cpu=$(ps -o pcpu -p $mypid h)
            if [[ -z $cpu ]]
            then
                echo "Process $mypid must have crashed: $exec,$table_size,$cachetable_size,$num_ptquery,$num_update,$t0,$t1,FAIL" 1>&2
                echo "Check rundir $rundir, envdir $envdir, corefile core.$mypid." 1>&2
                return
            fi
            if expr $cpu == 0.0 &>/dev/null
            then
                echo "Deadlock detected in process $mypid: $exec,$table_size,$cachetable_size,$num_ptquery,$num_update,$t0,$t1,FAIL" 1>&2
                echo "Check rundir $rundir, envdir $envdir, corefile core.$mypid." 1>&2
                return
            fi
        done
    else
        echo "Create phase failed: $exec,$table_size,$cachetable_size,$num_ptquery,$num_update,$t0,$t1,FAIL" 1>&2
    fi
    cd ..
    rm -rf $rundir "$envdir"
}

cd $src_tests
for exec in ${testnames[@]}
do
    for table_size in 2000 200000 50000000
    do
        (( small_cachetable = table_size * 50 ))
        run_test $exec $table_size $small_cachetable 4 4 & savepid $!
    done
done

wait ${pids[@]} || true