Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 1 | #!/bin/sh |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 2 | |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 3 | _help() |
| 4 | { |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 5 | cat << EOF |
| 6 | ### run-regtests.sh ### |
| 7 | Running run-regtests.sh --help shows this information about how to use it |
| 8 | |
| 9 | Run without parameters to run all tests in the current folder (including subfolders) |
| 10 | run-regtests.sh |
| 11 | |
| 12 | Provide paths to run tests from (including subfolders): |
| 13 | run-regtests.sh ./tests1 ./tests2 |
| 14 | |
| 15 | Parameters: |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 16 | --j <NUM>, To run vtest with multiple jobs / threads for a faster overall result |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 17 | run-regtests.sh ./fasttest --j 16 |
| 18 | |
| 19 | --v, to run verbose |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 20 | run-regtests.sh --v, disables the default vtest 'quiet' parameter |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 21 | |
Ilya Shipitsin | 856aabc | 2020-04-16 23:51:34 +0500 | [diff] [blame] | 22 | --debug to show test logs on standard output (implies --v) |
Christopher Faulet | 2a7cf92 | 2018-12-19 10:22:01 +0100 | [diff] [blame] | 23 | run-regtests.sh --debug |
| 24 | |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 25 | --keep-logs to keep all log directories (by default kept if test fails) |
| 26 | run-regtests.sh --keep-logs |
| 27 | |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 28 | --vtestparams <ARGS>, passes custom ARGS to vtest |
| 29 | run-regtests.sh --vtestparams "-n 10" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 30 | |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 31 | --type <reg tests types> filter the types of the tests to be run, depending on |
| 32 | the commented REGTESTS_TYPE variable value in each VTC file. |
Christopher Faulet | 1eee6ca | 2019-12-11 16:26:11 +0100 | [diff] [blame] | 33 | The value of REGTESTS_TYPE supported are: default, slow, bug, broken, devel |
| 34 | and experimental. When not specified, it is set to 'default' as default value. |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 35 | |
| 36 | run-regtest.sh --type slow,default |
| 37 | |
Christopher Faulet | 8d0fdf5 | 2018-12-19 10:18:40 +0100 | [diff] [blame] | 38 | --clean to cleanup previous reg-tests log directories and exit |
| 39 | run-regtests.sh --clean |
| 40 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 41 | Including text below into a .vtc file will check for its requirements |
| 42 | related to haproxy's target and compilation options |
Bertrand Jacquin | 7e30b50 | 2019-05-16 22:15:31 +0100 | [diff] [blame] | 43 | # Below targets are not capable of completing this test successfully |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 44 | #EXCLUDE_TARGET=freebsd, abns sockets are not available on freebsd |
| 45 | |
| 46 | #EXCLUDE_TARGETS=dos,freebsd,windows |
| 47 | |
Bertrand Jacquin | 7e30b50 | 2019-05-16 22:15:31 +0100 | [diff] [blame] | 48 | # Below option is required to complete this test successfully |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 49 | #REQUIRE_OPTION=OPENSSL, this test needs OPENSSL compiled in. |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 50 | #REQUIRE_OPTIONS=ZLIB|SLZ,OPENSSL,LUA |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 51 | |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 52 | #REQUIRE_SERVICE=prometheus-exporter |
| 53 | #REQUIRE_SERVICES=prometheus-exporter,foo |
| 54 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 55 | # To define a range of versions that a test can run with: |
| 56 | #REQUIRE_VERSION=0.0 |
| 57 | #REQUIRE_VERSION_BELOW=99.9 |
| 58 | |
William Lallemand | d5b464b | 2019-12-19 14:30:00 +0100 | [diff] [blame] | 59 | # To define required binaries for a test: |
| 60 | #REQUIRE_BINARIES=socat,curl |
| 61 | |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 62 | Configure environment variables to set the haproxy and vtest binaries to use |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 63 | setenv HAPROXY_PROGRAM /usr/local/sbin/haproxy |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 64 | setenv VTEST_PROGRAM /usr/local/bin/vtest |
Willy Tarreau | a4009cd | 2020-12-16 10:39:20 +0100 | [diff] [blame] | 65 | setenv HAPROXY_ARGS "-dM -de -m 50" |
Frederic Lecaille | d4f36e3 | 2018-12-13 22:15:05 +0100 | [diff] [blame] | 66 | or |
| 67 | export HAPROXY_PROGRAM=/usr/local/sbin/haproxy |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 68 | export VTEST_PROGRAM=/usr/local/bin/vtest |
Willy Tarreau | a4009cd | 2020-12-16 10:39:20 +0100 | [diff] [blame] | 69 | export HAPROXY_ARGS="-dM -de -m 50" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 70 | EOF |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 71 | exit 0 |
| 72 | } |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 73 | |
Frederic Lecaille | d4f36e3 | 2018-12-13 22:15:05 +0100 | [diff] [blame] | 74 | add_range_to_test_list() |
| 75 | { |
| 76 | level0="*.vtc" |
| 77 | level1="h*.vtc" |
| 78 | level2="s*.vtc" |
| 79 | level3="l*.vtc" |
| 80 | level4="b*.vtc" |
| 81 | level5="k*.vtc" |
| 82 | level6="e*.vtc" |
| 83 | |
| 84 | new_range=$(echo $1 | tr '-' ' ') |
| 85 | non_digit=$(echo $new_range | grep '[^0-9 ]') |
| 86 | if [ -n "$non_digit" ] ; then |
| 87 | return |
| 88 | fi |
| 89 | if [ "$new_range" = "$1" ] ; then |
| 90 | if [ $1 -gt 6 ] ; then |
| 91 | return |
| 92 | fi |
| 93 | eval echo '$'level$1 |
| 94 | return |
| 95 | fi |
| 96 | if [ -z "$new_range" ] ; then |
| 97 | return |
| 98 | fi |
| 99 | list= |
| 100 | for l in $(seq $new_range) ; do |
| 101 | if [ -n "l" ] ; then |
| 102 | if [ -z "$list" ] ; then |
| 103 | list="$(eval echo '$'level${l})" |
| 104 | else |
| 105 | list="$list $(eval echo '$'level${l})" |
| 106 | fi |
| 107 | fi |
| 108 | done |
| 109 | |
| 110 | echo $list |
| 111 | } |
| 112 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 113 | _startswith() { |
| 114 | _str="$1" |
| 115 | _sub="$2" |
| 116 | echo "$_str" | grep "^$_sub" >/dev/null 2>&1 |
| 117 | } |
| 118 | |
| 119 | _findtests() { |
| 120 | set -f |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 121 | |
William Lallemand | c1ddcaf | 2021-02-05 11:27:54 +0100 | [diff] [blame] | 122 | REGTESTS_TYPES="${REGTESTS_TYPES:-default,bug,devel,slow}" |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 123 | any_test=$(echo $REGTESTS_TYPES | grep -cw "any") |
| 124 | for i in $( find "$1" -name *.vtc ); do |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 125 | skiptest= |
Willy Tarreau | 939193a | 2018-12-06 15:49:27 +0100 | [diff] [blame] | 126 | require_version="$(sed -ne 's/^#REQUIRE_VERSION=//p' "$i")" |
| 127 | require_version_below="$(sed -ne 's/^#REQUIRE_VERSION_BELOW=//p' "$i")" |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 128 | require_options="$(sed -ne 's/^#REQUIRE_OPTIONS=//p' "$i" | sed -e 's/,/ /g')" |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 129 | require_services="$(sed -ne 's/^#REQUIRE_SERVICES=//p' "$i" | sed -e 's/,/ /g')" |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 130 | exclude_targets="$(sed -ne 's/^#EXCLUDE_TARGETS=//p' "$i" | sed -e 's/,/ /g')" |
William Lallemand | d5b464b | 2019-12-19 14:30:00 +0100 | [diff] [blame] | 131 | require_binaries="$(sed -ne 's/^#REQUIRE_BINARIES=//p' "$i" | sed -e 's/,/ /g')" |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 132 | if [ $any_test -ne 1 ] ; then |
| 133 | regtest_type="$(sed -ne 's/^#REGTEST_TYPE=//p' "$i")" |
| 134 | if [ -z $regtest_type ] ; then |
| 135 | regtest_type=default |
| 136 | fi |
| 137 | if ! $(echo $REGTESTS_TYPES | grep -wq $regtest_type) ; then |
| 138 | echo " Skip $i because its type '"$regtest_type"' is excluded" |
| 139 | skiptest=1 |
| 140 | fi |
| 141 | fi |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 142 | |
| 143 | requiredoption="$(sed -ne 's/^#REQUIRE_OPTION=//p' "$i" | sed -e 's/,.*//')" |
| 144 | if [ -n "$requiredoption" ]; then |
| 145 | require_options="$require_options $requiredoption" |
| 146 | fi |
| 147 | |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 148 | requiredservice="$(sed -ne 's/^#REQUIRE_SERVICE=//p' "$i" | sed -e 's/,.*//')" |
| 149 | if [ -n "$requiredservice" ]; then |
| 150 | require_services="$require_services $requiredservice" |
| 151 | fi |
| 152 | |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 153 | excludedtarget="$(sed -ne 's/^#EXCLUDE_TARGET=//p' "$i" | sed -e 's/,.*//')" |
| 154 | if [ -n "$excludedtarget" ]; then |
| 155 | exclude_targets="$exclude_targets $excludedtarget" |
| 156 | fi |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 157 | |
| 158 | if [ -n "$require_version" ]; then |
| 159 | if [ $(_version "$HAPROXY_VERSION") -lt $(_version "$require_version") ]; then |
| 160 | echo " Skip $i because option haproxy is version: $HAPROXY_VERSION" |
| 161 | echo " REASON: this test requires at least version: $require_version" |
| 162 | skiptest=1 |
| 163 | fi |
| 164 | fi |
| 165 | if [ -n "$require_version_below" ]; then |
| 166 | if [ $(_version "$HAPROXY_VERSION") -ge $(_version "$require_version_below") ]; then |
| 167 | echo " Skip $i because option haproxy is version: $HAPROXY_VERSION" |
| 168 | echo " REASON: this test requires a version below: $require_version_below" |
| 169 | skiptest=1 |
| 170 | fi |
| 171 | fi |
| 172 | |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 173 | for excludedtarget in $exclude_targets; do |
| 174 | if [ "$excludedtarget" = "$TARGET" ]; then |
| 175 | echo " Skip $i because haproxy is compiled for the excluded target $TARGET" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 176 | skiptest=1 |
| 177 | fi |
| 178 | done |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 179 | |
| 180 | for requiredoption in $require_options; do |
| 181 | alternatives=$(echo "$requiredoption" | sed -e 's/|/ /g') |
| 182 | found= |
| 183 | for alt in $alternatives; do |
Willy Tarreau | 87586e1 | 2019-03-27 13:52:39 +0100 | [diff] [blame] | 184 | if echo "$FEATURES" | grep -qw "\+$alt"; then |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 185 | found=1; |
| 186 | fi |
| 187 | done |
| 188 | if [ -z $found ]; then |
| 189 | echo " Skip $i because haproxy is not compiled with the required option $requiredoption" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 190 | skiptest=1 |
| 191 | fi |
| 192 | done |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 193 | |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 194 | for requiredservice in $require_services; do |
| 195 | alternatives=$(echo "$requiredservice" | sed -e 's/|/ /g') |
| 196 | found= |
| 197 | for alt in $alternatives; do |
William Dauchy | 4488434 | 2021-01-10 21:13:05 +0100 | [diff] [blame] | 198 | if echo "$SERVICES" | grep -qw "$alt"; then |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 199 | found=1; |
| 200 | fi |
| 201 | done |
| 202 | if [ -z $found ]; then |
| 203 | echo " Skip $i because haproxy is not compiled with the required service $requiredservice" |
| 204 | skiptest=1 |
| 205 | fi |
| 206 | done |
| 207 | |
William Lallemand | d5b464b | 2019-12-19 14:30:00 +0100 | [diff] [blame] | 208 | for requiredbin in $require_binaries; do |
Ilya Shipitsin | 7faeea9 | 2020-09-26 11:54:27 +0500 | [diff] [blame] | 209 | if ! command -v $requiredbin >/dev/null 2>&1 |
| 210 | then |
William Lallemand | d5b464b | 2019-12-19 14:30:00 +0100 | [diff] [blame] | 211 | echo " Skip $i because '"$requiredbin"' is not installed" |
| 212 | skiptest=1 |
| 213 | fi |
| 214 | done |
| 215 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 216 | if [ -z $skiptest ]; then |
| 217 | echo " Add test: $i" |
| 218 | testlist="$testlist $i" |
| 219 | fi |
| 220 | done |
| 221 | } |
| 222 | |
Christopher Faulet | 8d0fdf5 | 2018-12-19 10:18:40 +0100 | [diff] [blame] | 223 | _cleanup() |
| 224 | { |
| 225 | DIRS=$(find "${TESTDIR}" -maxdepth 1 -type d -name "haregtests-*" -exec basename {} \; 2>/dev/null) |
| 226 | if [ -z "${DIRS}" ]; then |
| 227 | echo "No reg-tests log directory found" |
| 228 | else |
| 229 | echo "Cleanup following reg-tests log directories:" |
| 230 | for d in ${DIRS}; do |
| 231 | echo " o ${TESTDIR}/$d" |
| 232 | done |
| 233 | read -p "Continue (y/n)?" reply |
| 234 | case "$reply" in |
| 235 | y|Y) |
| 236 | for d in ${DIRS}; do |
| 237 | rm -r "${TESTDIR}/$d" |
| 238 | done |
| 239 | echo "done" |
| 240 | exit 0 |
| 241 | ;; |
| 242 | *) |
| 243 | echo "aborted" |
| 244 | exit 1 |
| 245 | ;; |
| 246 | esac |
| 247 | fi |
| 248 | } |
| 249 | |
| 250 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 251 | _process() { |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 252 | while [ ${#} -gt 0 ]; do |
| 253 | if _startswith "$1" "-"; then |
| 254 | case "${1}" in |
| 255 | --j) |
| 256 | jobcount="$2" |
| 257 | shift |
| 258 | ;; |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 259 | --vtestparams) |
| 260 | vtestparams="$2" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 261 | shift |
| 262 | ;; |
| 263 | --v) |
| 264 | verbose="" |
Christopher Faulet | 2a7cf92 | 2018-12-19 10:22:01 +0100 | [diff] [blame] | 265 | ;; |
| 266 | --debug) |
| 267 | verbose="" |
| 268 | debug="-v" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 269 | ;; |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 270 | --keep-logs) |
| 271 | keep_logs="-L" |
| 272 | ;; |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 273 | --type) |
| 274 | REGTESTS_TYPES="$2" |
| 275 | shift |
| 276 | ;; |
Christopher Faulet | 8d0fdf5 | 2018-12-19 10:18:40 +0100 | [diff] [blame] | 277 | --clean) |
| 278 | _cleanup |
| 279 | exit 0 |
| 280 | ;; |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 281 | --help) |
| 282 | _help |
| 283 | ;; |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 284 | *) |
| 285 | echo "Unknown parameter : $1" |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 286 | exit 1 |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 287 | ;; |
| 288 | esac |
| 289 | else |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 290 | REGTESTS="${REGTESTS} $1" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 291 | fi |
| 292 | shift 1 |
| 293 | done |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | _version() { |
| 297 | echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\012", $1,$2,$3,$4); }'; |
| 298 | } |
| 299 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 300 | |
Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 301 | HAPROXY_PROGRAM="${HAPROXY_PROGRAM:-${PWD}/haproxy}" |
Willy Tarreau | a4009cd | 2020-12-16 10:39:20 +0100 | [diff] [blame] | 302 | HAPROXY_ARGS="${HAPROXY_ARGS--dM}" |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 303 | VTEST_PROGRAM="${VTEST_PROGRAM:-vtest}" |
Christopher Faulet | 8d0fdf5 | 2018-12-19 10:18:40 +0100 | [diff] [blame] | 304 | TESTDIR="${TMPDIR:-/tmp}" |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 305 | REGTESTS="" |
| 306 | |
| 307 | jobcount="" |
| 308 | verbose="-q" |
Christopher Faulet | 2a7cf92 | 2018-12-19 10:22:01 +0100 | [diff] [blame] | 309 | debug="" |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 310 | keep_logs="-l" |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 311 | testlist="" |
| 312 | |
| 313 | _process "$@"; |
| 314 | |
| 315 | echo "" |
| 316 | echo "########################## Preparing to run tests ##########################" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 317 | |
| 318 | preparefailed= |
| 319 | if ! [ -x "$(command -v $HAPROXY_PROGRAM)" ]; then |
| 320 | echo "haproxy not found in path, please specify HAPROXY_PROGRAM environment variable" |
| 321 | preparefailed=1 |
| 322 | fi |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 323 | if ! [ -x "$(command -v $VTEST_PROGRAM)" ]; then |
| 324 | echo "vtest not found in path, please specify VTEST_PROGRAM environment variable" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 325 | preparefailed=1 |
| 326 | fi |
| 327 | if [ $preparefailed ]; then |
| 328 | exit 1 |
| 329 | fi |
| 330 | |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 331 | { read HAPROXY_VERSION; read TARGET; read FEATURES; read SERVICES; } << EOF |
Willy Tarreau | 5f3448f | 2021-05-09 06:12:41 +0200 | [diff] [blame] | 332 | $($HAPROXY_PROGRAM $HAPROXY_ARGS -vv | grep 'HA-\?Proxy version\|TARGET.*=\|^Feature\|^Available services' | sed 's/.* [:=] //') |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 333 | EOF |
| 334 | |
| 335 | HAPROXY_VERSION=$(echo $HAPROXY_VERSION | cut -d " " -f 3) |
| 336 | echo "Testing with haproxy version: $HAPROXY_VERSION" |
| 337 | |
| 338 | TESTRUNDATETIME="$(date '+%Y-%m-%d_%H-%M-%S')" |
| 339 | |
Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 340 | mkdir -p "$TESTDIR" || exit 1 |
Christopher Faulet | 8d0fdf5 | 2018-12-19 10:18:40 +0100 | [diff] [blame] | 341 | TESTDIR=$(mktemp -d "$TESTDIR/haregtests-$TESTRUNDATETIME.XXXXXX") || exit 1 |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 342 | |
Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 343 | export TMPDIR="$TESTDIR" |
| 344 | export HAPROXY_PROGRAM="$HAPROXY_PROGRAM" |
Willy Tarreau | a4009cd | 2020-12-16 10:39:20 +0100 | [diff] [blame] | 345 | if [ -n "$HAPROXY_ARGS" ]; then |
| 346 | export HAPROXY_ARGS |
| 347 | fi |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 348 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 349 | echo "Target : $TARGET" |
Willy Tarreau | 87586e1 | 2019-03-27 13:52:39 +0100 | [diff] [blame] | 350 | echo "Options : $FEATURES" |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 351 | echo "Services : $SERVICES" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 352 | |
| 353 | echo "########################## Gathering tests to run ##########################" |
Christopher Faulet | fa6798f | 2018-12-19 11:22:04 +0100 | [diff] [blame] | 354 | |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 355 | if [ -z "$REGTESTS" ]; then |
Willy Tarreau | ca8df4c | 2019-04-23 16:09:50 +0200 | [diff] [blame] | 356 | _findtests reg-tests/ |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 357 | else |
| 358 | for t in $REGTESTS; do |
| 359 | _findtests $t |
| 360 | done |
| 361 | fi |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 362 | |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 363 | echo "########################## Starting vtest ##########################" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 364 | echo "Testing with haproxy version: $HAPROXY_VERSION" |
| 365 | _vtresult=0 |
| 366 | if [ -n "$testlist" ]; then |
| 367 | if [ -n "$jobcount" ]; then |
| 368 | jobcount="-j $jobcount" |
| 369 | fi |
Tim Duesterhus | a9334df | 2021-05-31 23:07:29 +0200 | [diff] [blame] | 370 | cmd="$VTEST_PROGRAM -b $((2<<20)) -k -t 10 $keep_logs $verbose $debug $jobcount $vtestparams $testlist" |
Christopher Faulet | 1ecf0ea | 2018-12-18 22:47:23 +0100 | [diff] [blame] | 371 | eval $cmd |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 372 | _vtresult=$? |
| 373 | else |
| 374 | echo "No tests found that meet the required criteria" |
| 375 | fi |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 376 | |
| 377 | |
| 378 | if [ $_vtresult -eq 0 ]; then |
Bertrand Jacquin | 7e30b50 | 2019-05-16 22:15:31 +0100 | [diff] [blame] | 379 | # all tests were successful, removing tempdir (the last part.) |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 380 | # ignore errors is the directory is not empty or if it does not exist |
| 381 | rmdir "$TESTDIR" 2>/dev/null |
| 382 | fi |
| 383 | |
| 384 | if [ -d "${TESTDIR}" ]; then |
| 385 | echo "########################## Gathering results ##########################" |
Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 386 | export TESTDIR |
| 387 | find "$TESTDIR" -type d -name "vtc.*" -exec sh -c 'for i; do |
| 388 | if [ ! -e "$i/LOG" ] ; then continue; fi |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 389 | |
Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 390 | cat <<- EOF | tee -a "$TESTDIR/failedtests.log" |
| 391 | $(echo "###### $(cat "$i/INFO") ######") |
| 392 | $(echo "## test results in: \"$i\"") |
Frédéric Lécaille | f9a48ef | 2019-01-08 11:30:28 +0100 | [diff] [blame] | 393 | $(grep -E -- "^(----|\* diag)" "$i/LOG") |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 394 | EOF |
Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 395 | done' sh {} + |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 396 | fi |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 397 | |
| 398 | exit $_vtresult |