summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorWilliam Dauchy <wdauchy@gmail.com>2021-01-09 17:26:20 +0100
committerWilly Tarreau <w@1wt.eu>2021-01-10 07:42:33 +0100
commitaabde7133242563109b4f36c42e732f083bddf4d (patch)
treecc3667226c1430345a0ca76d4ac7a7c6cbd126a6 /scripts
parent5417e898ff0334c9693c1e773a840a4f37512b3d (diff)
downloadhaproxy-aabde7133242563109b4f36c42e732f083bddf4d.tar.gz
MINOR: reg-tests: add a way to add service dependency
I was looking at writing a simple first test for prometheus but I realised there is no proper way to exclude it if haproxy was not built with prometheus plugin. Today we have `REQUIRE_OPTIONS` in reg-tests which is based on `Feature list` from `haproxy -vv`. Those options are coming from the Makefile itself. A plugin is build this way: EXTRA_OBJS="contrib/prometheus-exporter/service-prometheus.o" It does register service actions through `service_keywords_register`. Those are listed through `list_services` in `haproxy -vv`. To facilitate parsing, I slightly changed the output to a single line and integrate it in regtests shell script so that we can now specify a dependency while writing a reg-test for prometheus, e.g: #REQUIRE_SERVICE=prometheus-exporter #REQUIRE_SERVICES=prometheus-exporter,foo There might be other ways to handle this, but that's the cleanest I found; I understand people might be concerned by this output change in `haproxy -vv` which goes from: Available services : foo bar to: Available services : foo bar Signed-off-by: William Dauchy <wdauchy@gmail.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/run-regtests.sh29
1 files changed, 26 insertions, 3 deletions
diff --git a/scripts/run-regtests.sh b/scripts/run-regtests.sh
index da20ae3dd..e6cb0e6cf 100755
--- a/scripts/run-regtests.sh
+++ b/scripts/run-regtests.sh
@@ -56,9 +56,11 @@ _help()
# Below option is required to complete this test successfully
#REQUIRE_OPTION=OPENSSL, this test needs OPENSSL compiled in.
-
#REQUIRE_OPTIONS=ZLIB|SLZ,OPENSSL,LUA
+ #REQUIRE_SERVICE=prometheus-exporter
+ #REQUIRE_SERVICES=prometheus-exporter,foo
+
# To define a range of versions that a test can run with:
#REQUIRE_VERSION=0.0
#REQUIRE_VERSION_BELOW=99.9
@@ -133,6 +135,7 @@ _findtests() {
require_version="$(sed -ne 's/^#REQUIRE_VERSION=//p' "$i")"
require_version_below="$(sed -ne 's/^#REQUIRE_VERSION_BELOW=//p' "$i")"
require_options="$(sed -ne 's/^#REQUIRE_OPTIONS=//p' "$i" | sed -e 's/,/ /g')"
+ require_services="$(sed -ne 's/^#REQUIRE_SERVICES=//p' "$i" | sed -e 's/,/ /g')"
exclude_targets="$(sed -ne 's/^#EXCLUDE_TARGETS=//p' "$i" | sed -e 's/,/ /g')"
require_binaries="$(sed -ne 's/^#REQUIRE_BINARIES=//p' "$i" | sed -e 's/,/ /g')"
if [ $any_test -ne 1 ] ; then
@@ -151,6 +154,11 @@ _findtests() {
require_options="$require_options $requiredoption"
fi
+ requiredservice="$(sed -ne 's/^#REQUIRE_SERVICE=//p' "$i" | sed -e 's/,.*//')"
+ if [ -n "$requiredservice" ]; then
+ require_services="$require_services $requiredservice"
+ fi
+
excludedtarget="$(sed -ne 's/^#EXCLUDE_TARGET=//p' "$i" | sed -e 's/,.*//')"
if [ -n "$excludedtarget" ]; then
exclude_targets="$exclude_targets $excludedtarget"
@@ -192,6 +200,20 @@ _findtests() {
fi
done
+ for requiredservice in $require_services; do
+ alternatives=$(echo "$requiredservice" | sed -e 's/|/ /g')
+ found=
+ for alt in $alternatives; do
+ if echo "$SERVICES" | grep -qw "\+$alt"; then
+ found=1;
+ fi
+ done
+ if [ -z $found ]; then
+ echo " Skip $i because haproxy is not compiled with the required service $requiredservice"
+ skiptest=1
+ fi
+ done
+
for requiredbin in $require_binaries; do
if ! command -v $requiredbin >/dev/null 2>&1
then
@@ -322,8 +344,8 @@ if [ $preparefailed ]; then
exit 1
fi
-{ read HAPROXY_VERSION; read TARGET; read FEATURES; } << EOF
-$($HAPROXY_PROGRAM $HAPROXY_ARGS -vv |grep 'HA-Proxy version\|TARGET.*=\|^Feature' | sed 's/.* [:=] //')
+{ read HAPROXY_VERSION; read TARGET; read FEATURES; read SERVICES; } << EOF
+$($HAPROXY_PROGRAM $HAPROXY_ARGS -vv | grep 'HA-Proxy version\|TARGET.*=\|^Feature\|^Available services' | sed 's/.* [:=] //')
EOF
HAPROXY_VERSION=$(echo $HAPROXY_VERSION | cut -d " " -f 3)
@@ -342,6 +364,7 @@ fi
echo "Target : $TARGET"
echo "Options : $FEATURES"
+echo "Services : $SERVICES"
echo "########################## Gathering tests to run ##########################"
# if htx is enable, but HAProxy version is lower to 1.9, disable it