From 1bc72e69dc0e2def3bbf4a805175cd8e765a7013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Chlup?= Date: Mon, 25 Sep 2023 15:59:27 +0200 Subject: [PATCH 1/3] Tweak testsuite.sh output --- test/testsuite.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/testsuite.sh b/test/testsuite.sh index a70f02da5..7663b7f3a 100644 --- a/test/testsuite.sh +++ b/test/testsuite.sh @@ -43,6 +43,7 @@ if [ ! -d tomcat/target ]; then exit 4 fi +echo -n "Creating docker containers..." if [ ! -z ${DEBUG+x} ]; then httpd_create || exit 2 tomcat_create || exit 3 @@ -50,6 +51,7 @@ else httpd_create > /dev/null 2>&1 || exit 2 tomcat_create > /dev/null 2>&1 || exit 3 fi +echo " Done" # clean everything at first echo -n "Cleaning possibly running containers..." @@ -99,8 +101,10 @@ MPC_CONF=httpd/mod_lbmethod_cluster.conf run_test MODCLUSTER-794/testit.sh "MO res=$(expr $res + $?) -echo "Clean remaining httpd containers" -httpd_all_clean +echo -n "Cleaning containers if any..." +httpd_all_clean > /dev/null 2>&1 +tomcat_all_remove > /dev/null 2>&1 +echo " Done" if [ $res -eq 0 ]; then echo "Tests finished successfully!" From 2f9f86c8226631deb2baeb8b588915a0965b8d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Chlup?= Date: Mon, 25 Sep 2023 16:09:31 +0200 Subject: [PATCH 2/3] Use portOffset for tomcat containers, update tomcat_start function --- test/includes/common.sh | 35 ++++++++++++++----------------- test/tomcat/Dockerfile | 5 +---- test/tomcat/server.xml | 23 ++++++++++++++------- test/tomcat/start.sh | 46 ++++------------------------------------- 4 files changed, 37 insertions(+), 72 deletions(-) diff --git a/test/includes/common.sh b/test/includes/common.sh index e7b254f8a..f5496f72d 100644 --- a/test/includes/common.sh +++ b/test/includes/common.sh @@ -116,33 +116,31 @@ tomcat_create() { --build-arg TESTSUITE_TOMCAT_CONTEXT=${3:-context.xml} } -# Start tomcat$1 container on 127.0.0.$2 -# or 127.0.0.$1 if $2 is not given -# arguments: -# $1 tomcat number (required) -# $2 tomcat's last byte of IPv4 address (if 0 or omitted, equals to $1) -# $3 tomcat port (if omitted it's 8080 + $1 - 1) -# $4 tomcat ajp port (if omitted it's 8900 + $1 - 1) -# $5 tomcat shutdown port (if omitted it's 8005 + $1 - 1) +# Start tomcat$1 container on 127.0.0.$2 or 127.0.0.$1 if $2 is not given. +# Ports are set by default as follows +# * tomcat port 8080 + $1 - 1 +# * tomcat ajp port 8900 + $1 - 1 +# * tomcat shutdown port 8005 + $1 - 1 +# $1 has to be in range [1, 75]. tomcat_start() { if [ -z "$1" ]; then echo "tomcat_start called without arguments" exit 1 fi + + if [ $1 -le 0 ] || [ $1 -gt 75 ]; then + echo "tomcat_start called with invalid \$1 value (got $1, allowed [1, 75])" + exit 2 + fi ADDR="127.0.0.$1" if [ ${2:-0} -ne 0 ]; then ADDR="127.0.0.$2" fi - local portdef=$(expr 8080 + $1 - 1) - local ajpdef=$(expr 8900 + $1 - 1) - local shutdef=$(expr 8005 + $1 - 1) - - echo "Starting tomcat$1 on $ADDR" - nohup docker run --network=host -e tomcat_ajp_port=${4:-$ajpdef} \ - -e tomcat_address=$ADDR \ - -e tomcat_port=${3:-$portdef} \ - -e tomcat_shutdown_port=${5:-$shutdef} \ + local OFFSET=$(expr $1 - 1) + echo "Starting tomcat$1 on $ADDR:$(expr 8080 + $OFFSET)" + nohup docker run --network=host -e tomcat_address=$ADDR \ + -e tomcat_port_offset=$OFFSET \ -e jvm_route=tomcat$1 \ --name tomcat$1 ${IMG} & ps -q $! > /dev/null @@ -268,7 +266,6 @@ tomcat_start_webapp() { # arguments: # $1 tomcat number # $2 the last segment of IPv4 addr ($1 by default) -# $3 the shutdown port (8005 + $1 - 1 by default) tomcat_shutdown() { ADDR="127.0.0.$1" if [ $2 -ne 0 ]; then @@ -276,7 +273,7 @@ tomcat_shutdown() { fi echo "shutting down tomcat$1 with address: $ADDR" - echo "SHUTDOWN" | nc $ADDR ${3:-$(expr 8005 + $1 - 1)} + echo "SHUTDOWN" | nc $ADDR $(expr 8005 + $1 - 1) } # Remove the docker image tomcat$1 diff --git a/test/tomcat/Dockerfile b/test/tomcat/Dockerfile index a05af043b..f49dd626a 100644 --- a/test/tomcat/Dockerfile +++ b/test/tomcat/Dockerfile @@ -17,13 +17,10 @@ COPY $TESTSUITE_TOMCAT_CONTEXT ./conf/context.xml COPY start.sh ./ RUN chmod +x start.sh - -ENV tomcat_port= -ENV tomcat_shutdown_port= -ENV tomcat_ajp_port= ENV cluster_port=6666 ENV jvm_route= ENV tomcat_address= +ENV tomcat_port_offset=0 CMD ["./start.sh"] diff --git a/test/tomcat/server.xml b/test/tomcat/server.xml index 3547b1527..80d9ed6cb 100644 --- a/test/tomcat/server.xml +++ b/test/tomcat/server.xml @@ -19,9 +19,16 @@ define subcomponents such as "Valves" at this level. Documentation at /docs/config/server.html --> - - - + + + - + redirectPort="8443" + portOffset="port_offset" />