summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/librdkafka-2.1.0/tests/until-fail.sh
blob: 48cbecb0c126c4c96c07cfbc379fec0ddebab551 (plain)
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
#!/bin/bash
#
#
# Run tests, one by one, until a failure.
#
# Usage:
#   ./until-fail.sh [test-runner args] [mode]
#
# mode := bare valgrind helgrind gdb ..
#
# Logs for the last test run is written to _until-fail_<PID>.log.
#

[[ -z "$DELETE_TOPICS" ]] && DELETE_TOPICS=y

if [[ -z $ZK_ADDRESS ]]; then
    ZK_ADDRESS="localhost"
fi

set -e
set -o pipefail  # to have 'run-test.sh | tee' fail if run-test.sh fails.

ARGS=
while [[ $1 == -* ]]; do
    ARGS="$ARGS $1"
    shift
done

modes=$*
if [[ -z "$modes" ]]; then
   modes="valgrind"
fi

if [[ -z "$TESTS" ]]; then
    tests=$(echo 0???-*.c 0???-*.cpp)
else
    tests="$TESTS"
fi

if [[ $modes != gdb ]]; then
    ARGS="-p1 $ARGS"
fi

LOG_FILE="_until_fail_$$.log"

iter=0
while true ; do
    iter=$(expr $iter + 1)

    for t in $tests ; do
        # Strip everything after test number (0001-....)
        t=$(echo $t | cut -d- -f1)

        for mode in $modes ; do

            echo "##################################################"
            echo "##################################################"
            echo "############ Test iteration $iter ################"
            echo "############ Test $t in mode $mode ###############"
            echo "##################################################"
            echo "##################################################"

            if [[ $t == all ]]; then
                unset TESTS
            else
                export TESTS=$t
            fi
            (./run-test.sh $ARGS $mode 2>&1 | tee $LOG_FILE) || (echo "Failed on iteration $iter, test $t, mode $mode, logs in $LOG_FILE" ; exit 1)
        done
    done


    if [[ "$DELETE_TOPICS" == "y" ]]; then
        # Delete topics using Admin API, which is very fast
        # leads to sub-sequent test failures because of the background
        # deletes in Kafka still taking a long time:
        #
        #make delete_topics

        # Delete topic-by-topic using kafka-topics for each one,
        # very slow but topics are properly deleted before the script
        # returns.
        ./delete-test-topics.sh $ZK_ADDRESS || true
    fi
done