Skip to content

Commit

Permalink
Merge pull request #121 from jajik/rework-test-add-ci
Browse files Browse the repository at this point in the history
Add basic tests into CI
  • Loading branch information
rhusar authored Aug 9, 2023
2 parents 4a98c3a + 489e2e7 commit 6331394
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 117 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,53 @@ jobs:
- name: Build
run: |
./native/scripts/windows-build.bat
tests:
runs-on: ubuntu-latest
env:
IMG: local-tomcat
HTTPD_IMG: local-httpd
DEBUG: on
FOREVER_PAUSE: 30
ITERATION_COUNT: 2
TOMCAT_CYCLE_COUNT: 2
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup dependencies
run: |
sudo apt update -y
sudo apt install -y moby* maven git curl iproute2
cd test
sh setup-dependencies.sh
- name: Setup images
run: |
cd test
source includes/common.sh
httpd_create
tomcat_create
- name: Run test
shell: bash {0}
run: |
cd test
mkdir logs
# set vars
export MPC_SOURCES=$(git remote -v | grep "origin.*fetch" | awk ' { print $2 } ')
export MPC_BRANCH=$(git branch --show-current)
source includes/common.sh
res=0
# Those are currently all tests we have. In CI only MODCLUSTER-{734,755}/testit.sh pass, so until we fix the issue, only these tests are enabled.
# basetests.sh hangingtests.sh maintests.sh JBCS-1236/testit.sh MODCLUSTER-640/testit.sh MODCLUSTER-734/testit.sh MODCLUSTER-755/testit.sh MODCLUSTER-785/testit.sh
for testcase in MODCLUSTER-734/testit.sh MODCLUSTER-755/testit.sh
do
run_test $testcase $(echo $testcase | cut -f1 -d/)
res=$(expr $res + $?)
done
exit $res
- name: Preserve test logs
uses: actions/upload-artifact@v3
if: always()
with:
name: Test logs
path: |
test/logs/*
retention-days: 7
81 changes: 40 additions & 41 deletions test/JBCS-1236/testit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@ runtomcatbatch() {
done

tomcat_count=$(expr 3 + 11 - $t)
tomcat_wait_for_n_nodes $tomcat_count || clean_and_exit
tomcat_wait_for_n_nodes $tomcat_count || exit 1
for i in $(seq $t 10);
do
tomcat_start_webapp $i || clean_and_exit
tomcat_start_webapp $i || exit 1
done

# test the tomcats
sleep 20
tomcat_all_test_app $tomcat_count
if [ $? -ne 0 ]; then
echo "runtomcatbatch tomcat_all_test_app 9 FAILED!"
clean_and_exit
exit 1
fi

# "load test" 9 of them
tomcat_all_run_ab $tomcat_count
if [ $? -ne 0 ]; then
echo "runtomcatbatch tomcat_all_run_ab 9 FAILED!"
clean_and_exit
exit 1
fi

# retest
tomcat_all_test_app $tomcat_count
if [ $? -ne 0 ]; then
echo "runtomcatbatch tomcat_all_test_app 9 FAILED!"
clean_and_exit
exit 1
fi

# stop the tomcats
Expand All @@ -58,7 +58,7 @@ runtomcatbatch() {
tomcat_wait_for_n_nodes 3
if [ $? -ne 0 ]; then
echo "runtomcatbatch tomcat_wait_for_n_nodes 3 FAILED!"
clean_and_exit
exit 1
fi

# remove the tomcats
Expand All @@ -78,10 +78,10 @@ singlecycle() {
R=$(expr 1 + $RANDOM % 10 + 10)
R=$(expr $R + 2)
# TODO
tomcat_start $1 $R || clean_and_exit
tomcat_start $1 $R || exit 1
else
R=0
tomcat_start $1 $R || clean_and_exit
tomcat_start $1 $R || exit 1
fi
# Wait for it to start
echo "Testing(0) tomcat$1 waiting..."
Expand All @@ -94,7 +94,7 @@ singlecycle() {
sleep 1
done
echo "Testing(0) tomcat$1 started"
tomcat_start_webapp $1 || clean_and_exit
tomcat_start_webapp $1 || exit 1
echo "Testing(0) tomcat$1 with webapp"
while true
do
Expand All @@ -106,12 +106,12 @@ singlecycle() {
sleep 1
done
echo "Testing(1) tomcat$1"
tomcat_test_app $1 || clean_and_exit
tomcat_test_app $1 || exit 1
echo "Testing(2) tomcat$1"
tomcat_test_app $1 || clean_and_exit
tomcat_run_ab $1 || clean_and_exit
tomcat_test_app $1 || exit 1
tomcat_run_ab $1 || exit 1
echo "Testing(3) tomcat$1"
tomcat_shutdown $1 $R || clean_and_exit
tomcat_shutdown $1 $R || exit 1
while true
do
curl -s http://localhost:6666/mod_cluster_manager | grep Node | grep tomcat$1 > /dev/null
Expand All @@ -120,15 +120,15 @@ singlecycle() {
fi
sleep 1
done
tomcat_remove $1 || clean_and_exit
tomcat_remove $1 || exit 1
echo "singlecycle Done tomcat$1"
}

# Run neverending testing loop of a single tomcat
looptomcatforever() {
while true
do
singlecycle $1 || clean_and_exit
singlecycle $1 || exit 1
done
}

Expand All @@ -153,7 +153,7 @@ forevertomcat() {
kill -15 $pid12 $pid13 $pid14 $pid15 $pid16
if [ $? -ne 0 ]; then
echo "kill -15 $pid12 $pid13 $pid14 $pid15 $pid16 failed"
clean_and_exit
exit 1
fi
echo "Tests done, cleaning"
# stop & remove the containers
Expand All @@ -175,7 +175,7 @@ cyclestomcats() {
echo "Looks OK, Done!"
break
fi
singlecycle $i useran || clean_and_exit
singlecycle $i useran || exit 1
done
}

Expand All @@ -186,15 +186,15 @@ runjbcs1236() {
tomcat_start 2 0
tomcat_start 3 0
tomcat_start 4 0
tomcat_wait_for_n_nodes 3 || clean_and_exit
tomcat_wait_for_n_nodes 3 || exit 1
# check them
tomcat_start_webapp 2 || clean_and_exit
tomcat_start_webapp 3 || clean_and_exit
tomcat_start_webapp 4 || clean_and_exit
tomcat_start_webapp 2 || exit 1
tomcat_start_webapp 3 || exit 1
tomcat_start_webapp 4 || exit 1
sleep 20
tomcat_test_app 2 || clean_and_exit
tomcat_test_app 3 || clean_and_exit
tomcat_test_app 4 || clean_and_exit
tomcat_test_app 2 || exit 1
tomcat_test_app 3 || exit 1
tomcat_test_app 4 || exit 1

# start a bunch of tomcats, test, shutdown, remove and try in a loop.
runjbcs1236=0
Expand All @@ -210,52 +210,52 @@ runjbcs1236() {

if [ $? -ne 0 ]; then
echo "runtomcatbatch: runjbcs1236 Failed!"
clean_and_exit
exit 1
fi
tomcat_shutdown 2 0

tomcat_wait_for_n_nodes 2
if [ $? -ne 0 ]; then
echo "tomcat_wait_for_n_nodes 2: runjbcs1236 Failed!"
clean_and_exit
exit 1
fi
tomcat_remove 2
tomcat_start 5 0

tomcat_wait_for_n_nodes 3
if [ $? -ne 0 ]; then
echo "tomcat_wait_for_n_nodes 3: runjbcs1236 Failed!"
clean_and_exit
exit 1
fi
tomcat_start_webapp 5
if [ $? -ne 0 ]; then
echo "tomcat_start_webapp 5: runjbcs1236 Failed!"
clean_and_exit
exit 1
fi
sleep 20
tomcat_test_app 5
if [ $? -ne 0 ]; then
echo "tomcat_test_app 5: runjbcs1236 Failed!"
clean_and_exit
exit 1
fi
# we have 5 3 4 in shared memory
# read 2
tomcat_start 2 0
tomcat_wait_for_n_nodes 4
if [ $? -ne 0 ]; then
echo "tomcat_wait_for_n_nodes 4: runjbcs1236 Failed!"
clean_and_exit
exit 1
fi
tomcat_start_webapp 2
if [ $? -ne 0 ]; then
echo "tomcat_start_webapp 2: runjbcs1236 Failed!"
clean_and_exit
exit 1
fi
sleep 20
tomcat_test_app 2
if [ $? -ne 0 ]; then
echo "tomcat_test_app 2: runjbcs1236 Failed!"
clean_and_exit
exit 1
fi

sleep 20
Expand All @@ -267,26 +267,26 @@ runjbcs1236() {
tomcat_wait_for_n_nodes 3
if [ $? -ne 0 ]; then
echo "tomcat_wait_for_n_nodes 3: runjbcs1236 Failed!"
clean_and_exit
exit 1
fi
tomcat_remove 5

tomcat_test_app 2
if [ $? -ne 0 ]; then
echo "tomcat_test_app 2: runjbcs1236 Failed!"
clean_and_exit
exit 1
fi

tomcat_test_app 3
if [ $? -ne 0 ]; then
echo "tomcat_test_app 3: runjbcs1236 Failed!"
clean_and_exit
exit 1
fi

tomcat_test_app 4
if [ $? -ne 0 ]; then
echo "tomcat_test_app 4: runjbcs1236 Failed!"
clean_and_exit
exit 1
fi
echo "runjbcs1236 loop: $runjbcs1236 DONE"
done
Expand All @@ -295,7 +295,7 @@ runjbcs1236() {
tomcat_shutdown 4 0
tomcat_shutdown 3 0
tomcat_shutdown 2 0
tomcat_wait_for_n_nodes 0 || clean_and_exit
tomcat_wait_for_n_nodes 0 || exit 1
tomcat_remove 2
tomcat_remove 3
tomcat_remove 4
Expand All @@ -306,18 +306,17 @@ echo "Testing JBCS-1236"
cyclestomcats ${TOMCAT_CYCLE_COUNT:-10}
if [ $? -ne 0 ]; then
echo "JBCS-1236 cyclestomcats 100 FAILED!"
clean_and_exit
exit 1
fi
forevertomcat
if [ $? -ne 0 ]; then
echo "JBCS-1236 forevertomcat FAILED!"
clean_and_exit
exit 1
fi
runjbcs1236
if [ $? -ne 0 ]; then
echo "JBCS-1236 runjbcs1236 FAILED!"
clean_and_exit
exit 1
fi

httpd_shutdown JBCS-1236
tomcat_all_remove
18 changes: 8 additions & 10 deletions test/MODCLUSTER-640/testit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ sleep 10
code=$(/usr/bin/curl -o /dev/null --silent --write-out '%{http_code}' http://localhost:8000/webapp1/index.html)
if [ "${code}" != "200" ]; then
echo "nocanon test failed, we get ${code} on http://localhost:8000/webapp1/index.html"
clean_and_exit
exit 1
fi
curl -v "http://localhost:8000/webapp1/jsr%3aroot/toto" | grep "jsr:root"
if [ $? -eq 0 ]; then
echo "nocanon test failed, we get \"jsr:root\"!!!"
clean_and_exit
exit 1
fi

# Test without UseNocanon On
sed 's:UseNocanon On::' $PREFIX/mod_proxy_cluster.conf > $PREFIX/mod_proxy_cluster_new.conf

docker cp $PREFIX/mod_proxy_cluster_new.conf MODCLUSTER-640:/usr/local/apache2/conf/mod_proxy_cluster.conf
docker exec -it MODCLUSTER-640 /usr/local/apache2/bin/apachectl restart
docker exec MODCLUSTER-640 /usr/local/apache2/bin/apachectl restart

# wait until the tomcats are back in mod_proxy_cluster tables
tomcat_wait_for_n_nodes 2
Expand All @@ -61,20 +61,20 @@ tomcat_wait_for_n_nodes 2
code=$(/usr/bin/curl -o /dev/null --silent --write-out '%{http_code}' http://localhost:8000/webapp1/index.html)
if [ "${code}" != "200" ]; then
echo "nocanon test failed, we get ${code} on http://localhost:8000/webapp1/index.html"
clean_and_exit
exit 1
fi
curl -v "http://localhost:8000/webapp1/jsr%3aroot/toto" | grep "jsr:root"
if [ $? -ne 0 ]; then
echo "NO nocanon test failed, we don't get \"jsr:root\"!!!"
clean_and_exit
exit 1
fi

# Test for just a proxypass / nocanon
sed 's:UseNocanon On::' $PREFIX/mod_proxy_cluster.conf > mod_proxy_cluster_new.conf
echo "ProxyPass / balancer://mycluster/ nocanon" >> $PREFIX/mod_proxy_cluster_new.conf

docker cp $PREFIX/mod_proxy_cluster_new.conf MODCLUSTER-640:/usr/local/apache2/conf/mod_proxy_cluster.conf
docker exec -it MODCLUSTER-640 /usr/local/apache2/bin/apachectl restart
docker exec MODCLUSTER-640 /usr/local/apache2/bin/apachectl restart

# wait until the tomcats are back in mod_proxy_cluster tables
tomcat_wait_for_n_nodes 2
Expand All @@ -83,16 +83,14 @@ tomcat_wait_for_n_nodes 2
code=$(/usr/bin/curl -o /dev/null --silent --write-out '%{http_code}' http://localhost:8000/webapp1/index.html)
if [ "${code}" != "200" ]; then
echo "nocanon test failed, we get ${code} on http://localhost:8000/webapp1/index.html"
clean_and_exit
exit 1
fi
curl -v "http://localhost:8000/webapp1/jsr%3aroot/toto" | grep "jsr:root"
if [ $? -eq 0 ]; then
echo "nocanon test failed, we get \"jsr:root\"!!!"
tomcat_all_remove
clean_and_exit
exit 1
fi

# clean tomcats
tomcat_all_remove
# and httpd
httpd_all_clean
1 change: 1 addition & 0 deletions test/MODCLUSTER-734/mod_proxy_cluster.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ LoadModule manager_module modules/mod_manager.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so
LoadModule watchdog_module modules/mod_watchdog.so
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so

ProxyHCExpr in_maint {hc('body') !~ /Under maintenance/}
ModProxyClusterHCTemplate hcmethod=GET hcexpr=in_maint hcuri=/status.jsp
Expand Down
Loading

0 comments on commit 6331394

Please sign in to comment.