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 | |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 59 | Configure environment variables to set the haproxy and vtest binaries to use |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 60 | setenv HAPROXY_PROGRAM /usr/local/sbin/haproxy |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 61 | setenv VTEST_PROGRAM /usr/local/bin/vtest |
Willy Tarreau | a4009cd | 2020-12-16 10:39:20 +0100 | [diff] [blame] | 62 | setenv HAPROXY_ARGS "-dM -de -m 50" |
Frederic Lecaille | d4f36e3 | 2018-12-13 22:15:05 +0100 | [diff] [blame] | 63 | or |
| 64 | export HAPROXY_PROGRAM=/usr/local/sbin/haproxy |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 65 | export VTEST_PROGRAM=/usr/local/bin/vtest |
Willy Tarreau | a4009cd | 2020-12-16 10:39:20 +0100 | [diff] [blame] | 66 | export HAPROXY_ARGS="-dM -de -m 50" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 67 | EOF |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 68 | exit 0 |
| 69 | } |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 70 | |
Frederic Lecaille | d4f36e3 | 2018-12-13 22:15:05 +0100 | [diff] [blame] | 71 | add_range_to_test_list() |
| 72 | { |
| 73 | level0="*.vtc" |
| 74 | level1="h*.vtc" |
| 75 | level2="s*.vtc" |
| 76 | level3="l*.vtc" |
| 77 | level4="b*.vtc" |
| 78 | level5="k*.vtc" |
| 79 | level6="e*.vtc" |
| 80 | |
| 81 | new_range=$(echo $1 | tr '-' ' ') |
| 82 | non_digit=$(echo $new_range | grep '[^0-9 ]') |
| 83 | if [ -n "$non_digit" ] ; then |
| 84 | return |
| 85 | fi |
| 86 | if [ "$new_range" = "$1" ] ; then |
| 87 | if [ $1 -gt 6 ] ; then |
| 88 | return |
| 89 | fi |
| 90 | eval echo '$'level$1 |
| 91 | return |
| 92 | fi |
| 93 | if [ -z "$new_range" ] ; then |
| 94 | return |
| 95 | fi |
| 96 | list= |
| 97 | for l in $(seq $new_range) ; do |
| 98 | if [ -n "l" ] ; then |
| 99 | if [ -z "$list" ] ; then |
| 100 | list="$(eval echo '$'level${l})" |
| 101 | else |
| 102 | list="$list $(eval echo '$'level${l})" |
| 103 | fi |
| 104 | fi |
| 105 | done |
| 106 | |
| 107 | echo $list |
| 108 | } |
| 109 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 110 | _startswith() { |
| 111 | _str="$1" |
| 112 | _sub="$2" |
| 113 | echo "$_str" | grep "^$_sub" >/dev/null 2>&1 |
| 114 | } |
| 115 | |
| 116 | _findtests() { |
| 117 | set -f |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 118 | |
William Lallemand | c1ddcaf | 2021-02-05 11:27:54 +0100 | [diff] [blame] | 119 | REGTESTS_TYPES="${REGTESTS_TYPES:-default,bug,devel,slow}" |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 120 | any_test=$(echo $REGTESTS_TYPES | grep -cw "any") |
| 121 | for i in $( find "$1" -name *.vtc ); do |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 122 | skiptest= |
Willy Tarreau | 969e7af | 2021-11-18 13:49:01 +0100 | [diff] [blame] | 123 | OLDIFS="$IFS"; IFS="$LINEFEED" |
| 124 | set -- $(grep '^#[0-9A-Z_]*=' "$i") |
| 125 | IFS="$OLDIFS" |
| 126 | |
| 127 | require_version=""; require_version_below=""; require_options=""; |
| 128 | require_services=""; exclude_targets=""; regtest_type="" |
| 129 | requiredoption=""; requiredservice=""; excludedtarget=""; |
| 130 | |
| 131 | while [ $# -gt 0 ]; do |
| 132 | v="$1"; v="${v#*=}" |
| 133 | case "$1" in |
| 134 | "#REQUIRE_VERSION="*) require_version="$v" ;; |
| 135 | "#REQUIRE_VERSION_BELOW="*) require_version_below="$v" ;; |
| 136 | "#REQUIRE_OPTIONS="*) require_options="$v" ;; |
| 137 | "#REQUIRE_SERVICES="*) require_services="$v" ;; |
| 138 | "#EXCLUDE_TARGETS="*) exclude_targets="$v" ;; |
| 139 | "#REGTEST_TYPE="*) regtest_type="$v" ;; |
| 140 | "#REQUIRE_OPTION="*) requiredoption="${v%,*}" ;; |
| 141 | "#REQUIRE_SERVICE="*) required_service="${v%,*}" ;; |
| 142 | "#EXCLUDE_TARGET="*) excludedtarget="${v%,*}" ;; |
| 143 | # Note: any new variable declared here must be initialized above. |
| 144 | esac |
| 145 | shift |
| 146 | done |
| 147 | |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 148 | if [ $any_test -ne 1 ] ; then |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 149 | if [ -z $regtest_type ] ; then |
| 150 | regtest_type=default |
| 151 | fi |
| 152 | if ! $(echo $REGTESTS_TYPES | grep -wq $regtest_type) ; then |
| 153 | echo " Skip $i because its type '"$regtest_type"' is excluded" |
| 154 | skiptest=1 |
| 155 | fi |
| 156 | fi |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 157 | |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 158 | if [ -n "$requiredoption" ]; then |
Willy Tarreau | 969e7af | 2021-11-18 13:49:01 +0100 | [diff] [blame] | 159 | require_options="$require_options,$requiredoption" |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 160 | fi |
| 161 | |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 162 | if [ -n "$requiredservice" ]; then |
Willy Tarreau | 969e7af | 2021-11-18 13:49:01 +0100 | [diff] [blame] | 163 | require_services="$require_services,$requiredservice" |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 164 | fi |
| 165 | |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 166 | if [ -n "$excludedtarget" ]; then |
Willy Tarreau | 969e7af | 2021-11-18 13:49:01 +0100 | [diff] [blame] | 167 | exclude_targets="$exclude_targets,$excludedtarget" |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 168 | fi |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 169 | |
Willy Tarreau | 969e7af | 2021-11-18 13:49:01 +0100 | [diff] [blame] | 170 | IFS=","; set -- $require_options; IFS=$OLDIFS; require_options="$*" |
| 171 | IFS=","; set -- $require_services; IFS=$OLDIFS; require_services="$*" |
| 172 | IFS=","; set -- $exclude_targets; IFS=$OLDIFS; exclude_targets="$*" |
| 173 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 174 | if [ -n "$require_version" ]; then |
| 175 | if [ $(_version "$HAPROXY_VERSION") -lt $(_version "$require_version") ]; then |
| 176 | echo " Skip $i because option haproxy is version: $HAPROXY_VERSION" |
| 177 | echo " REASON: this test requires at least version: $require_version" |
| 178 | skiptest=1 |
| 179 | fi |
| 180 | fi |
| 181 | if [ -n "$require_version_below" ]; then |
| 182 | if [ $(_version "$HAPROXY_VERSION") -ge $(_version "$require_version_below") ]; then |
| 183 | echo " Skip $i because option haproxy is version: $HAPROXY_VERSION" |
| 184 | echo " REASON: this test requires a version below: $require_version_below" |
| 185 | skiptest=1 |
| 186 | fi |
| 187 | fi |
| 188 | |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 189 | for excludedtarget in $exclude_targets; do |
| 190 | if [ "$excludedtarget" = "$TARGET" ]; then |
| 191 | echo " Skip $i because haproxy is compiled for the excluded target $TARGET" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 192 | skiptest=1 |
| 193 | fi |
| 194 | done |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 195 | |
| 196 | for requiredoption in $require_options; do |
Willy Tarreau | 969e7af | 2021-11-18 13:49:01 +0100 | [diff] [blame] | 197 | IFS="|"; set -- $requiredoption; IFS=$OLDIFS; alternatives="$*" |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 198 | found= |
| 199 | for alt in $alternatives; do |
Willy Tarreau | 0b3eb81 | 2021-11-18 15:05:45 +0100 | [diff] [blame] | 200 | if [ -z "${FEATURES_PATTERN##* +$alt *}" ]; then |
Christopher Faulet | 7e245df | 2018-12-21 15:18:02 +0100 | [diff] [blame] | 201 | found=1; |
| 202 | fi |
| 203 | done |
| 204 | if [ -z $found ]; then |
| 205 | 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] | 206 | skiptest=1 |
| 207 | fi |
| 208 | done |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 209 | |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 210 | for requiredservice in $require_services; do |
Willy Tarreau | 969e7af | 2021-11-18 13:49:01 +0100 | [diff] [blame] | 211 | IFS="|"; set -- $requiredservice; IFS=$OLDIFS; alternatives="$*" |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 212 | found= |
| 213 | for alt in $alternatives; do |
Willy Tarreau | 0b3eb81 | 2021-11-18 15:05:45 +0100 | [diff] [blame] | 214 | if [ -z "${SERVICES_PATTERN##* $alt *}" ]; then |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 215 | found=1; |
| 216 | fi |
| 217 | done |
| 218 | if [ -z $found ]; then |
| 219 | echo " Skip $i because haproxy is not compiled with the required service $requiredservice" |
| 220 | skiptest=1 |
| 221 | fi |
| 222 | done |
| 223 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 224 | if [ -z $skiptest ]; then |
| 225 | echo " Add test: $i" |
| 226 | testlist="$testlist $i" |
| 227 | fi |
| 228 | done |
| 229 | } |
| 230 | |
Christopher Faulet | 8d0fdf5 | 2018-12-19 10:18:40 +0100 | [diff] [blame] | 231 | _cleanup() |
| 232 | { |
| 233 | DIRS=$(find "${TESTDIR}" -maxdepth 1 -type d -name "haregtests-*" -exec basename {} \; 2>/dev/null) |
| 234 | if [ -z "${DIRS}" ]; then |
| 235 | echo "No reg-tests log directory found" |
| 236 | else |
| 237 | echo "Cleanup following reg-tests log directories:" |
| 238 | for d in ${DIRS}; do |
| 239 | echo " o ${TESTDIR}/$d" |
| 240 | done |
| 241 | read -p "Continue (y/n)?" reply |
| 242 | case "$reply" in |
| 243 | y|Y) |
| 244 | for d in ${DIRS}; do |
| 245 | rm -r "${TESTDIR}/$d" |
| 246 | done |
| 247 | echo "done" |
| 248 | exit 0 |
| 249 | ;; |
| 250 | *) |
| 251 | echo "aborted" |
| 252 | exit 1 |
| 253 | ;; |
| 254 | esac |
| 255 | fi |
| 256 | } |
| 257 | |
| 258 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 259 | _process() { |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 260 | while [ ${#} -gt 0 ]; do |
| 261 | if _startswith "$1" "-"; then |
| 262 | case "${1}" in |
| 263 | --j) |
| 264 | jobcount="$2" |
| 265 | shift |
| 266 | ;; |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 267 | --vtestparams) |
| 268 | vtestparams="$2" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 269 | shift |
| 270 | ;; |
| 271 | --v) |
| 272 | verbose="" |
Christopher Faulet | 2a7cf92 | 2018-12-19 10:22:01 +0100 | [diff] [blame] | 273 | ;; |
| 274 | --debug) |
| 275 | verbose="" |
| 276 | debug="-v" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 277 | ;; |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 278 | --keep-logs) |
| 279 | keep_logs="-L" |
| 280 | ;; |
Frédéric Lécaille | dc1a3bd | 2019-03-29 15:07:24 +0100 | [diff] [blame] | 281 | --type) |
| 282 | REGTESTS_TYPES="$2" |
| 283 | shift |
| 284 | ;; |
Christopher Faulet | 8d0fdf5 | 2018-12-19 10:18:40 +0100 | [diff] [blame] | 285 | --clean) |
| 286 | _cleanup |
| 287 | exit 0 |
| 288 | ;; |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 289 | --help) |
| 290 | _help |
| 291 | ;; |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 292 | *) |
| 293 | echo "Unknown parameter : $1" |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 294 | exit 1 |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 295 | ;; |
| 296 | esac |
| 297 | else |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 298 | REGTESTS="${REGTESTS} $1" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 299 | fi |
| 300 | shift 1 |
| 301 | done |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 302 | } |
| 303 | |
Willy Tarreau | b7a28e7 | 2021-11-18 15:32:16 +0100 | [diff] [blame] | 304 | # compute a version from up to 4 sub-version components, each multiplied |
| 305 | # by a power of 1000, and padded left with 0, 1 or 2 zeroes. |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 306 | _version() { |
Willy Tarreau | b7a28e7 | 2021-11-18 15:32:16 +0100 | [diff] [blame] | 307 | OLDIFS="$IFS"; IFS="."; set -- $*; IFS="$OLDIFS" |
| 308 | set -- ${1%%[!0-9]*} 000${2%%[!0-9]*} 000${3%%[!0-9]*} 000${4%%[!0-9]*} |
| 309 | prf2=${2%???}; prf3=${3%???}; prf4=${4%???} |
| 310 | echo ${1}${2#$prf2}${3#$prf3}${4#$prf4} |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 311 | } |
| 312 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 313 | |
Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 314 | HAPROXY_PROGRAM="${HAPROXY_PROGRAM:-${PWD}/haproxy}" |
Willy Tarreau | a4009cd | 2020-12-16 10:39:20 +0100 | [diff] [blame] | 315 | HAPROXY_ARGS="${HAPROXY_ARGS--dM}" |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 316 | VTEST_PROGRAM="${VTEST_PROGRAM:-vtest}" |
Christopher Faulet | 8d0fdf5 | 2018-12-19 10:18:40 +0100 | [diff] [blame] | 317 | TESTDIR="${TMPDIR:-/tmp}" |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 318 | REGTESTS="" |
Willy Tarreau | 969e7af | 2021-11-18 13:49:01 +0100 | [diff] [blame] | 319 | LINEFEED=" |
| 320 | " |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 321 | |
| 322 | jobcount="" |
| 323 | verbose="-q" |
Christopher Faulet | 2a7cf92 | 2018-12-19 10:22:01 +0100 | [diff] [blame] | 324 | debug="" |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 325 | keep_logs="-l" |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 326 | testlist="" |
| 327 | |
| 328 | _process "$@"; |
| 329 | |
| 330 | echo "" |
| 331 | echo "########################## Preparing to run tests ##########################" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 332 | |
| 333 | preparefailed= |
| 334 | if ! [ -x "$(command -v $HAPROXY_PROGRAM)" ]; then |
| 335 | echo "haproxy not found in path, please specify HAPROXY_PROGRAM environment variable" |
| 336 | preparefailed=1 |
| 337 | fi |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 338 | if ! [ -x "$(command -v $VTEST_PROGRAM)" ]; then |
| 339 | echo "vtest not found in path, please specify VTEST_PROGRAM environment variable" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 340 | preparefailed=1 |
| 341 | fi |
| 342 | if [ $preparefailed ]; then |
| 343 | exit 1 |
| 344 | fi |
| 345 | |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 346 | { read HAPROXY_VERSION; read TARGET; read FEATURES; read SERVICES; } << EOF |
Willy Tarreau | 5f3448f | 2021-05-09 06:12:41 +0200 | [diff] [blame] | 347 | $($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] | 348 | EOF |
| 349 | |
| 350 | HAPROXY_VERSION=$(echo $HAPROXY_VERSION | cut -d " " -f 3) |
| 351 | echo "Testing with haproxy version: $HAPROXY_VERSION" |
| 352 | |
Willy Tarreau | 9d5e116 | 2022-11-30 18:44:33 +0100 | [diff] [blame] | 353 | PROJECT_VERSION=$(${MAKE:-make} version 2>&1 | grep '^VERSION:\|^SUBVERS:'|cut -f2 -d' '|tr -d '\012') |
| 354 | if [ -z "${PROJECT_VERSION}${MAKE}" ]; then |
| 355 | # try again with gmake, just in case |
| 356 | PROJECT_VERSION=$(gmake version 2>&1 | grep '^VERSION:\|^SUBVERS:'|cut -f2 -d' '|tr -d '\012') |
| 357 | fi |
| 358 | |
Willy Tarreau | 0b3eb81 | 2021-11-18 15:05:45 +0100 | [diff] [blame] | 359 | FEATURES_PATTERN=" $FEATURES " |
| 360 | SERVICES_PATTERN=" $SERVICES " |
| 361 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 362 | TESTRUNDATETIME="$(date '+%Y-%m-%d_%H-%M-%S')" |
| 363 | |
Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 364 | mkdir -p "$TESTDIR" || exit 1 |
Christopher Faulet | 8d0fdf5 | 2018-12-19 10:18:40 +0100 | [diff] [blame] | 365 | TESTDIR=$(mktemp -d "$TESTDIR/haregtests-$TESTRUNDATETIME.XXXXXX") || exit 1 |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 366 | |
Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 367 | export TMPDIR="$TESTDIR" |
| 368 | export HAPROXY_PROGRAM="$HAPROXY_PROGRAM" |
Willy Tarreau | a4009cd | 2020-12-16 10:39:20 +0100 | [diff] [blame] | 369 | if [ -n "$HAPROXY_ARGS" ]; then |
| 370 | export HAPROXY_ARGS |
| 371 | fi |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 372 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 373 | echo "Target : $TARGET" |
Willy Tarreau | 87586e1 | 2019-03-27 13:52:39 +0100 | [diff] [blame] | 374 | echo "Options : $FEATURES" |
William Dauchy | aabde71 | 2021-01-09 17:26:20 +0100 | [diff] [blame] | 375 | echo "Services : $SERVICES" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 376 | |
| 377 | echo "########################## Gathering tests to run ##########################" |
Christopher Faulet | fa6798f | 2018-12-19 11:22:04 +0100 | [diff] [blame] | 378 | |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 379 | if [ -z "$REGTESTS" ]; then |
Willy Tarreau | ca8df4c | 2019-04-23 16:09:50 +0200 | [diff] [blame] | 380 | _findtests reg-tests/ |
Christopher Faulet | 8d67cf8 | 2018-12-18 22:41:20 +0100 | [diff] [blame] | 381 | else |
| 382 | for t in $REGTESTS; do |
| 383 | _findtests $t |
| 384 | done |
| 385 | fi |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 386 | |
Frédéric Lécaille | 4336123 | 2019-01-11 10:10:21 +0100 | [diff] [blame] | 387 | echo "########################## Starting vtest ##########################" |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 388 | echo "Testing with haproxy version: $HAPROXY_VERSION" |
Willy Tarreau | 9d5e116 | 2022-11-30 18:44:33 +0100 | [diff] [blame] | 389 | |
| 390 | if [ -n "$PROJECT_VERSION" -a "$PROJECT_VERSION" != "$HAPROXY_VERSION" ]; then |
| 391 | echo "Warning: version does not match the current tree ($PROJECT_VERSION)" |
| 392 | fi |
| 393 | |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 394 | _vtresult=0 |
| 395 | if [ -n "$testlist" ]; then |
| 396 | if [ -n "$jobcount" ]; then |
| 397 | jobcount="-j $jobcount" |
| 398 | fi |
Tim Duesterhus | a9334df | 2021-05-31 23:07:29 +0200 | [diff] [blame] | 399 | 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] | 400 | eval $cmd |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 401 | _vtresult=$? |
| 402 | else |
| 403 | echo "No tests found that meet the required criteria" |
| 404 | fi |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 405 | |
| 406 | |
| 407 | if [ $_vtresult -eq 0 ]; then |
Bertrand Jacquin | 7e30b50 | 2019-05-16 22:15:31 +0100 | [diff] [blame] | 408 | # all tests were successful, removing tempdir (the last part.) |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 409 | # ignore errors is the directory is not empty or if it does not exist |
| 410 | rmdir "$TESTDIR" 2>/dev/null |
| 411 | fi |
| 412 | |
| 413 | if [ -d "${TESTDIR}" ]; then |
| 414 | echo "########################## Gathering results ##########################" |
Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 415 | export TESTDIR |
| 416 | find "$TESTDIR" -type d -name "vtc.*" -exec sh -c 'for i; do |
| 417 | if [ ! -e "$i/LOG" ] ; then continue; fi |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 418 | |
Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 419 | cat <<- EOF | tee -a "$TESTDIR/failedtests.log" |
| 420 | $(echo "###### $(cat "$i/INFO") ######") |
| 421 | $(echo "## test results in: \"$i\"") |
Frédéric Lécaille | f9a48ef | 2019-01-08 11:30:28 +0100 | [diff] [blame] | 422 | $(grep -E -- "^(----|\* diag)" "$i/LOG") |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 423 | EOF |
Frédéric Lécaille | 51e01b5 | 2018-11-29 21:41:42 +0100 | [diff] [blame] | 424 | done' sh {} + |
PiBa-NL | 7250404 | 2018-11-27 22:26:38 +0100 | [diff] [blame] | 425 | fi |
Christopher Faulet | 9c6df5e | 2018-12-19 10:25:07 +0100 | [diff] [blame] | 426 | |
| 427 | exit $_vtresult |