diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d981f5e4..a725c64a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,9 +17,7 @@ on: debug: description: "Test logs are generated when on" type: choice - options: - - "on" - - "off" + options: [ "on", "off" ] default: "on" forever-pause: @@ -37,6 +35,27 @@ on: type: number default: 2 + mod_proxy_cluster: + description: "mod_proxy_cluster tests are executed" + type: choice + options: [ "on", "off" ] + default: "on" + + balancer: + description: "mod_proxy_balancer tests are executed" + type: choice + options: [ "on", "off" ] + default: "on" + +env: + IMG: local-tomcat + HTTPD_IMG: local-httpd + DEBUG: ${{ inputs.debug || 'on' }} + FOREVER_PAUSE: ${{ inputs.forever-pause || 100 }} + ITERATION_COUNT: ${{ inputs.iteration-count || 2 }} + TOMCAT_CYCLE_COUNT: ${{ inputs.tomcat-cycle-count || 2 }} + SKIP_CONTAINER_CREATION: 'on' + jobs: cmake-fedora-latest: @@ -105,17 +124,17 @@ jobs: } > Containerfile podman build . - clang-format-style-check: + clang-style-checks: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v6 with: path: mod_proxy_cluster - - name: Install clang-format + - name: Install clang-format and clang-tidy run: | sudo apt-get update - sudo apt-get install -y clang-format + sudo apt-get install -y clang-format clang-tidy apache2-dev - name: Check styles run: | code=0 @@ -132,18 +151,6 @@ jobs: rm diff.txt || true # we don't fail if the file does not exist done; exit $code - - clang-tidy-naming-check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - path: mod_proxy_cluster - - name: Install clang-tidy - run: | - sudo apt-get update - sudo apt-get install -y clang-tidy apache2-dev - name: Check naming conventions run: | code=0 @@ -161,6 +168,7 @@ jobs: done exit $code + make-httpd-maintainer-mode: runs-on: ubuntu-latest strategy: @@ -289,22 +297,20 @@ jobs: if: always() with: name: Windows logs for ${{ matrix.os }} - path: C:\Apache24\logs\ + path: C:\Apache24\logs\*log retention-days: 7 - tests: + # Both testsuites run against this one image, so that they exercise the very same + # binaries and the coverage they gather can be merged (see the merged-coverage job). + build-test-containers: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ ubuntu-latest, ubuntu-24.04-arm ] + os: [ ubuntu-latest, ubuntu-24.04-arm ] env: IMG: local-tomcat HTTPD_IMG: local-httpd - DEBUG: ${{ inputs.debug || 'on' }} - FOREVER_PAUSE: ${{ inputs.forever-pause || 100 }} - ITERATION_COUNT: ${{ inputs.iteration-count || 2 }} - TOMCAT_CYCLE_COUNT: ${{ inputs.tomcat-cycle-count || 2 }} steps: - name: Checkout uses: actions/checkout@v6 @@ -316,10 +322,119 @@ jobs: - name: Setup dependencies run: | sudo apt-get update -y - sudo apt-get install -y podman-docker maven git curl iproute2 wcstools + sudo apt-get install -y podman-docker maven git curl iproute2 wcstools zstd sudo touch /etc/containers/nodocker cd test sh setup-dependencies.sh + - name: Build the test images + run: | + cd test + . includes/common.sh + test_create_all_containers + for img in $(docker image ls --format "{{.Repository}}:{{.Tag}}" | sed 's|^localhost/||'); do + if [[ "$img" != "$IMG"* ]] && [[ "$img" != "$HTTPD_IMG"* ]]; then continue; fi + echo "Saving $img image" + docker save $img | zstd -T0 -o /tmp/$(echo $img | sed 's|:|-|').tar.zst + done + - name: Preserve the test images + uses: actions/upload-artifact@v6 + with: + name: test-containers-${{ matrix.os }} + path: /tmp/*.tar.zst + retention-days: 1 + # the tests themselves need these, they don't run setup-dependencies.sh + - name: Preserve the test dependencies + uses: actions/upload-artifact@v6 + with: + name: test-dependencies-${{ matrix.os }} + path: | + test/websocket/websocket-hello-0.0.1.war + test/includes/target/test-1.0.jar + retention-days: 1 + + test-extra: + name: test-extra (${{ matrix.os }}, ${{ matrix.test.name }}) + runs-on: ${{ matrix.os }} + needs: build-test-containers + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, ubuntu-24.04-arm ] + # these tests take a lot of time, that's why we keep them separate + test: + - name: MODCLUSTER-736 + script: MODCLUSTER-736/testit.sh + + - name: Hanging tests + script: hangingtests.sh + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: Setup dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y podman-docker git curl iproute2 wcstools zstd + sudo touch /etc/containers/nodocker + # create the network (usually done by setup-dependencies.sh + docker network create mod_proxy_cluster_testsuite_net > /dev/null 2>&1 || true + - name: Configure Podman logging driver + run: | + mkdir -p ~/.config/containers + cat < ~/.config/containers/containers.conf + [containers] + log_driver = "k8s-file" + + [engine] + events_logger = "file" + EOF + - name: Get the test images built + uses: actions/download-artifact@v7 + with: + name: test-containers-${{ matrix.os }} + path: /tmp + - name: Load the test images + run: | + cd /tmp + for img in $(ls *.tar.zst); do + echo "Loading $img image" + zstd -dc $img | docker load + done + - name: Run ${{ matrix.test.name }} + run: | + cd test + mkdir logs + . includes/common.sh + run_test "${{ matrix.test.script }}" "${{ matrix.test.name }}" + - name: Preserve test logs + uses: actions/upload-artifact@v6 + if: ${{ !cancelled() && env.DEBUG == 'on' }} + with: + name: ${{ matrix.test.name }} logs ${{ matrix.os }} + path: | + test/logs/* + retention-days: 7 + + tests: + runs-on: ${{ matrix.os }} + needs: build-test-containers + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, ubuntu-24.04-arm ] + suite: [ mod_proxy_cluster, mod_proxy_balancer ] + env: + MOD_PROXY_CLUSTER_TESTS: ${{ matrix.suite == 'mod_proxy_cluster' && (inputs.mod_proxy_cluster || 'on') || 'off' }} + MOD_PROXY_BALANCER_TESTS: ${{ matrix.suite == 'mod_proxy_balancer' && (inputs.balancer || 'on') || 'off' }} + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: Setup dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y podman-docker git curl iproute2 wcstools zstd + sudo touch /etc/containers/nodocker + # create the network (usually done by setup-dependencies.sh + docker network create mod_proxy_cluster_testsuite_net > /dev/null 2>&1 || true - name: Configure Podman logging driver run: | mkdir -p ~/.config/containers @@ -330,15 +445,37 @@ jobs: [engine] events_logger = "file" EOF + - name: Get the test images built + uses: actions/download-artifact@v7 + with: + name: test-containers-${{ matrix.os }} + path: /tmp + - name: Load the test images + run: | + cd /tmp + for img in $(ls *.tar.zst); do + echo "Loading $img image" + zstd -dc $img | docker load + done + - name: Get the test dependencies built + uses: actions/download-artifact@v7 + with: + name: test-dependencies-${{ matrix.os }} + path: test + - name: Disable MODCLUSTER-736 and Hanging tests + run: | + cd test + sed -i '/MODCLUSTER-736/s|^|#|' testsuite.sh + sed -i '/Hanging tests/s|^|#|' testsuite.sh - name: Run testsuite run: | cd test sh testsuite.sh - name: Preserve test logs uses: actions/upload-artifact@v6 - if: ${{ env.DEBUG == 'on' }} + if: ${{ !cancelled() && env.DEBUG == 'on' }} with: - name: Test logs ${{ matrix.os }} + name: Test logs ${{ matrix.os }} ${{ matrix.suite }} path: | test/logs/* retention-days: 7 @@ -403,3 +540,25 @@ jobs: name: Doxygen docs path: doxygen-out/html/* retention-days: 30 + + gather-results: + runs-on: ubuntu-latest + # make-with-httpd-trunk is in there transitively through perl tests + needs: [ tests, perl-tests, clang-style-checks, cmake-fedora-latest, make-httpd-maintainer-mode, make-fedora-latest, doxygen, cmake-windows-latest, test-extra ] + steps: + - name: Delete all the containers/dependencies we no longer need + uses: geekyeggo/delete-artifact@v6 + with: + name: | + test-containers* + test-dependencies* + failOnError: false + - name: Merge all the logs + uses: actions/upload-artifact/merge@v6 + with: + name: Test logs + pattern: '*logs*' + separate-directories: true + delete-merged: true + retention-days: 7 + diff --git a/test/MODCLUSTER-736/testit.sh b/test/MODCLUSTER-736/testit.sh index d2248669..964c37cd 100644 --- a/test/MODCLUSTER-736/testit.sh +++ b/test/MODCLUSTER-736/testit.sh @@ -25,34 +25,22 @@ runtomcatbatch() { MPC_NAME=MODCLUSTER-736 tomcat_start $i done - tomcat_count=$(expr 3 + 11 - $t) - tomcat_wait_for_n_nodes $tomcat_count || exit 1 + tomcat_count=$(( 3 + 11 - $t )) + tomcat_wait_for_n_nodes $tomcat_count for i in $(seq $t 10); do - tomcat_start_webapp $i || exit 1 + tomcat_start_webapp $i done # test the tomcats sleep 20 tomcat_all_test_app $tomcat_count - if [ $? -ne 0 ]; then - echo "runtomcatbatch tomcat_all_test_app $tomcat_count FAILED!" - exit 1 - fi # "load test" 9 of them tomcat_all_run_ab $tomcat_count - if [ $? -ne 0 ]; then - echo "runtomcatbatch tomcat_all_run_ab $tomcat_count FAILED!" - exit 1 - fi # retest tomcat_all_test_app $tomcat_count - if [ $? -ne 0 ]; then - echo "runtomcatbatch tomcat_all_test_app $tomcat_count FAILED!" - exit 1 - fi # stop the tomcats for i in $(seq $t 10); @@ -61,10 +49,6 @@ runtomcatbatch() { done tomcat_wait_for_n_nodes 3 - if [ $? -ne 0 ]; then - echo "runtomcatbatch tomcat_wait_for_n_nodes 3 FAILED!" - exit 1 - fi # remove the tomcats for i in $(seq $t 10); @@ -79,7 +63,7 @@ runtomcatbatch() { singlecycle() { echo "singlecycle: Testing tomcat$1" R=$1 - MPC_NAME=MODCLUSTER-736 tomcat_start $1 || exit 1 + MPC_NAME=MODCLUSTER-736 tomcat_start $1 # Wait for it to start echo "Testing(0) tomcat$1 waiting..." @@ -94,11 +78,11 @@ singlecycle() { echo "Timeout: tomcat$1 is not ready" exit 1 fi - i=$(expr $i + 1) + i=$(( $i + 1 )) sleep 1 done echo "Testing(0) tomcat$1 started" - tomcat_start_webapp $1 || exit 1 + tomcat_start_webapp $1 echo "Testing(0) tomcat$1 with webapp" i=0 while true @@ -112,14 +96,14 @@ singlecycle() { echo "Timeout: webapp on tomcat$1 is not ready after 300 seconds" exit 1 fi - i=$(expr $i + 1) + i=$(( $i + 1 )) sleep 1 done echo "Testing(1) tomcat$1" - tomcat_test_app $1 || exit 1 + tomcat_test_app $1 echo "Testing(2) tomcat$1" - tomcat_test_app $1 || exit 1 - tomcat_run_ab $1 || exit 1 + tomcat_test_app $1 + tomcat_run_ab $1 echo "Testing(3) tomcat$1" tomcat_shutdown $1 || exit 1 while true @@ -132,7 +116,7 @@ singlecycle() { echo "Timeout: webapp is still present on tomcat$1 after 300 seconds" exit 1 fi - i=$(expr $i + 1) + i=$(( $i + 1 )) sleep 1 done tomcat_remove $1 || exit 1 @@ -143,7 +127,7 @@ singlecycle() { looptomcatforever() { while true do - singlecycle $1 || exit 1 + singlecycle $1 done } @@ -177,14 +161,16 @@ forevertomcat() { tomcat_remove_by_name tomcat14 tomcat_remove_by_name tomcat15 tomcat_remove_by_name tomcat16 - sleep 10 + # the nodes have to be gone from the manager, otherwise the following + # tomcat_wait_for_n_nodes calls would be satisfied by these leftovers + tomcat_wait_for_n_nodes 0 } # Start and stop successively (one after another) $1 tomcats cyclestomcats() { for i in $(seq 1 $1); do echo -n "$i/$1: " - singlecycle $i || exit 1 + singlecycle $i done echo "Looks OK, Done!" } @@ -196,77 +182,44 @@ runmodcluster736() { MPC_NAME=MODCLUSTER-736 tomcat_start 2 MPC_NAME=MODCLUSTER-736 tomcat_start 3 MPC_NAME=MODCLUSTER-736 tomcat_start 4 - tomcat_wait_for_n_nodes 3 || exit 1 + tomcat_wait_for_n_nodes 3 # check them - tomcat_start_webapp 2 || exit 1 - tomcat_start_webapp 3 || exit 1 - tomcat_start_webapp 4 || exit 1 + tomcat_start_webapp 2 + tomcat_start_webapp 3 + tomcat_start_webapp 4 sleep 20 - tomcat_test_app 2 || exit 1 - tomcat_test_app 3 || exit 1 - tomcat_test_app 4 || exit 1 + tomcat_test_app 2 + tomcat_test_app 3 + tomcat_test_app 4 # start a bunch of tomcats, test, shutdown, remove and try in a loop. runmodcluster736=0 while true do - runmodcluster736=$(expr $runmodcluster736 + 1) + runmodcluster736=$(( $runmodcluster736 + 1 )) if [ $runmodcluster736 -gt 2 ]; then echo "Looks OK, runmodcluster736 stopping!" break fi # cycle the tomcats runtomcatbatch - - if [ $? -ne 0 ]; then - echo "runtomcatbatch: runmodcluster736 Failed!" - exit 1 - fi tomcat_shutdown 2 tomcat_wait_for_n_nodes 2 - if [ $? -ne 0 ]; then - echo "tomcat_wait_for_n_nodes 2: runmodcluster736 Failed!" - exit 1 - fi tomcat_remove 2 MPC_NAME=MODCLUSTER-736 tomcat_start 5 tomcat_wait_for_n_nodes 3 - if [ $? -ne 0 ]; then - echo "tomcat_wait_for_n_nodes 3: runmodcluster736 Failed!" - exit 1 - fi tomcat_start_webapp 5 - if [ $? -ne 0 ]; then - echo "tomcat_start_webapp 5: runmodcluster736 Failed!" - exit 1 - fi sleep 20 tomcat_test_app 5 - if [ $? -ne 0 ]; then - echo "tomcat_test_app 5: runmodcluster736 Failed!" - exit 1 - fi # we have 5 3 4 in shared memory # read 2 MPC_NAME=MODCLUSTER-736 tomcat_start 2 tomcat_wait_for_n_nodes 4 - if [ $? -ne 0 ]; then - echo "tomcat_wait_for_n_nodes 4: runmodcluster736 Failed!" - exit 1 - fi tomcat_start_webapp 2 - if [ $? -ne 0 ]; then - echo "tomcat_start_webapp 2: runmodcluster736 Failed!" - exit 1 - fi sleep 20 tomcat_test_app 2 - if [ $? -ne 0 ]; then - echo "tomcat_test_app 2: runmodcluster736 Failed!" - exit 1 - fi sleep 20 @@ -275,29 +228,11 @@ runmodcluster736() { tomcat_shutdown 5 tomcat_wait_for_n_nodes 3 - if [ $? -ne 0 ]; then - echo "tomcat_wait_for_n_nodes 3: runmodcluster736 Failed!" - exit 1 - fi tomcat_remove 5 tomcat_test_app 2 - if [ $? -ne 0 ]; then - echo "tomcat_test_app 2: runmodcluster736 Failed!" - exit 1 - fi - tomcat_test_app 3 - if [ $? -ne 0 ]; then - echo "tomcat_test_app 3: runmodcluster736 Failed!" - exit 1 - fi - tomcat_test_app 4 - if [ $? -ne 0 ]; then - echo "tomcat_test_app 4: runmodcluster736 Failed!" - exit 1 - fi echo "runmodcluster736 loop: $runmodcluster736 DONE" done @@ -305,7 +240,7 @@ runmodcluster736() { tomcat_shutdown 4 tomcat_shutdown 3 tomcat_shutdown 2 - tomcat_wait_for_n_nodes 0 || exit 1 + tomcat_wait_for_n_nodes 0 tomcat_remove 2 tomcat_remove 3 tomcat_remove 4 @@ -314,16 +249,8 @@ runmodcluster736() { # MODCLUSTER-736 echo "Testing MODCLUSTER-736" cyclestomcats ${TOMCAT_CYCLE_COUNT:-10} -if [ $? -ne 0 ]; then - echo "MODCLUSTER-736 cyclestomcats 100 FAILED!" - exit 1 -fi echo "cycletomcats DONE" forevertomcat -if [ $? -ne 0 ]; then - echo "MODCLUSTER-736 forevertomcat FAILED!" - exit 1 -fi echo "forevertomcat DONE" runmodcluster736 if [ $? -ne 0 ]; then diff --git a/test/MODCLUSTER-755/testit.sh b/test/MODCLUSTER-755/testit.sh index 9fe7c726..f9aae7cc 100755 --- a/test/MODCLUSTER-755/testit.sh +++ b/test/MODCLUSTER-755/testit.sh @@ -33,7 +33,7 @@ if [ "x$USE_MULTI_APP" = "xtrue" ]; then echo "The webapp are going to be 1-9000/2-9000 until count (1-9499/2-9499)" fi -for i in $(seq 9000 $(expr 9000 + $NODE_COUNT - 1)) +for i in $(seq 9000 $(( 9000 + $NODE_COUNT - 1 ))) do curl $HTTPD -H "User-Agent: ClusterListener/1.0" -X CONFIG --data "JVMRoute=appserver$i&Host=127.0.0.1&Maxattempts=1&Port=$i&StickySessionForce=No&Timeout=20&Type=ajp&ping=20" curl $HTTPD -H "User-Agent: ClusterListener/1.0" -X STATUS --data "JVMRoute=appserver$i&Load=100" @@ -51,7 +51,7 @@ done i=0 while [ true ] do - for i in $(seq 9000 $(expr 9000 + $NODE_COUNT - 1)) + for i in $(seq 9000 $(( 9000 + $NODE_COUNT - 1 ))) do curl $HTTPD -H "User-Agent: ClusterListener/1.0" -X STATUS --data "JVMRoute=appserver$i&Load=100" if [ $? -ne 0 ]; then @@ -60,7 +60,7 @@ do fi done sleep 10 - i=$(expr $i + 1) + i=$(( $i + 1 )) if [ $i -gt 100 ]; then break fi diff --git a/test/MODCLUSTER-785/testit.sh b/test/MODCLUSTER-785/testit.sh index f6dbf214..9871b2b2 100755 --- a/test/MODCLUSTER-785/testit.sh +++ b/test/MODCLUSTER-785/testit.sh @@ -67,7 +67,7 @@ do if [ ${http_code} = 200 ]; then break fi - i=$(expr $i + 1) + i=$(( $i + 1 )) if [ $i -gt 60 ]; then break fi @@ -92,7 +92,7 @@ do echo "MODCLUSTER-785 Failed! return 503" exit 1 fi - i=$(expr $i + 1) + i=$(( $i + 1 )) if [ $i -gt 60 ]; then break fi diff --git a/test/basetests.sh b/test/basetests.sh index 3ea5e1fc..fdd36154 100644 --- a/test/basetests.sh +++ b/test/basetests.sh @@ -45,7 +45,7 @@ do tomcat_shutdown 1 tomcat_wait_for_n_nodes 0 || exit 1 tomcat_remove 1 - iter=$(expr $iter + 1) + iter=$(( $iter + 1 )) done tomcat_all_remove diff --git a/test/includes/common.sh b/test/includes/common.sh index 1fcbd9bb..34e9226c 100644 --- a/test/includes/common.sh +++ b/test/includes/common.sh @@ -8,16 +8,16 @@ MPC_NAME=${MPC_NAME:-httpd-mod_proxy_cluster} run_test() { local ret=0 if [ ! -z "$2" ]; then - printf "Running %-42s ..." "$2" + printf "Running %-64s ..." "$2" else - printf "Running %-42s ..." "$1" + printf "Running %-64s ..." "$1" fi if is_enabled "$DEBUG"; then - sh $1 > "logs/${2:-$1}.log" 2>&1 + sh $1 > "logs/${2:-$1}.log" 2>&1 || ret=$? else - sh $1 > /dev/null 2>&1 + sh $1 > /dev/null 2>&1 || ret=$? fi - if [ $? = 0 ]; then + if [ $ret = 0 ]; then echo " OK" else echo " NOK" @@ -47,6 +47,24 @@ is_enabled() { return 0 } +test_create_all_containers() { + if is_enabled "$DEBUG"; then + httpd_create || exit 2 + tomcat_create || exit 3 + else + httpd_create > /dev/null 2>&1 || exit 2 + tomcat_create > /dev/null 2>&1 || exit 3 + fi + # create all main tomcat versions for Base tests + ## IMG name might include specific version, we have to handle that + IMG_NOVER=$(echo $IMG | cut -d: -f1) + for tomcat_version in "9.0" "10.1" "11.0" + do + IMG="$IMG_NOVER:$tomcat_version" tomcat_create $tomcat_version > /dev/null 2>&1 || exit 3 + done +} + + ##################################################### ### H T T P D H E L P E R F U N C T I O N S ### ##################################################### @@ -93,7 +111,7 @@ httpd_wait_until_ready() { curl -m 20 localhost:8090 > /dev/null 2>&1 while [ $? != 0 ]; do - i=$(expr $i + 1) + i=$(( $i + 1 )) if [ $i -gt 20 ]; then echo "$(date) Failed to run httpd container" exit 1; @@ -151,8 +169,8 @@ tomcat_start() { exit 1 fi - local DEFAULT_OFFSET=$(expr $1 - 1) - local shutport=$(expr ${SHUTDOWN_PORT:-8005} + $DEFAULT_OFFSET) + local DEFAULT_OFFSET=$(( $1 - 1 )) + local shutport=$(( ${SHUTDOWN_PORT:-8005} + $DEFAULT_OFFSET )) echo "$(date) Starting tomcat$1" nohup docker run --network=mod_proxy_cluster_testsuite_net \ @@ -182,14 +200,14 @@ tomcat_wait_for_n_nodes() { echo "$(date) httpd isn't running or something is VERY wrong" exit 1 fi - NBNODES=-1 + NBNODES=$(curl -s http://localhost:8090/mod_cluster_manager -m 20 | grep "Status: OK" | awk ' { print $3} ' | wc -l) i=0 while [ ${NBNODES} != ${nodes} ] do NBNODES=$(curl -s http://localhost:8090/mod_cluster_manager -m 20 | grep "Status: OK" | awk ' { print $3} ' | wc -l) sleep 10 echo "$(date) Waiting for $nodes node to be ready (nodes ready: $NBNODES)" - i=$(expr $i + 1) + i=$(( $i + 1 )) if [ $i -gt 60 ]; then echo "($date) Timeout! There are not $nodes nodes but $NBNODES instead" exit 1 @@ -272,7 +290,7 @@ tomcat_shutdown() { fi echo "$(date) shutting down tomcat$1" - echo "SHUTDOWN" | nc localhost $(expr ${SHUTDOWN_PORT:-8005} + $1 - 1) + echo "SHUTDOWN" | nc localhost $(( ${SHUTDOWN_PORT:-8005} + $1 - 1 )) } # Remove the docker image tomcat$1 @@ -352,7 +370,7 @@ tomcat_all_run_ab() { while true do tomcat_run_ab $tc || exit 1 - tc=$(expr $tc + 1) + tc=$(( $tc + 1 )) if [ $tc -gt $1 ]; then echo "$(date) abtomcats: Done!" break @@ -376,7 +394,7 @@ tomcat_all_test_app() { while true do tomcat_test_app $tc || exit 1 - tc=$(expr $tc + 1) + tc=$(( $tc + 1 )) if [ $tc -gt $1 ]; then echo "$(date) tomcat_tests $tc Done!" break diff --git a/test/maintests.sh b/test/maintests.sh index b909bbd4..fd67da8f 100644 --- a/test/maintests.sh +++ b/test/maintests.sh @@ -60,7 +60,7 @@ while [ "${NODE}" = "${NEWNODE}" ] do NEWCO=$(curl -v http://localhost:8090/testapp/test.jsp -m 20 -o /dev/null 2>&1 | grep Set-Cookie | awk '{ print $3 } ' | sed 's:;::') NEWNODE=$(echo ${NEWCO} | awk -F = '{ print $2 }' | awk -F . '{ print $2 }') - i=$(expr $i + 1) + i=$(( $i + 1 )) if [ $i -gt 40 ]; then echo "Can't find the 2 webapps" exit 1 @@ -90,7 +90,7 @@ echotestlabel "sticky: stopping one node and doing requests..." NODE=$(echo ${NEWCO} | awk -F = '{ print $2 }' | awk -F . '{ print $2 }') echo $NODE PORT=$(curl http://localhost:8090/mod_cluster_manager -m 20 | grep Node | grep $NODE | sed 's:)::' | awk -F : '{ print $3 } ') -NUMBER=$(expr ${PORT} - 8080 + 1) +NUMBER=$(( ${PORT} - 8080 + 1 )) CODE="200" i=0 while [ "$CODE" = "200" ] @@ -106,7 +106,7 @@ do # We're going to kill instead of removal because kill only tomcat proc (keeps the container in DNS) tomcat_kill $NUMBER fi - i=$(expr $i + 1) + i=$(( $i + 1 )) done if [ ${CODE} != "200" ]; then echo "Something was wrong... got: ${CODE}" diff --git a/test/testsuite.sh b/test/testsuite.sh index 8ef515e9..1b92d987 100644 --- a/test/testsuite.sh +++ b/test/testsuite.sh @@ -4,34 +4,20 @@ # exits with 2 if httpd container build failed # exits with 3 if tomcat container build failed -# configuration of variables -# if you want tests to pass much faster, decrease these values -if [ -z ${FOREVER_PAUSE+x} ]; then - export FOREVER_PAUSE=3600 # sleep period length during which tomcats are run & stopped -fi -if [ -z ${TOMCAT_CYCLE_COUNT+x} ]; then - export TOMCAT_CYCLE_COUNT=100 # the number of repetitions of a test cycle -fi -if [ -z ${ITERATION_COUNT+x} ]; then - export ITERATION_COUNT=50 # the number of iteration of starting/stopping a tomcat -fi -if [ -z ${IMG+x} ]; then - export IMG=mod_proxy_cluster-testsuite-tomcat -fi -if [ -z ${HTTPD_IMG+x} ]; then - export HTTPD_IMG=mod_proxy_cluster-testsuite-httpd -fi - echo "Test parameters are:" -echo " FOREVER_PAUSE=$FOREVER_PAUSE" -echo " TOMCAT_CYCLE_COUNT=$TOMCAT_CYCLE_COUNT" -echo " ITERATION_COUNT=$ITERATION_COUNT" -echo " IMG=$IMG" -echo " HTTPD_IMG=$HTTPD_IMG" +echo " FOREVER_PAUSE=${FOREVER_PAUSE:=3600}" # sleep period length during which tomcats are run & stopped +echo " TOMCAT_CYCLE_COUNT=${TOMCAT_CYCLE_COUNT:=100}" # the number of repetitions of a test cycle +echo " ITERATION_COUNT=${ITERATION_COUNT:=50}" # the number of iteration of starting/stopping a tomcat +echo " IMG=${IMG:=mod_proxy_cluster-testsuite-tomcat}" # tomcat container image +echo " HTTPD_IMG=${HTTPD_IMG:=mod_proxy_cluster-testsuite-httpd}" # httpd with mod_proxy_cluster container image if [ ! -z ${MPC_CONF+x} ]; then echo " MPC_CONF=$MPC_CONF" fi echo " DEBUG=${DEBUG:-Off (undefined)}" +echo " MOD_PROXY_CLUSTER_TESTS=${MOD_PROXY_CLUSTER_TESTS:=On}" +echo " MOD_PROXY_BALANCER_TESTS=${MOD_PROXY_BALANCER_TESTS:=On}" +echo " SKIP_CONTAINER_CREATION=${SKIP_CONTAINER_CREATION:=Off}" + if [ ! -d logs ]; then mkdir logs @@ -39,20 +25,32 @@ fi . includes/common.sh -if [ ! -d tomcat/target ]; then - echo "Missing dependencies. Please run setup-dependencies.sh and then try again" - exit 4 -fi +IMG_NOVER=$(echo $IMG | cut -d: -f1) -echo -n "Creating docker containers..." -if is_enabled "$DEBUG"; then - httpd_create || exit 2 - tomcat_create || exit 3 +if is_enabled "$SKIP_CONTAINER_CREATION"; then + # let's just check all the containers are present + for tomcat_image in "$IMG_NOVER:latest" "$IMG_NOVER:9.0" "$IMG_NOVER:10.1" "$IMG_NOVER:11.0" + do + if ! docker image inspect $tomcat_image > /dev/null 2>&1; then + echo "tomcat image $tomcat_image is missing" + exit 3 + fi + done + if ! docker image inspect $HTTPD_IMG > /dev/null 2>&1; then + echo "httpd image $HTTPD_IMG is missing" + exit 2 + fi else - httpd_create > /dev/null 2>&1 || exit 2 - tomcat_create > /dev/null 2>&1 || exit 3 + # create all containers + if [ ! -d tomcat/target ]; then + echo "Missing dependencies. Please run setup-dependencies.sh and then try again" + exit 4 + fi + + echo "Creating docker containers..." + test_create_all_containers + echo "Done" fi -echo " Done" # clean everything at first echo -n "Cleaning possibly running containers..." @@ -62,48 +60,51 @@ echo " Done" res=0 -# IMG name might include specific version, we have to handle that -IMG_NOVER=$(echo $IMG | cut -d: -f1) - -for tomcat_version in "9.0" "10.1" "11.0" -do - IMG="$IMG_NOVER:$tomcat_version" tomcat_create $tomcat_version > /dev/null 2>&1 || exit 3 - IMG="$IMG_NOVER:$tomcat_version" run_test basetests.sh "Basic tests with tomcat $tomcat_version" - res=$(expr $res + $?) -done -run_test hangingtests.sh "Hanging tests" -res=$(expr $res + $?) -run_test maintests.sh "Main tests" -res=$(expr $res + $?) -run_test websocket/basic.sh "Websocket tests" -res=$(expr $res + $?) -run_test usealias/testit.sh "UseAlias" -res=$(expr $res + $?) -run_test MODCLUSTER-640/testit.sh "MODCLUSTER-640" -res=$(expr $res + $?) -run_test MODCLUSTER-734/testit.sh "MODCLUSTER-734" -res=$(expr $res + $?) -run_test MODCLUSTER-736/testit.sh "MODCLUSTER-736" -res=$(expr $res + $?) -run_test MODCLUSTER-755/testit.sh "MODCLUSTER-755" -res=$(expr $res + $?) -run_test MODCLUSTER-785/testit.sh "MODCLUSTER-785" -res=$(expr $res + $?) -run_test MODCLUSTER-794/testit.sh "MODCLUSTER-794" -res=$(expr $res + $?) +if is_enabled "$MOD_PROXY_CLUSTER_TESTS"; then + for tomcat_version in "9.0" "10.1" "11.0" + do + IMG="$IMG_NOVER:$tomcat_version" run_test basetests.sh "Basic tests with tomcat $tomcat_version" + res=$(( $res + $? )) + done + run_test hangingtests.sh "Hanging tests" + res=$(( $res + $? )) + run_test maintests.sh "Main tests" + res=$(( $res + $? )) + run_test websocket/basic.sh "Websocket tests" + res=$(( $res + $? )) + run_test usealias/testit.sh "UseAlias" + res=$(( $res + $? )) + run_test MODCLUSTER-640/testit.sh "MODCLUSTER-640" + res=$(( $res + $? )) + run_test MODCLUSTER-734/testit.sh "MODCLUSTER-734" + res=$(( $res + $? )) + run_test MODCLUSTER-736/testit.sh "MODCLUSTER-736" + res=$(( $res + $? )) + run_test MODCLUSTER-755/testit.sh "MODCLUSTER-755" + res=$(( $res + $? )) + run_test MODCLUSTER-785/testit.sh "MODCLUSTER-785" + res=$(( $res + $? )) + run_test MODCLUSTER-794/testit.sh "MODCLUSTER-794" + res=$(( $res + $? )) +fi -MPC_CONF=httpd/mod_lbmethod_cluster.conf run_test basetests.sh "Basic tests with mod_proxy_balancer" -res=$(expr $res + $?) -MPC_CONF=MODCLUSTER-640/mod_lbmethod_cluster.conf run_test MODCLUSTER-640/testit.sh "MODCLUSTER-640 with mod_proxy_balancer" -res=$(expr $res + $?) -MPC_CONF=MODCLUSTER-734/mod_lbmethod_cluster.conf run_test MODCLUSTER-734/testit.sh "MODCLUSTER-734 with mod_proxy_balancer" -res=$(expr $res + $?) -MPC_CONF=httpd/mod_lbmethod_cluster.conf run_test MODCLUSTER-755/testit.sh "MODCLUSTER-755 with mod_proxy_balancer" -res=$(expr $res + $?) -MPC_CONF=MODCLUSTER-785/mod_lbmethod_cluster.conf run_test MODCLUSTER-785/testit.sh "MODCLUSTER-785 with mod_proxy_balancer" -res=$(expr $res + $?) -MPC_CONF=MODCLUSTER-794/mod_lbmethod_cluster.conf run_test MODCLUSTER-794/testit.sh "MODCLUSTER-794 with mod_proxy_balancer" -res=$(expr $res + $?) +if is_enabled "$MOD_PROXY_BALANCER_TESTS"; then + for tomcat_version in "9.0" "10.1" "11.0" + do + IMG="$IMG_NOVER:$tomcat_version" MPC_CONF=httpd/mod_lbmethod_cluster.conf run_test basetests.sh "Basic tests with mod_proxy_balancer and tomcat $tomcat_version" + res=$(( $res + $? )) + done + MPC_CONF=MODCLUSTER-640/mod_lbmethod_cluster.conf run_test MODCLUSTER-640/testit.sh "MODCLUSTER-640 with mod_proxy_balancer" + res=$(( $res + $? )) + MPC_CONF=MODCLUSTER-734/mod_lbmethod_cluster.conf run_test MODCLUSTER-734/testit.sh "MODCLUSTER-734 with mod_proxy_balancer" + res=$(( $res + $? )) + MPC_CONF=httpd/mod_lbmethod_cluster.conf run_test MODCLUSTER-755/testit.sh "MODCLUSTER-755 with mod_proxy_balancer" + res=$(( $res + $? )) + MPC_CONF=MODCLUSTER-785/mod_lbmethod_cluster.conf run_test MODCLUSTER-785/testit.sh "MODCLUSTER-785 with mod_proxy_balancer" + res=$(( $res + $? )) + MPC_CONF=MODCLUSTER-794/mod_lbmethod_cluster.conf run_test MODCLUSTER-794/testit.sh "MODCLUSTER-794 with mod_proxy_balancer" + res=$(( $res + $? )) +fi echo -n "Cleaning containers if any..." httpd_remove > /dev/null 2>&1